[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Parsing error when "case" in "for" in $()
From: |
Eric Blake |
Subject: |
Re: Parsing error when "case" in "for" in $() |
Date: |
Tue, 11 Sep 2012 16:27:53 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 |
On 09/11/2012 08:50 AM, Benoit Vaugon wrote:
> Bash Version: 4.1
> Patch Level: 7
> Repeat-By:
> echo $(for x in whatever; do case y in *) echo 42;; esac; done)
The syntax error is still present in bash 4.2 patchlevel 37:
$ echo $(for x in whatever; do case y in *) echo 42;; esac; done)
bash: syntax error near unexpected token `;;'
$ bash --version | head -n1
GNU bash, version 4.2.37(1)-release (x86_64-redhat-linux-gnu)
and also present in very recent ksh and zsh:
# ksh -c 'echo $(for x in whatever; do case y in *) echo 42;; esac; done) '
ksh: syntax error at line 1: `;;' unexpected
but not in mksh or dash:
# dash -c 'echo $(for x in whatever; do case y in *) echo 42;; esac; done) '
42
Looks like you found a real bug, but a tough one to fix if even ksh gets
it wrong.
--
Eric Blake eblake@redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature