[Top][All Lists]

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

bash bug in $()

From: Eric Blake
Subject: bash bug in $()
Date: Wed, 28 Dec 2005 18:20:34 +0000

Dan Jacobson uncovered what I believe is a bash bug:

See my arguments as to why I think this is a violation of
POSIX rules:

Although the Shell Substitutions portion of the manual
already recommends using `foo` instead of $(foo),
it may be worth adding to that section to also document
that bash 3.0 (I haven't verified whether bash 3.1 has
fixed the bug), zsh (as of 4.2.6), and ksh (5.2.14) all
have a bug in parsing command substitutions with an
embedded case, when you don' t use a leading ( for
each pattern:

$ k=$(case x in x) echo hi ; esac)
bash: syntax error near unexpected token `esac'
$ k=`case x in x) echo hi ; esac`
$ echo $k
$ k=$(case x in (x) echo bye ; esac)
$ echo $k

For that matter, the following examples are required
in the POSIX rationale, but are misparsed by several

$ echo $(
> cat <</eof
> a here-doc with )
> eof
> )
a here-doc with )
$ echo $(
> echo abc # a comment with )
> )

$ echo $(
> cat << /eof
> a here-doc with )
a here-doc with 
$ echo $(
> echo abc # a comment with )
> )

Eric Blake

reply via email to

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