bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: select syntax violates the POLA


From: Ilkka Virta
Subject: Re: select syntax violates the POLA
Date: Sat, 3 Apr 2021 00:28:45 +0300

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

> chet.ramey@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

[Prev in Thread] Current Thread [Next in Thread]