[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash-5.0: problem with variable scoping in posix-mode
From: |
Chet Ramey |
Subject: |
Re: bash-5.0: problem with variable scoping in posix-mode |
Date: |
Wed, 30 Jan 2019 10:40:49 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
On 1/28/19 6:24 PM, Martijn Dekker wrote:
> 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.
Yes, I think so. This isn't how the discussion from back in May ended up,
but I think I will change the posix-mode behavior for the next release.
The default bash behavior will stay the same -- having assignments that
precede a special builtin persist past its execution is not something we
need to carry forward.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/