FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.

» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

LinkBack Thread Tools
Old 01-30-2009, 09:34 AM
Mart Frauenlob
Default 'bash -n' - extended pattern matching - case buitin: problem with syntax check script

Good day!

I've been writing a bash function to check the syntax of other bash
scripts (using ´bash -n'), before loading them with the ´source' builtin.
Everything runs fine, until I use extended pattern matching in
combination with the ´case' builtin.

System: Debian linux 4.0
Bash version: GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu)

Here's my testing script:

The file (script) to be checked:
shopt -s extglob

case "${foo}" in
foo) echo foo ;;
bar) echo bar ;;
+([[:digit:]])) echo extglob_test ;;

The syntax check function:
shopt -s extglob

echo "checking syntax in ${1}"
"${SHELL}" -n "${1}" || { echo "Syntax errors in "${1}"."; return 1; }

syntax_check $1

# running it normaly, returns NO ERROR:
./${1} 666

eris:~/myscripts# ./syntax_check syntax_check_input
checking syntax in syntax_check_input
syntax_check_input: line 11: syntax error near unexpected token `('
syntax_check_input: line 11: ` +([[:digit:]])) echo extglob_test ;;'

Running the script to be checked normaly, works fine, so I assume using
extended pattern matching this way is legal.

My questions are:

1: Am I doing something wrong in the script?
2: If not, can we call this a bug?
3: If it's a bug, can someone tell me, if it exists in newer bash versions?

Thanks for your help!



To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Thread Tools

All times are GMT. The time now is 08:18 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org