[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Robert Elz
Subject: Re: [Nmh-workers] Environment variables - with or without $?
Date: Fri, 24 Mar 2017 21:08:23 +0700

    Date:        Fri, 24 Mar 2017 06:38:12 +0700
    From:        Robert Elz <address@hidden>
    Message-ID:  <address@hidden>

  |     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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]