Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: why not promote the plague ? (brace|rc|alternative|modern) syntax






On 2024-12-13 03:55, Bart Schaefer wrote:
On Thu, Dec 12, 2024 at 7:20 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
What matters is robust code.  I've been convinced that:

for (( ...))
{
...
}

... is stable, but for everything else stick with do/done  or then/fi.
Keep in mind that the setopt for those sans-do/done shapes is
SHORT_loops.  In C-think, that means something like "cuddled" braces
-- minimal vertical whitespace.  But the other thing to remember is
that a newline in shell is like a semicolon in C, and throwing in
extra statement terminators is likely to get you in trouble.
There's another new thought.  That never occurred to me.  I know of course that a newline can obviate a semicolon, but that the above parses the same as:

for (( ...)); {; ...; }; ...

... is ... I dunno what it is, but it's new, anyway.  But forewarned is forearmed, so next time I run into some weirdness I'll have an extra suspect to investigate ... or, nuts, just stick with do/done and sleep soundly.








Messages sorted by: Reverse Date, Date, Thread, Author