ksh: case statement in command substitution raises a syntax error

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ksh: case statement in command substitution raises a syntax error

Masanori Ogino
>Synopsis: ksh: case statement in command substitution raises a syntax error
>Category: system
>Environment:
        System      : OpenBSD 6.4
        Details     : OpenBSD 6.4 (GENERIC.MP) #364: Thu Oct 11 13:30:23 MDT 2018
                         [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP

        Architecture: OpenBSD.amd64
        Machine     : amd64
>Description:

All of four commands below shall output "OK":

1. (case 1 in (1) echo OK;; esac)
2. (case 1 in 1) echo OK;; esac)
3. echo $(case 1 in (1) echo OK;; esac)
4. echo $(case 1 in 1) echo OK;; esac)

With OpenBSD ksh(1), however, all but 4. behave as expected.

$ (case 1 in (1) echo OK;; esac)
OK
$ (case 1 in 1) echo OK;; esac)
OK
$ echo $(case 1 in (1) echo OK;; esac)
OK
$ echo $(case 1 in 1) echo OK;; esac)
ksh: syntax error: `;;' unexpected

It seems a bug in eval.c but I could not find where it exactly is.

The problem initially targeted bash and zsh, and was described
in the following (Japanese) article:

https://qiita.com/richmikan@github/items/8eebbacc73f80c18a728

Reply | Threaded
Open this post in threaded view
|

Re: ksh: case statement in command substitution raises a syntax error

Anton Lindqvist-2
On Wed, Nov 21, 2018 at 01:29:24PM +0900, Masanori Ogino wrote:

> >Synopsis: ksh: case statement in command substitution raises a syntax error
> >Category: system
> >Environment:
> System      : OpenBSD 6.4
> Details     : OpenBSD 6.4 (GENERIC.MP) #364: Thu Oct 11 13:30:23 MDT 2018
> [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
>
> Architecture: OpenBSD.amd64
> Machine     : amd64
> >Description:
>
> All of four commands below shall output "OK":
>
> 1. (case 1 in (1) echo OK;; esac)
> 2. (case 1 in 1) echo OK;; esac)
> 3. echo $(case 1 in (1) echo OK;; esac)
> 4. echo $(case 1 in 1) echo OK;; esac)
>
> With OpenBSD ksh(1), however, all but 4. behave as expected.
>
> $ (case 1 in (1) echo OK;; esac)
> OK
> $ (case 1 in 1) echo OK;; esac)
> OK
> $ echo $(case 1 in (1) echo OK;; esac)
> OK
> $ echo $(case 1 in 1) echo OK;; esac)
> ksh: syntax error: `;;' unexpected
>
> It seems a bug in eval.c but I could not find where it exactly is.
>
> The problem initially targeted bash and zsh, and was described
> in the following (Japanese) article:
>
> https://qiita.com/richmikan@github/items/8eebbacc73f80c18a728

This is a known limitation: http://man.openbsd.org/ksh#BUGS

Reply | Threaded
Open this post in threaded view
|

Re: ksh: case statement in command substitution raises a syntax error

Masanori Ogino-2
2018年11月21日(水) 15:46 Anton Lindqvist <[hidden email]>:

> On Wed, Nov 21, 2018 at 01:29:24PM +0900, Masanori Ogino wrote:
> > >Synopsis:    ksh: case statement in command substitution raises a
> syntax error
> > >Category:    system
> > >Environment:
> >       System      : OpenBSD 6.4
> >       Details     : OpenBSD 6.4 (GENERIC.MP) #364: Thu Oct 11 13:30:23
> MDT 2018
> >                        [hidden email]:
> /usr/src/sys/arch/amd64/compile/GENERIC.MP
> >
> >       Architecture: OpenBSD.amd64
> >       Machine     : amd64
> > >Description:
> >
> > All of four commands below shall output "OK":
> >
> > 1. (case 1 in (1) echo OK;; esac)
> > 2. (case 1 in 1) echo OK;; esac)
> > 3. echo $(case 1 in (1) echo OK;; esac)
> > 4. echo $(case 1 in 1) echo OK;; esac)
> >
> > With OpenBSD ksh(1), however, all but 4. behave as expected.
> >
> > $ (case 1 in (1) echo OK;; esac)
> > OK
> > $ (case 1 in 1) echo OK;; esac)
> > OK
> > $ echo $(case 1 in (1) echo OK;; esac)
> > OK
> > $ echo $(case 1 in 1) echo OK;; esac)
> > ksh: syntax error: `;;' unexpected
> >
> > It seems a bug in eval.c but I could not find where it exactly is.
> >
> > The problem initially targeted bash and zsh, and was described
> > in the following (Japanese) article:
> >
> > https://qiita.com/richmikan@github/items/8eebbacc73f80c18a728
>
> This is a known limitation: http://man.openbsd.org/ksh#BUGS
>

Ah, I did not check the man page. I am sorry for bothering you.
--
Masanori Ogino