[Top][All Lists]

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

Re: select syntax violates the POLA

From: Chet Ramey
Subject: Re: select syntax violates the POLA
Date: Mon, 5 Apr 2021 17:21:54 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.0

On 4/1/21 5:54 PM, Greywolf wrote:

On 4/1/2021 8:57, Chet Ramey wrote:

It's more like `select' doesn't inherit some of the shell's special cases.

        select dir in ${d[@]}; do {
        } done;

    ...but select breaks on the "} done;" syntax

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. Some of the other compound commands have special
cases, mostly inherited from the Bourne shell, to allow it.

I took a look at bash-1.14, where the `select' command first appeared. At
the time, it was identical to the `for' command -- which makes sense, since
the syntaxes are essentially identical (and internally, they are
represented the same way). They both used the `list' grammar production.

When I updated the grammar to use the `compound_list' production in
bash-2.0, to be closer to how POSIX specified the compound commands in the
POSIX grammar, I left the select command alone. It's been the same way
since late 1994, though bash-2.0 wasn't released until 1996.

I took this opportunity to examine the grammar again, and there's no good
reason `select' and `for' should be different -- they started out the same,
and they should both use compound_list now. So they will.

This presented an opportunity to marginally simplify the grammar, so it's a
win all around.

The change will be in the next devel branch push.


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

reply via email to

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