Machine Type: x86_64-redhat-linux-gnu
Bash Version: 4.3
Patch Level: 39
Release Status: release
Description:
If $() includes a case statement nested within it, the parser is not
matching ) as closing the case,
but rather the $(. This behavior is different between bash and other
shells. ksh/busybox
both process this without error, but I do not know which is officially
"correct".
Test Case:
---------------
testing=$(
echo test | while read line; do
case $line in
test) echo saw test ;;
*) echo other ;;
esac
done
)
echo result: $testing
--------------
Expected output:
result: saw test
Actual output:
parse-bug.sh: line 6: syntax error near unexpected token `;;'
parse-bug.sh: line 6: ` test) echo saw test ;;'
Workaround: Use (test) instead of test) in the nested code
Repeat-By:
Run script with that syntax.
--
------------------------------------------------------------
Nathan Neulinger nneul@neulinger.org
Neulinger Consulting (573) 612-1412