Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Failure of "typeset" and exit status



On Mon, 11 May 2015 19:43:20 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> torch% ( () { typeset +g -m \* && echo No error } )
> (anon): failed to change user ID: operation not permitted
> (anon): failed to change group ID: operation not permitted
> (anon): failed to change effective user ID: operation not permitted
> (anon): failed to change effective group ID: operation not permitted
> No error
> torch% 
> 
> OK, that's not SO bad, except that "typeset +g -m \*" is intended to
> have made all the variables local

No, it isn't.  The "g" is a bit of a snare and a delusion.  "-g" means
"use the global scope, never create a new variable even if you're a
local scope".  "+g" means "it's OK to create a new variable if you
need", it doesn't mean "never use the existing variable".  Remember that
option letters with no argument have a binary effect in typeset and +g
is the default (exactly equivalent to saying -g is not the default).
You're using the -m option to refer to existing variables, so the +g has
no effect.

pws



Messages sorted by: Reverse Date, Date, Thread, Author