> Machine Type: i686-pc-cygwin > > Bash Version: 3.2 > Patch Level: 9 > Release Status: release > > Description: > If a command in $(...) contains a case-esac construction, the > bash prints a syntax error instead > of executing the code: > bash: syntax error near unexpected token `;;' > > Repeat-By: > A simple example is: x=$(a=4; case $a in 3) echo a=3;; 4) echo a=4;; > esac)
This is a long-standing problem, caused by the bash parser's requirement that parens match. Posix introduced the optional left paren before a case statement pattern list to finesse the problem, but current versions of the standard require that commands inside $(...) be parsed correctly even in the absence of balanced parens. Bash-4.0 will work as you expect, without requiring the parens to balance. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRU [EMAIL PROTECTED] http://tiswww.tis.case.edu/~chet/