Path: csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!usenet.stanford.edu!not-for-mail From: Greg Wooledge Newsgroups: gnu.bash.bug Subject: Re: Weird shopt behavior Date: Thu, 21 Jan 2016 08:16:18 -0500 Lines: 18 Approved: bug-bash@gnu.org Message-ID: References: <56A02125.2040904@gmail.com> <20160121061647.GA2740@ma.sdf.org> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: usenet.stanford.edu 1453382214 21259 208.118.235.17 (21 Jan 2016 13:16:54 GMT) X-Complaints-To: action@cs.stanford.edu To: Petr =?iso-8859-1?B?U2tvPz/taw==?= , bug-bash@gnu.org Envelope-to: bug-bash@gnu.org Content-Disposition: inline In-Reply-To: <20160121061647.GA2740@ma.sdf.org> User-Agent: Mutt/1.4.2.3i X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 139.137.100.1 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:12268 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.