'eval' added to interpret all options like forward errors to null correctly

This commit is contained in:
Ulf 2023-12-31 15:15:08 +01:00
parent 0571130cbd
commit f2e4db87a8

9
dfc.sh
View file

@ -2,8 +2,7 @@
# df (= DiskFree) with some options and colored if Alert levels are exceeded
#
# (c) GPL by Ulf Bartolomäus
VERSION="$( basename $0 ) Version 0.1.3 from 31.12.2023"
#
VERSION="$( basename $0 ) Version 0.1.4 from 31.12.2023"
# Input: -v : Version
# -y YY : YY = alert level (yellow) in % (default = 80%)
# -r RR : RR = critical alert level (red) in % (default = 90%)
@ -11,8 +10,10 @@ VERSION="$( basename $0 ) Version 0.1.3 from 31.12.2023"
# Returnvalue: 0
#
# Changes:
# 0.1.4
# 'eval' added before the command execution
# 0.1.3
# Add '2> /dev/null' at df to remove error messages
# df -> added "2> /dev/null" to remove error messages
# 0.1.2
# Some format improfements and adding from options
# 0.1.1
@ -90,7 +91,7 @@ done
#MyDfC="${MyDfC} $*"
## DiskFree (only if not the same device => unique check first 40 characters)
${MyDfC} | uniq -w40 | while read MyOutput; do ## Execute df and filter doublicates - for each row stored in MyOutput
eval ${MyDfC} | uniq -w40 | while read MyOutput; do ## Execute df and filter doublicates - for each row stored in MyOutput
MyDfUsage=$(echo ${MyOutput} | awk '{ print $6}' | cut -d'%' -f1 ) ## Search Usage in %
if [[ ! $( echo "${MyDfUsage}" | grep [[:digit:]] ) ]] ; then ## If first row
echo -e ${dick}"${MyOutput}"${norm} ## Echo in bold