On 09/11/2012 03:31 PM, Steven W. Orr wrote: >>> Fix: >>> Probably by fixing the bash parser. >> >> Balance the parentheses in the case statement: >> >> echo $(for x in whatever; do case y in (*) echo 42;; esac; done) >> > > Thanks. I didn't know that the opening paren was optional and was needed > in such a case as a disambiguator. Very nice. And if you really want to > match something that starts with an open paren, just backslash it. > > As a style issue, it makes me wonder if I should always use the optional > open paren as syntactic sugar...
POSIX has always required an optional open paren to case patterns, thanks to ksh; but it hasn't been portable to all shells until recently (among others, Solaris /bin/sh will fail if you try it, but then again, that's not a POSIX shell). -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature