From: W. Trevor King Date: Thu, 6 Dec 2012 17:46:20 +0000 (-0500) Subject: emerge-status.sh: cleanup Bash command substitution and testing X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0b46c91c9f000dd35bc58ba1edf9016e06dda6ed;p=mw2txt.git emerge-status.sh: cleanup Bash command substitution and testing --- 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