On 02/25/2012 09:42 PM, Davide Baldini wrote: > Configuration Information [Automatically generated, do not > change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation > CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' > -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' > -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include > -I../bash/lib -g -O2 -Wall uname output: Linux debianBunker > 2.6.26-2-686 #1 SMP Wed Sep 21 04:35:47 UTC 2011 i686 GNU/Linux > Machine Type: i486-pc-linux-gnu > > Bash Version: 4.1 Patch Level: 5 Release Status: release
Ok so had a play around with it. Its not specific to sub shells its commands. so the following also doesn't work. shopt -u extglob if true; then shopt -s extglob echo !(x) fi this is because bash treats the entire if statement as a command. so the second shopt isn't evaluate before the !(x) is parsed. therefore the error message. The error message is a parsing error not an expansion error I think. so bash sees the above as shopt -u extglob if true; then shopt -s extglob; echo !(x); fi as a workaround you could try/use is this it delays parsing the !(x) until after the shopt is evaluated. ( shopt -s extglob eval 'echo !(x)' ) Not sure if this is expected behavior. hth deth.