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.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/