Stephane Chazelas <stephane.chaze...@gmail.com> wrote:

> 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.

This is an interesting behavior, but it is not related to local/dynamic 
scoping, since this is a test whether a function is run in a sub-shell.

I am not sure whether this is covered by POSIX at all.


Jörg

-- 
 EMail:jo...@schily.net                    (home) Jörg Schilling D-13353 Berlin
    joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/
 URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'

Reply via email to