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


Groups > gnu.bash.bug > #13745

Re: Unset array doesn't work

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Robert Elz <kre@munnari.OZ.AU>
Newsgroups gnu.bash.bug
Subject Re: Unset array doesn't work
Date Mon, 26 Feb 2018 16:31:09 +0700
Lines 44
Approved bug-bash@gnu.org
Message-ID <mailman.9743.1519640672.27995.bug-bash@gnu.org> (permalink)
References <790ade74-690f-541c-9ab4-6359917442d0@case.edu> <a56e05b1-0b34-1cb2-6073-91c12f27e228@gmail.com> <a642644f-e475-6361-140e-5b47ab4e321c@case.edu> <755d61fa-d2bc-8855-bc30-4388aff40691@gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1519640672 23889 208.118.235.17 (26 Feb 2018 10:24:32 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org
To chet.ramey@case.edu
Envelope-to bug-bash@gnu.org
In-Reply-To <790ade74-690f-541c-9ab4-6359917442d0@case.edu>
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2001:3c8:9009:181::2
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:13745

Show key headers only | View raw


    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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web