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: Bernd Eggink
Subject: Re: Bash prints syntax error when command in $(...) contains case-esac
Date: Tue, 30 Sep 2008 14:59:12 +0200
User-agent: Thunderbird 2.0.0.17 (X11/20080914)

Juergen Gohlke schrieb:
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: cygwin
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash.exe' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='cygwin' -DCONF_MACHTYPE='i686-pc-cygwin' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DRECYCLES_PIDS -I. -I/home/eblake/bash-3.2.9-11/src/bash-3.2 -I/home/eblake/bash-3.2.9-11/src/bash-3.2/include -I/home/eblake/bash-3.2.9-11/src/bash-3.2/lib -O2 -pipe uname output: CYGWIN_NT-5.0 JONA 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
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)
       (typed in an interactive shell or being part of a shell script).
The same error has been seen on Windows Vista, Windows XP and Windows2000. The same error has been seen with an earlier version of bash, i.e. 2.05b.0(8)-release
       If $(...) is replaced by `...`, it works.

The problem is caused by the semi-parenthesized case labels 3) and 4). Bash matches the first unpaired right paren (after the 3) with the last unpaired left paren (in $( ). Using (3) and (4) instead makes the example work.
Unpaired parens are hideous anyway, IMHO.

Regards,
Bernd

--
Bernd Eggink
address@hidden
http://sudrala.de




reply via email to

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