Re: [Help-bash] Why `echo !(*.l).c` behaves different depending on the c
From:
Eduardo Bustamante
Subject:
Re: [Help-bash] Why `echo !(*.l).c` behaves different depending on the context?
Date:
Fri, 8 Feb 2019 21:20:38 -0800
On Fri, Feb 8, 2019 at 9:05 PM Peng Yu <address@hidden> wrote:
(...)
> I am not sure this link is relevant.
OK, since you didn't read the link:
| extglob changes the way certain characters are parsed. It is
necessary to have a newline (not just a semicolon) between shopt -s
extglob and any subsequent commands to use it. **You cannot enable
extended globs
| inside a group command that uses them**, because **the entire
block** is parsed before the shopt is evaluated. Note that the typical
function body is a group command. An unpleasant workaround could be to
use a subshell
| command list as the function body.