bash bug in $()

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

 



Dan Jacobson uncovered what I believe is a bash bug:
http://article.gmane.org/gmane.comp.shells.bash.bugs/8574

See my arguments as to why I think this is a violation of
POSIX rules:
http://article.gmane.org/gmane.comp.shells.bash.bugs/8575

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
hi
$ k=$(case x in (x) echo bye ; esac)
$ echo $k
bye

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

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

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

--
Eric Blake


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux