Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #12268

Re: Weird shopt behavior

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: Weird shopt behavior
Date 2016-01-21 08:16 -0500
Message-ID <mailman.2693.1453382213.843.bug-bash@gnu.org> (permalink)
References <56A02125.2040904@gmail.com> <20160121061647.GA2740@ma.sdf.org>

Show all headers | View raw


On Thu, Jan 21, 2016 at 12:16:48AM -0600, Eduardo A. Bustamante López wrote:
> - You can't enable extglob and use extglob syntax in the same line
> - You can't enable extglob in a function and use extglob syntax in the same
> line

More generally, you have to enable extglob to change the parser's
behavior BEFORE you can parse a command that uses extended globs.

When bash reads any compound command -- which includes function
definitions, but also if statements, while loops, etc. -- it has to
read the entire compound command, parsing it as it goes, in order to
find out where the command ends.  The commands inside of it are not
executed yet, so the parser is still acting in whatever mode it was
set to use before the start of the compound command.

As Eduardo said, you should enable extglob at the very beginning of
the script.  Treat it like the second line of the shebang.

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Weird shopt behavior Greg Wooledge <wooledg@eeg.ccf.org> - 2016-01-21 08:16 -0500

csiph-web