[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash-4.0 regression with comments in subshelled case
From: |
Mike Frysinger |
Subject: |
Re: bash-4.0 regression with comments in subshelled case |
Date: |
Tue, 3 Mar 2009 16:04:31 -0500 |
User-agent: |
KMail/1.11.0 (Linux/2.6.28; KDE/4.2.0; x86_64; ; ) |
On Tuesday 03 March 2009 15:28:28 Chet Ramey wrote:
> Mike Frysinger wrote:
> > code that uses case statements in a subshell and then uses comments
> > causes bash to trigger a parsing error:
> > $ cat test.sh
> > echo $(case a in (a) echo ok ;; # comment
> > )
> > $ sh ./test.sh
> > ./test.sh: line 1: unexpected EOF while looking for matching `)'
> > ./test.sh: line 3: syntax error: unexpected end of file
>
> As well it should. Bash parses the contents of command substitutions, so
> it will look forever for the missing `esac'. The error message could be
> improved.
sorry, the test case in the e-mail had a typo and didnt match the test case i
was actually using. the 2nd line should clearly be "esac)"
variations show that comments between the last ;; and the esac results in an
error. other locations work fine.
this fails:
echo $(case a in (a) echo ok;; # comment
esac)
this works:
echo $(case a in (a) echo ok;; # comment
(b) echo moo;;
esac)
-mike
signature.asc
Description: This is a digitally signed message part.