[Top][All Lists]

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

Re: "typeset +x var" to a variable exported to a function doesn't remove

From: Chet Ramey
Subject: Re: "typeset +x var" to a variable exported to a function doesn't remove it from the environment.
Date: Fri, 05 Apr 2013 16:50:18 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130307 Thunderbird/17.0.4

On 3/25/13 9:37 PM, Dan Douglas wrote:
> Hello,
>     $ function f { typeset +x x; typeset x=123; echo "$x"; sh -c 'echo "$x"'; 
> }; x=abc f
>     123
>     abc
>     $ echo "$BASH_VERSION"
>     4.2.45(1)-release
> This is inconsistent with a variable defined and exported any other way. 
> (ksh93/mksh/zsh don't have this issue. Dash doesn't actually export the 
> variable to the environment in this case, but just "localizes" it, and 
> requires a separate export.)

The question is whether or not variables in the temporary environment
passed to a shell function and that function's local variables exist in
the same namespace.  Bash makes a distinction, to a certain extent,
between the two, but it's inconsistent, as you say.  I'll take a look at
this, and maybe it will be in bash-4.3.


``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]