zlacker

[parent] [thread] 1 comments
1. wpm+(OP)[view] [source] 2026-01-07 21:25:52
The semicolon is required only when not using new lines to split the command words, as in

sleep 60; do_the_thing_that_needs_a_minute_wait

It's not necessarily required in the for loop either, I tend to prefer the more compact method of putting the "do" on the same line as the for. It can be written as

for i in {1..10}

do

    print $1
done

Having "done" be the signifier of the "the for loop context ends here" is 3 characters more than "}" or ")" or whatever else. "done" is more color coming off the screen with syntax-highlighting, and can be typed in two keypresses with a "d" and a "tab" in any editor from the last 30 years. It just seems like a very very inconsequential nitpick. At least Nushell doesn't pull a Python and just have "invisible space" be the end of the for-loop.

One line conditionals are doable as well in the shell.

test -f junk && junk

or

[[ -f junk ]] && junk

You can even just use [ -f junk ] if double brackets is giving the yuck.

replies(1): >>kalter+kx
2. kalter+kx[view] [source] 2026-01-08 00:07:43
>>wpm+(OP)
In practice, the only noticeable difference I have witnessed is

    for (f in *.c) if (test -f $f) cc $f
I can write the whole thing in a single line (which is essential in GUI and interactive contexts) and it reads well.
[go to top]