[Top][All Lists]

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

Re: Weird shopt behavior

From: Greg Wooledge
Subject: Re: Weird shopt behavior
Date: Thu, 21 Jan 2016 08:16:18 -0500
User-agent: Mutt/

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.

reply via email to

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