From aa746b32219feaa4ecfb25bcc94d3b32f7e0cc60 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Fri, 8 Jan 2010 00:51:34 +0000 Subject: [PATCH] (change version) found and fixed bug in awk, the test ! i in array is not supported, you have to use only: i in array annoying, but that's life. --- inxi | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/inxi b/inxi index b33c049..51e7d8d 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 1.2.9 +#### version: 1.2.10 #### Date: January 7 2010 ######################################################################## #### SPECIAL THANKS @@ -3207,13 +3207,13 @@ $repo_data_working" get_sensors_data() { eval $LOGFS - + IFS=$'\n' if [[ $B_SENSORS == 'true' ]];then # note: non-configured sensors gives error message, which we need to redirect to stdout # also, -F ':' no space, since some cases have the data starting right after,like - :1287 A_SENSORS_DATA=( $( - sensors | gawk -F ':' -v userCpuNo="$SENSORS_CPU_NO" ' + sensors | gawk -F ':' -v userCpuNo="$SENSORS_CPU_NO" ' BEGIN { IGNORECASE=1 core0Temp="" # only if all else fails... @@ -3315,20 +3315,26 @@ get_sensors_data() # note that the counters are dynamically set for fan numbers here # otherwise you could overwrite eg aux fan2 with case fan2 in theory # note: cpu/mobo/ps are 1/2/3 + # NOTE: test: ! i in array does NOT work, this appears to be an awk/gawk bug /^(AUX(1)? |CASE(1)? |CHASSIS(1)? )(.*)[ \t]*([0-9]+)[ \t]RPM/ { for ( i = 4; i < 7; i++ ){ - if ( ! i in aFanMain ){ - sysFanNu = i - aFanMain[sysFanNu]=gensub( /[ \t]*([0-9]+)[ \t]+(.*)/, "\\1", 1, $2 ) + if ( i in aFanMain ){ + ## + } + else { + aFanMain[i]=gensub( /[ \t]*([0-9]+)[ \t]+(.*)/, "\\1", 1, $2 ) break } } } /^(AUX([2-9]) |CASE([2-9]) |CHASSIS([2-9]) )(.*)[ \t]*([0-9]+)[ \t]RPM/ { for ( i = 5; i < 30; i++ ){ - if ( ! i in aFanMain ){ + if ( i in aFanMain ) { + ## + } + else { sysFanNu = i - aFanMain[sysFanNu]=gensub( /[ \t]*([0-9]+)[ \t]+(.*)/, "\\1", 1, $2 ) + aFanMain[i]=gensub( /[ \t]*([0-9]+)[ \t]+(.*)/, "\\1", 1, $2 ) break } } @@ -3342,7 +3348,12 @@ get_sensors_data() sysFanNu=gensub( /fan([0-9]+)/, "\\1", 1, $1 ) if ( sysFanNu ~ /^([0-9]+)$/ ) { # add to array if array index does not exist OR if number is > existing number - if ( ! sysFanNu in aFanDefault || fanWorking >= aFanDefault[sysFanNu] ) { + if ( sysFanNu in aFanDefault ) { + if ( fanWorking >= aFanDefault[sysFanNu] ) { + aFanDefault[sysFanNu]=fanWorking + } + } + else { aFanDefault[sysFanNu]=fanWorking } } @@ -3431,7 +3442,7 @@ get_sensors_data() } # then we need to get the actual numeric max array count for both fan arrays - for (i = 0; i <= 14; i++) { + for (i = 0; i <= 29; i++) { if ( i in aFanMain && i > indexCountaFanMain ) { indexCountaFanMain=i }