bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash prints syntax error when command in $(...) contains case-esac


From: Chet Ramey
Subject: Re: Bash prints syntax error when command in $(...) contains case-esac
Date: Tue, 30 Sep 2008 17:49:27 -0400

> 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    chet@case.edu    http://tiswww.tis.case.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]