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


Groups > gnu.bash.bug > #14155 > unrolled thread

Re: extglob patterns not expanded in -c command-strings

Started byChet Ramey <chet.ramey@case.edu>
First post2018-05-27 21:36 -0400
Last post2018-05-27 21:36 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: extglob patterns not expanded in -c command-strings Chet Ramey <chet.ramey@case.edu> - 2018-05-27 21:36 -0400

#14155 — Re: extglob patterns not expanded in -c command-strings

FromChet Ramey <chet.ramey@case.edu>
Date2018-05-27 21:36 -0400
SubjectRe: extglob patterns not expanded in -c command-strings
Message-ID<mailman.603.1527471385.1292.bug-bash@gnu.org>
On 5/27/18 7:38 PM, marcelpaulo@gmail.com wrote:

> Bash Version: 4.4
> Patch Level: 19
> Release Status: release
> 
> Description:
> extglob patterns are not expanded in -c command-strings, even if extglob is set within the command-string. For instance, running:
> 
> bash -c 'shopt -s extglob; echo @(foo*|bar*)'
> 
> generates this error:
> 
> bash: -c: line 0: syntax error near unexpected token `('
> bash: -c: line 0: `shopt -s extglob; echo @(foo*|bar*)'

Of course. This is how the shell should behave. Bash always reads at least
one complete line of input before parsing and executing any of the commands
on that line.

If you apply that rule, you can figure out the answer: extglob changes the
behavior of the parser, so it must be enabled before a command is parsed.
The complete line of input is read before any of it is parsed, and the
complete line is parsed before any of it is executed. As a consequence, the
extglob option must be enabled for the ( to be recognized as an extended
globbing pattern instead of an operator.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web