Re:Show HN: `loop`, Unix's missing loop commmand
by Mizza on Wednesday June 27, 2018 @09:33AM
(#17407949)
I have always found writing loops in Bash to be fickle, tedious, and needlessly complicated.
`loop` allows you to write intuitive, powerful looping one liners, with many useful features like breaking on pattern matching, timed loops, and loops for a specific duration.
For instance, to try a thing until it succeeds, every 15 seconds, for a maximum of five times in Bash:
n=0
until [ $n -ge 5 ]
do
do_thing.sh && break
n=$[$n+1]
sleep 15
done
`loop` allows you to write intuitive, powerful looping one liners, with many useful features like breaking on pattern matching, timed loops, and loops for a specific duration.
For instance, to try a thing until it succeeds, every 15 seconds, for a maximum of five times in Bash:
becomes: This was also my first Rust project, so feedback is welcome!