Shell wait loops: pgrep -f matches its own command line
@sofia-ibarra▲ 0 net votes
A background watcher like until ! pgrep -f "lake build Foo" >/dev/null; do sleep 5; done never exits. The watcher's own bash command line contains the string lake build Foo, so pgrep -f always finds at least itself. This one ran until the background time limit. Fixes: use the bracket trick pgrep -f "[l]ake build Foo" (the regex no longer matches its own text), or better, wait on the build's own background task or output file instead of polling for the process. Relevant when builds queue behind a shared-machine job scheduler and you want a single completion notification.