From 0b46c91c9f000dd35bc58ba1edf9016e06dda6ed Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 6 Dec 2012 12:46:20 -0500 Subject: [PATCH] emerge-status.sh: cleanup Bash command substitution and testing --- posts/conky/emerge-status.sh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/posts/conky/emerge-status.sh b/posts/conky/emerge-status.sh index a1241ef..b951e2f 100755 --- a/posts/conky/emerge-status.sh +++ b/posts/conky/emerge-status.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# emerge-status.sh by Hellf[i]re +# emerge-status.sh (originally by Hellf[i]re) # # This script will report the current status of portage. # @@ -20,20 +20,19 @@ # would be far too much parsing required to find out the current status of # every command which is run in parallel. -STATUS=`tail -n 15 /var/log/emerge.log |\ -grep -iE "Compiling|Cleaning|AUTOCLEAN|completed|search|terminating|rsync" |\ -cut -d ' ' -f "2-" |\ -grep -Ev 'Finished\.|Cleaning up\.\.\.' |\ -tail -n 1` +STATUS=$( + tail -n 15 /var/log/emerge.log | + grep -iE "Compiling|Cleaning|AUTOCLEAN|completed|search|terminating|rsync" | + cut -d ' ' -f "2-" | + grep -Ev 'Finished\.|Cleaning up\.\.\.' | + tail -n 1) -#echo "$STATUS" - -if [ "`echo "$STATUS" | grep -i compiling`" != "" ]; then echo Compiling -elif [ "`echo "$STATUS" | grep -i cleaning`" != "" ]; then echo Cleaning -elif [ "`echo "$STATUS" | grep -i autoclean`" != "" ]; then echo Autoclean -elif [ "`echo "$STATUS" | grep -i sync`" != "" ]; then echo Syncing -elif [ "`echo "$STATUS" | grep -i search`" != "" ]; then echo Searching -elif [ "`echo "$STATUS" | grep -i completed`" != "" ]; then echo Completed -elif [ "`echo "$STATUS" | grep -i terminating`" != "" ]; then echo Completed +if [ -n "$(echo "$STATUS" | grep -i compiling)" ]; then echo Compiling +elif [ -n "$(echo "$STATUS" | grep -i cleaning)" ]; then echo Cleaning +elif [ -n "$(echo "$STATUS" | grep -i autoclean)" ]; then echo Autoclean +elif [ -n "$(echo "$STATUS" | grep -i sync)" ]; then echo Syncing +elif [ -n "$(echo "$STATUS" | grep -i search)" ]; then echo Searching +elif [ -n "$(echo "$STATUS" | grep -i completed)" ]; then echo Completed +elif [ -n "$(echo "$STATUS" | grep -i terminating)" ]; then echo Completed else echo Script Error! fi -- 2.26.2