nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] Environment variables - with or without $?

2017-03-24 09:10:09
    Date:        Fri, 24 Mar 2017 06:38:12 +0700
    From:        Robert Elz <kre(_at_)munnari(_dot_)OZ(_dot_)AU>
    Message-ID:  
<9028(_dot_)1490312292(_at_)andromeda(_dot_)noi(_dot_)kre(_dot_)to>


  |     ll() { ls -l "$@"; }
  | 
  | FOO=xx ll /tmp
  | 
  | sets FOO=xx for ll, and then exports it to the ls command inside, and
  | (if your shell implements this part of POSIX as written) leaves FOO
  | set in the shell with the value "xx" (maybe exported, maybe not.)

I should correct this - the latest POSIX version now makes it unspecified
whether (in this example) FOO will be left set in the shell or not (and
still whether it will be exported if it is set) - and what's more, also
makes it unspecified whether FOO gets exported to the environ for the ls
command called from the function.

That is, using a var assignment before a command that is implemented as
a function causes just about anything to happen...

And believe it or not, this is actually better than it used to be, as it
now permits shell implementors to implement it all rationally, without
losing the ability to claim posix conformance.

kre


_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>