2017-09-29 12:02:17 -0400, Chet Ramey:
[...]
> I have to check my ksh88 book, but I believe that ksh88 functions had
> local scope for traps and options as well as variables.
[...]
Yes, you're right, thanks.
I knew that was the case for ksh93's functions defined with the
function f {...;} syntax (though using static scoping), but
hadn't realised ksh88 also did local (dynamic) scoping for
options and traps even with the f(){...;} syntax.
So it looks like that's another non-compliance.
If I read the spec correctly, one should expect
noglob() { set -f; }
glob() { set +f; }
noglob; echo *; glob
to output *, but that doesn't work with /usr/xpg4/bin/sh on
Solaris.
Local scope for options is useful in practice (though a
lot more useful when it doesn't affect other functions called
from the function as with static scoping) but here breaks
compliance and expectations when done by default. At least with
ash, zsh, bash4.4, ksh93, you get the choice. ksh88 doesn't seem
to support ksh93's ". f" syntax to avoid the local scope.
--
Stephane