I found this some time ago, but didn't report it because I couldn't come up
with a patch:

dualbus@hp ~ % for sh in bash mksh zsh ksh93 dash; do $sh -c 
't=${KSH_VERSION+typeset}; f() { x=3; ${t:-local} x; echo $x; }; [ "$(f)" = 
"$(x=4 f)" ]'; echo $sh $?; done
bash 1
mksh 0
zsh 0
ksh93 0
dash 0

dualbus@hp ~ % bash -xc 'f() { x=3; local x; echo $x; }; f; x=4 f'              
                       
+ f
+ x=3
+ local x
+ echo

+ x=4
+ f
+ x=3
+ local x
+ echo 3
3

I'm putting it here so I don't forget about it.

Bash is the only one that handles this: tmpenv - global - local variable chain
in that way.

-- 
Eduardo Bustamante
https://dualbus.me/

Reply via email to