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


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

Re: [BUG] 'unset' fails silently under specific conditions

Started byRobert Elz <kre@munnari.OZ.AU>
First post2018-05-02 04:42 +0700
Last post2018-05-02 04:42 +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: [BUG] 'unset' fails silently under specific conditions Robert Elz <kre@munnari.OZ.AU> - 2018-05-02 04:42 +0700

#14075 — Re: [BUG] 'unset' fails silently under specific conditions

FromRobert Elz <kre@munnari.OZ.AU>
Date2018-05-02 04:42 +0700
SubjectRe: [BUG] 'unset' fails silently under specific conditions
Message-ID<mailman.13229.1525211094.27995.bug-bash@gnu.org>
    Date:        Tue, 1 May 2018 14:36:29 -0400
    From:        Chet Ramey <chet.ramey@case.edu>
    Message-ID:  <71d753dc-036f-7fd7-d703-408c3f8ac202@case.edu>

  | OK, so which is it? Does an assignment statement preceding a special
  | builtin in a shell function create a local variable (as we discussed
  | just yesterday) or does it create a global variable because `Posix'?

Unless the variable didn't exist already, it creates nothing.   It sets the
variable for the purposes of the special builtin (and exports it) and
according to posix allows those values to persist in the current env
(though doing that is stupid .. just a bug in earlier implementations).

There is nothing related to local variables here at all, and no reason
at all for one to be created - just the globals.

The earlier test case had the "typeset" command added, which is non-standard
and so can do anything - including making local variables (though personally
I'd suggest it should do that only if called using its "local" alias, or when 
given an option to request that behaviour- there should be a way for a function
to alter the attributes of global variables).

  | Because if it creates a local variable, that's the one the `unset'
  | builtin unsets, leaving the global variable created by the first
  | assignment statement untouched.

Here, it doesn't - it was the typset that created the local variable
(and then we can have our long running discussion about the
nature of local vars and the model they should implement) but
that is not relevant to this example from Martijn.

kre


[toc] | [standalone]


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


csiph-web