[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

case pattern checking with bash -n fails

From: Paul Förster
Subject: case pattern checking with bash -n fails
Date: Fri, 1 Jun 2018 19:17:29 +0200

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.3 
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-suse-linux-gnu' 
-DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -fmessage-length=0 
-grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector 
-funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g  
-D_GNU_SOURCE -DRECYCLES_PIDS -Wall -g -Wuninitialized -Wextra 
-Wno-unprototyped-calls -Wno-switch-enum -Wno-unused-variable 
-Wno-unused-parameter -Wno-parentheses -ftree-loop-linear -pipe -DBNC382214=0 
-DIMPORT_FUNCTIONS_DEF=0 -fprofile-use
uname output: Linux weasel 4.4.132-53-default #1 SMP Wed May 23 06:57:07 UTC 
2018 (036cd2f) x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-suse-linux-gnu

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

Bash seems to have a parens checking problem with patterns in a case statement 
using the -n option. I need a "case" where I can identify a word where a word 
starts with a letter and may be followed by zero or more letters, digits, 
dashes or underscores. It works fine when running, but miserably fails the bash 
-n test, which I also *need* it to pass. Or am I doing something wrong here?

System is openSUSE 42.3, all current patches applied. I can't change that.

file: case-test (700)

shopt -s extglob
case "${1}" in
        echo "${1} matches" ;;
    # ... some more cases here...
    *) echo "no match." ;;

Runs fine:

$ ./case-test "y"
y matches
$ ./case-test "1"
no match.
$ ./case-test "yes17match"
yes17match matches
$ ./case-test "17nomatch"
no match.

But fails -n check:

$ bash -n case-test 
case-test: line 5: syntax error near unexpected token `('
case-test: line 5: `    +([[:alpha:]])*([[:alnum:]-_]))'

Also tried with leading open parens and other variations:
Didn't work. All fail bash -n. Please advise.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]