[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: case pattern checking with bash -n fails
From: |
Greg Wooledge |
Subject: |
Re: case pattern checking with bash -n fails |
Date: |
Fri, 1 Jun 2018 13:35:34 -0400 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
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