(change version)

fixed very obscure gensub/gawk bug that makes integers into strings if 501-1000 when number is generated by gensub. This bug makes the 
number typed as string, which makes > tests always true.

Also fixed output bug where there is nothing in main fan data, but there is something in default fan data array.
This commit is contained in:
inxi-svn 2009-08-05 00:56:27 +00:00
parent 2201b388c9
commit 242dc4e829

12
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 1.1.10 #### version: 1.1.11
#### Date: August 4 2009 #### Date: August 4 2009
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
@ -3123,7 +3123,7 @@ get_sensors_data()
# more validation because gensub if fails to get match returns full string, so # more validation because gensub if fails to get match returns full string, so
# we have to be sure we are working with the actual real string before assiging # we have to be sure we are working with the actual real string before assiging
# data to real variables and arrays. Extracting C/F degree unit as well to use # data to real variables and arrays. Extracting C/F degree unit as well to use
# when constructing temp items for array. # when constructing temp items for array.
# note that because of charset issues, no tempUnit="°" tempWorkingUnit degree sign # note that because of charset issues, no tempUnit="°" tempWorkingUnit degree sign
# used, but it is required in testing regex to avoid error. # used, but it is required in testing regex to avoid error.
/^(M\/B|MB|SYS)(.*)\+([0-9]+)(.*)[ \t°](C|F)/ && $2 ~ /^[ \t]*\+([0-9]+)/ { /^(M\/B|MB|SYS)(.*)\+([0-9]+)(.*)[ \t°](C|F)/ && $2 ~ /^[ \t]*\+([0-9]+)/ {
@ -3323,9 +3323,11 @@ get_sensors_data()
# which has to be a gawk bug, unless there is something really weird with arrays # which has to be a gawk bug, unless there is something really weird with arrays
# note: 500 > aFanDefault[j] < 1000 is the exact trigger, and if you manually # note: 500 > aFanDefault[j] < 1000 is the exact trigger, and if you manually
# assign that value below, the > 5000 test works again, and a print of the value # assign that value below, the > 5000 test works again, and a print of the value
# shows the proper value, so the corruption might be internal in awk. # shows the proper value, so the corruption might be internal in awk.
# Note: gensub is the culprit I think, assigning type string for range 501-1000 but
# type integer for all others, this triggers true for >
for (j = 1; j <= indexCountaFanDefault; j++) { for (j = 1; j <= indexCountaFanDefault; j++) {
if ( j in aFanDefault && aFanDefault[j] > 5000 && aFanMain[2] == "" ) { if ( j in aFanDefault && int( aFanDefault[j] ) > 5000 && aFanMain[2] == "" ) {
aFanMain[2] = aFanDefault[j] aFanMain[2] = aFanDefault[j]
aFanDefault[j] = "" aFanDefault[j] = ""
# then add one if required for output # then add one if required for output
@ -3364,7 +3366,7 @@ get_sensors_data()
# then build array arrays: # then build array arrays:
print cpuTempReal "," moboTempReal "," psuTemp print cpuTempReal "," moboTempReal "," psuTemp
# this is for output, a null print line does NOT create a new array index in bash # this is for output, a null print line does NOT create a new array index in bash
if ( fanMainString == "" && fanDefaultString == "" ) { if ( fanMainString == "" ) {
fanMainString="," fanMainString=","
} }
print fanMainString print fanMainString