Op 27-01-19 om 22:59 schreef Chet Ramey:
> This is a consequence of a combination of two POSIX features. First, POSIX
> requires assignment statements preceding special builtins to create global
> variables (POSIX has no local variables) that persist in the shell context
> after the special builtin completes.

Exactly because POSIX has no notion of local variables (but bash does),
I don't think there is anything that requires you to ignore/override
bash local variables in this context. Any fully POSIX-compliant script
will not use local variables, so is not affected either way. I think
that leaves you free to do the logical thing and keep the scope local as
defined by the user.

>  Second, POSIX requires* that
> assignment statements preceding function calls have the same variable-
> assignment behavior as special builtins.

When combining POSIX mode with a bash local variable scope, I would take
that to mean the assignment should persist for as long as the local
scope does.

[...]
> (*) The most recent version of the standard has removed this requirement
> for shell functions, and I will change that behavior for the next release
> of bash.

Thank you for that. dash and yash recently got rid of that behaviour, I
hope other shell authors will also follow suit...

- M.

Reply via email to