Re: extglob can be erroneously enabled in bash-5.2 through comsub nestin
From:
Kerin Millar
Subject:
Re: extglob can be erroneously enabled in bash-5.2 through comsub nesting
Date:
Fri, 7 Oct 2022 00:58:43 +0100
On Thu, 6 Oct 2022 15:49:26 -0400
Chet Ramey <chet.ramey@case.edu> wrote:
> On 10/2/22 4:51 AM, Kerin Millar wrote:
>
> > $ declare -p BASH_VERSION
> > declare -- BASH_VERSION="5.2.0(1)-release"
> > $ BASH_COMPAT=50; shopt extglob; : $(: $(: $(:))); shopt extglob
> > extglob off
> > extglob on
>
> Thanks for the report. I've attached the patch I applied to fix this.
Thanks for the patch. It is probably sufficient for the downstream bug report
to be closed. Unfortunately, it remains the case that the >=5.2-rc3 parser is
buggy. Consider the following, as conducted using 5.2.2 with said patch applied.
$ declare -p BASH_VERSION
declare -- BASH_VERSION="5.2.2(1)-release"
$ BASH_COMPAT=50
$ [[ foo = $(: $(shopt extglob >&2)) ]]
extglob off
$ shopt extglob
extglob off
$ [[ foo = $(: $(shopt extglob >&2) ]]
> ^C
$ shopt extglob
extglob on
Note that, within the second test, the comsub parentheses are deliberately
imbalanced, causing bash to display the PS2 prompt and wait for further input.
I then interrupt bash with ^C and check on the status of the extglob option,
only to find that - yet again - it has been unexpectedly enabled.
This is perfectly reproducible, provided that those exact steps are carried out
as shown. In particular, one cannot skip the first (syntactically correct)
test, which must nest at least one comsub within another.
--
Kerin Millar