Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11749
| From | Eduardo A. Bustamante López <dualbus@gmail.com> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Inconsistency in the handling of variables inside a function when using a tempenv variable |
| Date | 2015-10-22 17:34 -0500 |
| Message-ID | <mailman.840.1445553297.7904.bug-bash@gnu.org> (permalink) |
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/
Back to gnu.bash.bug | Previous | Next | Find similar
Inconsistency in the handling of variables inside a function when using a tempenv variable Eduardo A. Bustamante López <dualbus@gmail.com> - 2015-10-22 17:34 -0500
csiph-web