[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] local_builtin: do not overwrite previously saved options wit
From: |
Emanuele Torre |
Subject: |
Re: [PATCH] local_builtin: do not overwrite previously saved options with local - |
Date: |
Mon, 6 Feb 2023 16:55:39 +0100 |
User-agent: |
Mutt/2.2.9 (2022-11-12) |
On Mon, Feb 06, 2023 at 10:18:30AM -0500, Dale R. Worley wrote:
> The behavior of bash appears to be is "future changes in shell options
> using the 'set' builtin inside the current function invocation are
> restored to their prior values when the function returns".
Perhaps, the wording of the documentation is not great, but I don't
think it would make sense to expect `set -C; local -' to only set
noclobber in the dynamic scope of the current function, instead of the
previous scope.
`var=foo; local var; var=bar' works the same way, but running
`local var' after that does set var to "bar" in the previous scope.
With the current implementation, calling local - a second time
"commits" the changes to shell options happened after the previous
local - call.
This patch simply makes multiple calls to local - a no-op to match the
behaviour of local - in other shells, and avoid nasty surprises.
emanuele6