[Top][All Lists]

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

Re: Local envvar remaining after function call

From: Chet Ramey
Subject: Re: Local envvar remaining after function call
Date: Tue, 15 Oct 2013 23:22:23 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.0.1

On 10/14/13 9:51 AM, Akim Demaille wrote:
> Hi!
> I have this weird behavior that I do not understand: when running
>       FOO=1 foo
> I do not expect FOO to remain in the env after foo was invoked, even
> if foo is a shell function.  However it does, _if_ bash is invoked
> in POSIX mode, something which I couldn't find documented in the
> model (and I wouldn't know where to find this information in POSIX).

Yes, Posix requires it.  It's described in the info manual:

 31. Assignment statements preceding shell function calls persist in the
     shell environment after the function returns, as if a POSIX
     special builtin command had been executed.

An extract from the info manual describing Posix mode (the same as the
POSIX file in the bash distribution) is available at



``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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