On Fri, Apr 2, 2021 at 2:04 AM Robert Elz <k...@munnari.oz.au> wrote:

> chet.ra...@case.edu said:
>   | Yes, you need a list terminator so that `done' is recognized as a
> reserved
>   | word here. `;' is sufficient. Select doesn't allow the `done' unless
> it's
>   | in a command position.
>
> isn't really all that appealing as an explanation.   select isn't part
> of the standard, so its syntax is arbitrary, which means that nothing can
> really be considered wrong, but while we often think of reserved words
> (not counting the special cases in case and for statements) as only working
> in the command word position, that's not how it really is.  They work
> there,
> they also should work following other reserved words (most of them, but
> '}' is not one of the exceptions).   so '} done' should work correctly,
> always, if the '}' is a reserved word, and a ';' or newline between them
> should not be needed.
>

FWIW, it works in the other shells I know that support select:

 $ cat select.sh
select x in foo bar; do {
    echo $x;
    break;
} done;

$ for sh in bash ksh mksh zsh; do echo "== $sh"; $sh select.sh <<< 1; done
== bash
select.sh: line 5: syntax error near unexpected token ‘done’
select.sh: line 5: `} done;'
== ksh
1) foo
2) bar
foo
== mksh
1) foo
2) bar
#? foo
== zsh
1) foo  2) bar
?# foo

Reply via email to