From 37a0e55b579595a1c19620eb0ebedb283020db63 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Tue, 4 Nov 2008 03:13:01 +0000 Subject: [PATCH] added error condition to number calculator --- inxi | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/inxi b/inxi index 052ce9c..abd9a5d 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 0.3.13 +#### version: 0.3.14 #### Date: November 3 2008 ######################################################################## #### 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_number=$( awk '{print $1}' <<< $1 ) 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" }