Weird shopt behavior

2016-01-20 Thread pjump
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -D_FORTIFY_SOURCE=2 -g 
-O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat 
-Werror=format-security -Wall
uname output: Linux laptop 3.19.0-32-generic #37~14.04.1-Ubuntu SMP Thu Oct 22 
09:41:40 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.3
Patch Level: 11
Release Status: release

Description:
  Not sure if this is a bug (it does bug me a little), however:

  main(){
shopt -s extglob
local line=' x bar'
echo "${line##*( )}"
case "$line" in
  *( )x*) ;;
  *) ;;
esac
  }

   fails with a syntax error on the first parenthesis in the case statement. It 
does turn extglob on
  in other contexts (the echo line), but the extglob in the case statement 
fails.
Interestingly, moving `shopt -s extglob` outside of main fixes the problem.

Fix:
[Description of how to fix the problem.  If you don't know a
fix for the problem, don't include this section.]



Weird shopt behavior

2016-01-20 Thread pjump
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -D_FORTIFY_SOURCE=2 -g 
-O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat 
-Werror=format-security -Wall
uname output: Linux laptop 3.19.0-32-generic #37~14.04.1-Ubuntu SMP Thu Oct 22 
09:41:40 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.3
Patch Level: 11
Release Status: release

Description:
  Not sure if this is a bug (it does bug me a little), however:

  main(){
shopt -s extglob
local line=' x bar'
echo "${line##*( )}"
case "$line" in
  *( )x*) ;;
  *) ;;
esac
  }

   fails with a syntax error on the first parenthesis in the case statement. It 
does turn extglob on
  in other contexts (the echo line), but the extglob in the case statement 
fails.
Interestingly, moving `shopt -s extglob` outside of main fixes the problem.

Fix:
[Description of how to fix the problem.  If you don't know a
fix for the problem, don't include this section.]



Weird shopt behavior

2016-01-20 Thread Petr Skočík
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib 
-D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4
-Wformat -Werror=format-security -Wall
uname output: Linux laptop 3.19.0-32-generic #37~14.04.1-Ubuntu SMP Thu
Oct 22 09:41:40 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.3
Patch Level: 11
Release Status: release

Description:
  Not sure if this is a bug (it does bug me a little), however:

  main(){
shopt -s extglob
local line=' x bar'
echo "${line##*( )}"
case "$line" in
  *( )x*) ;;
  *) ;;
esac
  }
  main "$@"

   fails with a syntax error on the first parenthesis in the case
statement. It does turn extglob on
  in other contexts (the echo line), but the extglob in the case
statement fails.
Interestingly, moving `shopt -s extglob` outside of main fixes the problem.





Re: Weird shopt behavior

2016-01-20 Thread Eduardo A . Bustamante López
Hey,

We got your report three times. Try to be more patient ;)

This is not a bug. When you use shopt -s extglob, you change how bash parses
the input script. But it has some restrictions:

- You can't enable extglob and use extglob syntax in the same line
- You can't enable extglob in a function and use extglob syntax in the same
line

The recommendation is to do what you did: enable it at the beginning of your
script.

So, not a bug. And don't expect a fix. That's just how it works :-)

-- 
Eduardo Bustamante
https://dualbus.me/