Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #13745 > unrolled thread

Re: Unset array doesn't work

Started byRobert Elz <kre@munnari.OZ.AU>
First post2018-02-26 16:31 +0700
Last post2018-02-26 16:31 +0700
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Unset array doesn't work Robert Elz <kre@munnari.OZ.AU> - 2018-02-26 16:31 +0700

#13745 — Re: Unset array doesn't work

FromRobert Elz <kre@munnari.OZ.AU>
Date2018-02-26 16:31 +0700
SubjectRe: Unset array doesn't work
Message-ID<mailman.9743.1519640672.27995.bug-bash@gnu.org>
    Date:        Mon, 12 Feb 2018 09:26:37 -0500
    From:        Chet Ramey <chet.ramey@case.edu>
    Message-ID:  <790ade74-690f-541c-9ab4-6359917442d0@case.edu>

  | This is bash's dynamic scoping. The visibility of a local variable is
  | restricted to a function and its children, and `unset' removes the
  | currently-visible instance. Removing such an instance can `unconver' an
  | instance in a previous scope.

Frankly this is brain dead, unset should not be unlocal (or something equiv)

eg: if I have a func

	myfunc() {
		local IFS
		unset IFS
		# do some code
	}

the very last thing that I want is for the global IFS to apply.

The intent is to use the default IFS value, which is what an unset IFS
produces, without affecting the current global IFS setting.

In this example, I could do IFS=$' \t\n' if I was willing to assume that $'...'
support exists (the shell executing the script is not necessarily going to
be bash) or I could do

		IFS=' 	
'

and just hope that survives as written (it would straight from the editor,
but who knows when someone else decides that trailing whitespace on
lines should all be deleted).   Variants to avoid that get even uglier.

All the variable modification operations that apply to globals should be
able to be applied to local vars, and have the exact same effect.
Unsetting a local variable should result in a local variable that is unset.
No more, no less.   If an unlocal command is needed, add it (either as
a new command, or as some option to local or something.)

kre

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web