top | item 44592731 (no title) marklgr | 7 months ago Could you elaborate? discuss order hn newest apopapo|7 months ago A for loop in a shell script may sometimes look like this:`for ((i = 0 ; i < max ; i++ )); do echo "$i"; done`Here this is essentially a "while" loop, meaning it will keep executing the commands as long as we don't reach `exit 1`.(; flock -n 9 || exit 1; # ... commands executed under lock ...; ) yjftsjthsd-h|7 months ago It doesn't seem to work? [~] 0 $ ( flock -n 9 || exit 1; echo in loop ; sleep 3 ; echo done working ; ) 9>~/tmp/mylock in loop done working [~] 0 $ (; flock -n 9 || exit 1; echo in loop ; sleep 3 ; echo done working ; ) 9>~/tmp/mylock -bash: syntax error near unexpected token `;' [~] 2 $ (This is bash)
apopapo|7 months ago A for loop in a shell script may sometimes look like this:`for ((i = 0 ; i < max ; i++ )); do echo "$i"; done`Here this is essentially a "while" loop, meaning it will keep executing the commands as long as we don't reach `exit 1`.(; flock -n 9 || exit 1; # ... commands executed under lock ...; ) yjftsjthsd-h|7 months ago It doesn't seem to work? [~] 0 $ ( flock -n 9 || exit 1; echo in loop ; sleep 3 ; echo done working ; ) 9>~/tmp/mylock in loop done working [~] 0 $ (; flock -n 9 || exit 1; echo in loop ; sleep 3 ; echo done working ; ) 9>~/tmp/mylock -bash: syntax error near unexpected token `;' [~] 2 $ (This is bash)
yjftsjthsd-h|7 months ago It doesn't seem to work? [~] 0 $ ( flock -n 9 || exit 1; echo in loop ; sleep 3 ; echo done working ; ) 9>~/tmp/mylock in loop done working [~] 0 $ (; flock -n 9 || exit 1; echo in loop ; sleep 3 ; echo done working ; ) 9>~/tmp/mylock -bash: syntax error near unexpected token `;' [~] 2 $ (This is bash)
apopapo|7 months ago
`for ((i = 0 ; i < max ; i++ )); do echo "$i"; done`
Here this is essentially a "while" loop, meaning it will keep executing the commands as long as we don't reach `exit 1`.
(; flock -n 9 || exit 1; # ... commands executed under lock ...; )
yjftsjthsd-h|7 months ago