[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: extglob and ()/{}
From: |
Peng Yu |
Subject: |
Re: extglob and ()/{} |
Date: |
Tue, 6 Apr 2021 10:59:50 -0500 |
> touch foobar foobaz; { shopt -s extglob; }; echo foo@(bar|baz)
>
> That'll work. But it cannot be declared within the same compound command in
> which it is used. That also goes for functions, if statements, loops, etc.
> Ideally, if you want to use extglob in a script, just set it once at the
> beginning of the script and be done with it. You'd be stretching to find a
> place where
> having it on where you don't need it would be a problem, IMO, anyway.
How likely will `shopt -s extglob` break a script that does not have it set?
It seems to me the following patterns are unlikely to occur in scripts
that don't have `shopt -s extglob`?
`?(pattern-list)`
`*(pattern-list)`
`+(pattern-list)`
`@(pattern-list)`
`!(pattern-list)`
If so, then it is better just set `shopt -s extglob` by default in all
bash scripts?
--
Regards,
Peng