mirror of
https://github.com/smxi/inxi.git
synced 2025-01-31 10:02:18 +00:00
added error condition to number calculator
This commit is contained in:
parent
4ebea16e5f
commit
37a0e55b57
9
inxi
9
inxi
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 0.3.13
|
#### version: 0.3.14
|
||||||
#### Date: November 3 2008
|
#### Date: November 3 2008
|
||||||
########################################################################
|
########################################################################
|
||||||
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
||||||
|
@ -1287,7 +1287,12 @@ calculate_multicore_data()
|
||||||
string_data=" $( awk '{print $2}' <<< $1 )" # add a space for output
|
string_data=" $( awk '{print $2}' <<< $1 )" # add a space for output
|
||||||
string_number=$( awk '{print $1}' <<< $1 )
|
string_number=$( awk '{print $1}' <<< $1 )
|
||||||
fi
|
fi
|
||||||
string_number=$( echo $string_number $2 | awk '{total = $1*$2; print total}' )
|
# handle weird error cases where it's not a number
|
||||||
|
if [ -n "$( egrep '^[0-9\.,]+$' <<< $string_number )" ];then
|
||||||
|
string_number=$( echo $string_number $2 | awk '{total = $1*$2; print total}' )
|
||||||
|
else
|
||||||
|
string_number="Error: string_number=$string_number "
|
||||||
|
fi
|
||||||
echo "$string_number$string_data"
|
echo "$string_number$string_data"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue