[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash 5.2 breaks our Arch Linux devtools
From: |
Greg Wooledge |
Subject: |
Re: Bash 5.2 breaks our Arch Linux devtools |
Date: |
Wed, 15 Feb 2023 11:42:49 -0500 |
On Wed, Feb 15, 2023 at 05:35:10PM +0100, Mike Jonkmans wrote:
> I once had that same issue:
> https://lists.gnu.org/archive/html/bug-bash/2015-10/msg00013.html
>
> Conclusion: the shopt is not yet working until the function has been run.
> (or after the line has been parsed).
Yes. This is not a change in bash 5.2. It would break in any version
of bash.
unicorn:~$ bash-2.05b -c 'x() { shopt -s extglob; echo *.pd@(f|qux); }'
bash-2.05b: -c: line 1: syntax error near unexpected token `('
bash-2.05b: -c: line 1: `x() { shopt -s extglob; echo *.pd@(f|qux); }'
The extglob shopt changes how bash parses commands as it reads them, so
it has to be in effect *before* bash reads a command which contains an
extended glob.
This means you can't turn it on in the middle of a compound command
(such as a function definition, a while loop, and if/then/fi, etc.).
You have to enable it before bash begins reading and parsing the compound
command.
I advise putting it as close to the top of the script as you can.