On Tuesday 03 March 2009 17:14:16 Chet Ramey wrote:
> Mike Frysinger wrote:
> > 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)"
>
> In that case, try the attached patch.

thanks, that fixes it

> And note that you don't have to
> use extra left parens around the pattern lists.

with bash-4, sure.  but this code needs to be compatible with bash-3 for a 
while and that means working around the old bug of subshelled case statements 
not parsing correctly.
-mike

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

Reply via email to