[Top][All Lists]

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

Re: select syntax violates the POLA

From: Greywolf
Subject: Re: select syntax violates the POLA
Date: Thu, 1 Apr 2021 14:54:55 -0700
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0

Hi, Chet!  I've read a lot of your posts long ago, as well!

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.

Firstly, thank you for your concise reply.

I discovered that making it '}; done;' as you suggested here worked,
shortly after my broken astonishment :).

kre mentioned that it's a ksh holdover.  This explains a great many
things considering how horribly broken I have found ksh to be (and the
weak arguments supporting that brokenness; among them, the need to
say 'fg %4' instead of merely being able to say '%4'; the requirement
to have ${var[ix]} instead of honouring $var[ix] with regard to arrays
is another one).

Lastly, thanks for not bagging on my coding style.  It was somewhat
intentional, somewhat accidental when I started using it 25 years back.
Being able to paren-match my for-in-do-done, while/until-do-done,
if-elif-else-fi has been a timesaver.  It not only helps me spot missing
closures, it helps me spot missing quotes.

[I think the only thing I wish would be enhanced and accepted further
was for it to work with case-esac, but that hasn't changed in 25 years,
either, and it's minor, so I'm not holding my breath. :) ]



reply via email to

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