2014-12-09 10:59:14 +0000, Stephane Chazelas:
[...]
> $ a=0 ksh -c 'function f { typeset a=1; g; h; echo "f: $a"; }; function g { 
> a=2; }; function h { typeset a=3; };f'
> f: 1
> 
> "f" doesn't have to worry about alien functions changing its
> local variables under its feet.
[...]

(for clarification)

It still has to worry about alien functions declared using the
Bourne syntax though (as those are interpreted in their parent's
scope and don't have a separate scope except for the positional
parameters):

$ ksh -c 'function f { typeset a=1; g; echo $a; }; g() a=2; f'
2

(or sourced scripts or "eval"ed variables...).

-- 
Stephane

Reply via email to