Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14198 > unrolled thread

case pattern checking with bash -n fails

Started byPaul Förster <paul.foerster@gmail.com>
First post2018-06-01 19:17 +0200
Last post2018-06-01 19:17 +0200
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug


Contents

  case pattern checking with bash -n fails Paul Förster <paul.foerster@gmail.com> - 2018-06-01 19:17 +0200

#14198 — case pattern checking with bash -n fails

FromPaul Förster <paul.foerster@gmail.com>
Date2018-06-01 19:17 +0200
Subjectcase pattern checking with bash -n fails
Message-ID<mailman.951.1527874256.1292.bug-bash@gnu.org>
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.3 -L/home/abuild/rpmbuild/BUILD/bash-4.3/../readline-6.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

Description:
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.

Repeat-By:
file: case-test (700)
==================8<------------------
#!/bin/bash

shopt -s extglob
case "${1}" in
    +([[:alpha:]])*([[:alnum:]-_]))
        echo "${1} matches" ;;
    # ... some more cases here...
    *) echo "no match." ;;
esac
==================8<------------------

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:
    (+([[:alpha:]])*([[:alnum:]-_]))
    (@([[:alpha:]])*([[:alnum:]-_]))
    [[:alpha:]]*([[:alnum:]-_]))
...
Didn't work. All fail bash -n. Please advise.
-- 
cul8er

Paul
paul.foerster@gmail.com


[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web