Hi Vadim,

On Mon, May 29, 2017 at 05:09:11AM +0300, Vadim Zhukov wrote:
> 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?

Just for reference, looks like this is caused by a bug mentioned in the
ksh(1) manual[1]:

> $(command) expressions are currently parsed by finding the closest
> matching (unquoted) parenthesis. Thus constructs inside $(command) may
> produce an error. For example, the parenthesis in ‘x);;’ is interpreted
> as the closing parenthesis in ‘$(case x in x);; *);; esac)’.

[1] http://man.openbsd.org/ksh#BUGS

Reply via email to