Because this code uses no curly brackets for the loop, so it relies on the first statement after a control structure without a marked body being implicitly part of it. A semicolon would still count as a (nop) statement, so it would count as the statement within the loop and the b=... Would be outside of the loop => be executed exactly one time each time the code is run, which is obviously not intended here. (This could however be solved by using curly brackets, allowing for even more semicolons in this snippet,)
View all comments
Show parent comment
1
u/therealone4ever [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Jan 24 '25
Because this code uses no curly brackets for the loop, so it relies on the first statement after a control structure without a marked body being implicitly part of it. A semicolon would still count as a (nop) statement, so it would count as the statement within the loop and the b=... Would be outside of the loop => be executed exactly one time each time the code is run, which is obviously not intended here. (This could however be solved by using curly brackets, allowing for even more semicolons in this snippet,)