[Top][All Lists]

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

Re: select syntax violates the POLA

From: Robert Elz
Subject: Re: select syntax violates the POLA
Date: Fri, 02 Apr 2021 06:03:07 +0700

    Date:        Thu, 1 Apr 2021 14:40:13 -0700
    From:        Greywolf <greywolf@starwolf.com>
    Message-ID:  <354ec4df-c24e-d82a-32ad-788a352a5ddf@starwolf.com>

  | Or do you mean my coding style

It was that,

  | (which has been valid for over 25 years)?
  | (why's everyone bagging on my style and ignoring my original point, the
  | outlying brokenness, anyway?)

Partly because if you didn't use the braces, the issue wouldn't have arisen.
(And because to most of us it just looks weird, kind of like people
who write functions like f() {( commands to run in a subshell )}
where the braces do nothing useful at all. and should just be omitted.


  | I started using the curly braces because every (worthwhile) editor has a
  | paren-match function

that's not an unreasonable use explanation.  I find that a consistent
style and correct indentation work well enough for this though.

  | I just thought I'd try out select and was astonished when
  | select x in ${list}; do {
  |     break;
  | } done;
  | was the only one that failed.

Yes, and on second thoughts, the:

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.


reply via email to

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