On Fri, Jun 01, 2018 at 07:17:29PM +0200, Paul Förster wrote:
> 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<------------------

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

With -n in effect, bash will never execute the shopt -s extglob command,
so it never puts the parser into extglob mode, so it fails with a syntax
error on the extended glob.

You'll need to put the parser into extglob mode manually:

bash -n -O extglob case-text

Reply via email to