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

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to