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)
--
Chris F.A. Johnson, <http://cfajohnson.com/>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)