It looks like I've just found a bug in (our) ksh. Not to be brave
enough to fix it right now, but I think it's still worths adding
regression test.
Bash and zsh pass this test without problem.
The idea is using the case...in...esac inside $(...) or `...`.
It starts failing when you add a single case match, i.e.:
a=foo
data=$(
case $a in
esac
)
echo $data
doesn't fail, while
a=foo
data=$(
case $a in
*) echo OK;;
esac
)
echo $data
fails with error:
$ ksh tt.sh
./tt.sh[4]: syntax error: `;;' unexpected
What's worse, it fails even if I comment the line it's whining after.
So... okay to add a regression test?
--
WBR,
Vadim Zhukov
Index: caseincmdsubst.t
===================================================================
RCS file: caseincmdsubst.t
diff -N caseincmdsubst.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ caseincmdsubst.t 29 May 2017 02:03:02 -0000
@@ -0,0 +1,26 @@
+name: case-inside-cmd-subst-parentheses
+description:
+ See if case...in...esac works inside parentesed command substitution
+stdin:
+ a=foo
+ data=$(
+ case $a in
+ *) echo OK;;
+ esac
+ )
+expected-stdout:
+ OK
+---
+name: case-inside-cmd-subst-backticks
+description:
+ See if case...in...esac works inside backticks command substitution
+stdin:
+ a=foo
+ data=`
+ case $a in
+ *) echo OK;;
+ esac
+ `
+expected-stdout:
+ OK
+---