#!/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.
#
# 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