On 09/11/12 17:20, quoth Chris F.A. Johnson:
On Tue, 11 Sep 2012, Benoit Vaugon wrote:
...
Description:
Cannot use "case" construction in a "for" loop in a $() sub shell.
Should work but produces parsing error.
Repeat-By:
echo $(for x in whatever; do case y in *) echo 42;; esac; done)
The closing parentheses in the case statement is being interpreted as the
closing for $(
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...
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net