3 ms·
Tip: You can use { } instead of do/done to emulate C syntax. Aside: [[ -v x ]] tests if the variable x is set. It should probably be [[ x -ne 0 ]] to match the
by hddqsb 4y ago
Tip: You can use { } instead of do/done to emulate C syntax.
Aside: [[ -v x ]] tests if the variable x is set. It should probably be [[ x -ne 0 ]] to match the example from the parent.
- cassepipe 4y ago"You can use { } instead of do/done" In sh ? In bash ? In zsh ? I am very glad if it is so in any of them
- hddqsb 4y agoIt works in bash/zsh/ksh but not in sh/dash. Examples: for i in 1 2 3 4 5; { echo $i; } for ((i=1;i<=5;i++)) { echo $i; } (It doesn't work with `while` loops, at least not in bash.)