commit 9d8e832ae98ad142e10ee43a258b7215893126d1
parent bb0fb92595dca9bba7ce4e982d9d1975ae18a56c
Author: St John Karp <contact@stjo.hn>
Date: Thu, 14 Oct 2021 05:10:46 -0400
Fix `ps` command to detect running processes
Fixed a `ps` command that was not portable between different
implementations. By only printing the process command itself and
not any arguments, we make the output more reliable across systems.
Diffstat:
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/squeeze.sh b/squeeze.sh
@@ -105,7 +105,7 @@ wait
# The `wait` command doesn't seem to wait for all the running jobs.
# Maybe it's stopping after all `swipl` processes complete?
# This hack just checks to see if any sed or smartypants processes are running.
-while [ $(ps -A | grep -c -e " sed$" -e " smartypants$") -gt 0 ]; do
+while [ "$(ps -o comm | grep -c -e '^sed$' -e '^smartypants$')" -gt 0 ]; do
sleep 1
done
diff --git a/unsqueeze.sh b/unsqueeze.sh
@@ -45,6 +45,6 @@ wait
# The `wait` command doesn't seem to wait for all the running jobs.
# Maybe it's stopping after all `swipl` processes complete?
# This hack just checks to see if any sed processes are running.
-while [ $(ps -A | grep -c " sed$") -gt 0 ]; do
+while [ "$(ps -o comm | grep -c '^sed$')" -gt 0 ]; do
sleep 1
done