From ecde3e165eb2b0472b9d851db49c68448b7f2f9f Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Fri, 9 Jan 2009 03:11:06 +0000 Subject: [PATCH] added testing 2 condition as well --- inxi | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/inxi b/inxi index b8810ab..7179d7a 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 0.9.4-b1-t1 +#### version: 0.9.4-b1-t2 #### Date: January 8, 2009 ######################################################################## #### SPECIAL THANKS @@ -1903,7 +1903,7 @@ get_hdd_data_basic() percent = used/full print "percent : " percent }' ) - else + if [[ $B_TESTING_2 == 'true' ]];then hdd_used=$( df | gawk ' p { if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) { @@ -1925,6 +1925,31 @@ get_hdd_data_basic() END { print c }' ) + else + hdd_used=$( df | gawk ' + /^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/ { + # this handles the case where the first item is too long + # and makes df wrap output to next line, so here we advance + # it to the next line for that single case + if ( NF == 1 ) { + getline + } + # if the first item caused a wrap, use one less than standard + if ( $4 ~ /.*\%/ ) { + used += $2 + } + # otherwise use standard + else if ( $5 ~ /.*\%/ ) { + used += $3 + } + # and if this is not detected, give up, we need user data to debug + else { + next + } + } + END { + print used + }' ) fi if [[ -z $hdd_used ]];then