[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shopt -u compat* (re)sets BASH_COMPAT to 51

From: Mihai Moldovan
Subject: Re: shopt -u compat* (re)sets BASH_COMPAT to 51
Date: Mon, 14 Feb 2022 10:30:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

* On 2/13/22 10:50 PM, Chet Ramey wrote:
> Hmmmm. So what you're proposing is that `shopt -u compat43' if compat43 is
> not set should not reset the compatibility level to the current version.
> OK.
> I think we could do this by interrogating $BASH_COMPAT after unsetting the
> appropriate compat_NN option.
> Or maybe leaving shell_compatibility_level alone if it's > 44 (the last
> compat_NN option) and <= DEFAULT_COMPATIBILITY_LEVEL (the current version)
> instead of unconditionally setting it to DEFAULT_COMPATIBILITY_LEVEL. But
> then you'd be required to unset BASH_COMPAT to get back to the current
> compatibility level, which is supported now but not required.

The easiest way to do this would be to check if the old value matches the new
one and in case both were unset, just do nothing.

However, looking at the source, I understand that this is not easily possible,
since the old value is overwritten in toggle_shopts() immediately and only the
new mode passed to the registered set_func fptr.

I'd refactor this to also give it the old value and just turn
set_compatibility_value() into a no-op if (!old_val) && (!new_val).


Attachment: OpenPGP_signature
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]