2017-03-20 16:32:10 -0400, Chet Ramey: [...] > > See also: > > > > $ bash -c 'f() { unset a; echo "$a";}; a=1; a=2 f' > > 1 > > > > already mentioned. > > A distinction without a difference; the behavior is explicitly the same. [...]
One I haven't mentioned yet is: $ bash -c 'f() { local a; unset a; echo "$a";}; a=1; a=2 f' 1 IOW, the work around I was mentioning earlier (of using "local" before "unset" to make sure "unset" unsets) doesn't work in that case. You'd need to use the same work around as for mksh/yash (call unset in a loop until the variable is really unset (with the nasty side effect of unsetting the variable in a scope you're need meant to tamper with) so you'd want to do it in a subshell). -- Stephane