(>> == pourko, > == Greg)
>> Sorry, Greg, but this is no "compound" command, these are separate commands:
>>
>> $ shopt -s extglob; echo !(this)
>That is another case where it fails, correct.
>However, in your original email, you did indeed have the shopt inside
>a compound command. That's why I phrased it the way I did.
>If you wish, I'll add some additional verbosity to my original warning:
> Turning on extglob changes how bash parses its input, and bash parses
> line by line. In addition, bash has to parse compound commands (if,
> for, while, functions and so on) as a whole.
> The "shopt -s extglob" command must have been parsed and executed
> BEFORE the parser tries to use extended globs.
> Therefore, you cannot put "shopt -s extglob" on the same line, or
> in the same compound command, as any extended glob.
> I always advise people that if they're going to use extglob, it should
> be done right up at the top of the script, either immediately below
> the shebang, or after any mandatory comments that their boss demands
> be present. Definitely before any function declarations or loops.
This whole thread sounds like a tempest in a teapot; I mean, it is what it is,
accept
it and move on. Face the fact that the bash (and pretty much any other shell
language; nothing specific to bash here) parser is line-oriented, even though
it does
have aspects of free-form languages (e.g., C). It is sort of a mishmash of the
two.
Incidentally, I sometimes run into this if I have an alias that I want to
convert to a
function. Assume foo is a (complicated) alias and you do:
unalias foo;foo() { echo New definition for foo; }
It no workie...
But here's the thing: As far as I can tell, extglob is on-by-default - in all
the
versions of bash that I was able to test - so I don't understand why OP is
messing
around with turning it on and off. Or why Greg is talking about turning it on
at the
top of the script.
Notes on the assertion above:
1) I do not have a compiled version of 5.3 release, but I tested on 5.3 rc2
(the
most recent version I have) and it was on-by-default.
2) The documentation seems to be out of step. Under the "shopt" command,
extglob
does not contain the usual notation of "This option is enabled by
default".
It should, shouldn't it?
=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.
When responding to my posts, please try to refrain from giving bureaucratic
answers.
If you have nothing useful to say, then just click Next and go on.