From 831cfbcc58c7fc25a89b669a6c7fdad5a5e02e06 Mon Sep 17 00:00:00 2001 From: natemaia Date: Sun, 25 Aug 2019 11:58:59 -0700 Subject: [PATCH] Tweak background process output handling --- archlabs-installer | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/archlabs-installer b/archlabs-installer index 9e4b01e..9e1e801 100755 --- a/archlabs-installer +++ b/archlabs-installer @@ -1376,17 +1376,19 @@ install_base() { if [[ $RSYNC_PID || $MIRROR_PID ]]; then local oldmsg="" msg="" - printf "\nOne or more background install processes are still running, grabbing their output...\n" - while kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; do - msg="$(tail -n 1 /tmp/bg_out)" - if [[ "$msg" != "$oldmsg" ]]; then - printf "\n%s" "$msg" - oldmsg="$msg" - else - printf "." - sleep 0.5 - fi - done + if kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; then + printf "\nOne or more background install processes are still running, grabbing their output...\n" + while kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; do + msg="$(tail -n 1 /tmp/bg_out)" + if [[ "$msg" != "$oldmsg" ]]; then + printf "\n%s" "$msg" + oldmsg="$msg" + else + printf "." + sleep 0.5 + fi + done + fi trap - EXIT unset RSYNC_PID MIRROR_PID else