mirror of
https://github.com/smxi/inxi.git
synced 2025-01-19 08:57:57 +00:00
Got rid of sanitize_data feature, which forces double dips into awk, instead I put hte cleaners for , and whitespace into
each awk statement. This avoids exiting awk, then looping through the array in bash, then sending the array items to the cleaner function, back into awk, then sending it back, and rebuilding the array. I tried putting the gawk cleaners into a variable and using the variable, but that didn't work as expected, but I'll see if i can figure out how to get that working.
This commit is contained in:
parent
c2f692c068
commit
82c3d091a8
77
inxi
77
inxi
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### version: 0.3.25
|
||||
#### Date: November 5 2008
|
||||
#### version: 0.3.26
|
||||
#### Date: November 6 2008
|
||||
########################################################################
|
||||
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
||||
#### As time permits functionality improvements and recoding will occur.
|
||||
|
@ -39,20 +39,6 @@
|
|||
#### VARIABLES
|
||||
########################################################################
|
||||
|
||||
GAWK_CLEANUP='
|
||||
gsub(/,/," ",$NF)
|
||||
gsub(/[^ | $| \t]+/," ",$NF)
|
||||
'
|
||||
|
||||
# fred=$( echo ' corporate graphics crap of some type ' | gawk '
|
||||
# /graphics/ {
|
||||
# gsub(/"graphics"/, "", $NF )
|
||||
# '
|
||||
# $GAWK_CLEANUP
|
||||
# '}' )
|
||||
# echo $fred;exit
|
||||
|
||||
|
||||
## NOTE: we can use hwinfo if it's available in all systems, or most, to get
|
||||
## a lot more data and verbosity levels going
|
||||
|
||||
|
@ -802,6 +788,9 @@ get_audio_data()
|
|||
{ IGNORECASE=1 }
|
||||
/multimedia audio controller|audio device/ {
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
|
||||
gsub(/,/," ",$NF)
|
||||
gsub(/^ +| +$/,"",$NF)
|
||||
gsub(/ [ \t]+/," ",$NF)
|
||||
print $NF
|
||||
}' ) )
|
||||
IFS="$ORIGINAL_IFS"
|
||||
|
@ -860,9 +849,10 @@ get_cpu_data()
|
|||
/^processor\t+:/ { nr = $NF }
|
||||
|
||||
/^model name|^cpu\t+:/ {
|
||||
gsub(/,/," ",$NF)
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
|
||||
gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
|
||||
gsub(/,/, " ", $NF)
|
||||
gsub(/^ +| +$/, "", $NF)
|
||||
gsub(/ [ \t]+/, " ", $NF)
|
||||
cpu[nr, "model"] = $NF
|
||||
}
|
||||
|
@ -956,8 +946,9 @@ get_distro_data()
|
|||
distro=$( gawk '
|
||||
BEGIN { RS="" } {
|
||||
gsub(/\\[a-z]/, "")
|
||||
gsub(/ [ ]+/," ")
|
||||
gsub(/,/, " ")
|
||||
gsub(/^ +| +$/, "")
|
||||
gsub(/ [ \t]+/, " ")
|
||||
print
|
||||
}' "/etc/${distro_file}" )
|
||||
fi
|
||||
|
@ -983,12 +974,21 @@ get_graphics_card_data()
|
|||
local i=''
|
||||
|
||||
IFS=$'\n'
|
||||
A_GFX_CARD_DATA=( $( echo "$lspci_data" | gawk -F': ' '/VGA compatible controller/ { print $NF }' ) )
|
||||
A_GFX_CARD_DATA=( $( echo "$lspci_data" | gawk -F': ' '
|
||||
{ IGNORECASE=1 }
|
||||
/VGA compatible controller/ {
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF)
|
||||
gsub(/,/, " ", $NF)
|
||||
gsub(/^ +| +$/, "", $NF)
|
||||
gsub(/ [ \t]+/, " ", $NF)
|
||||
print $NF
|
||||
}'
|
||||
) )
|
||||
IFS="$ORIGINAL_IFS"
|
||||
for (( i=0; i < ${#A_GFX_CARD_DATA[@]}; i++ ))
|
||||
do
|
||||
A_GFX_CARD_DATA[i]=$( sanitize_characters BAN_LIST_NORMAL "${A_GFX_CARD_DATA[i]}" )
|
||||
done
|
||||
# for (( i=0; i < ${#A_GFX_CARD_DATA[@]}; i++ ))
|
||||
# do
|
||||
# A_GFX_CARD_DATA[i]=$( sanitize_characters BAN_LIST_NORMAL "${A_GFX_CARD_DATA[i]}" )
|
||||
# done
|
||||
# handle cases where card detection fails, like in PS3, where lspci gives no output, or headless boxes..
|
||||
if [[ ${#A_GFX_CARD_DATA[@]} -eq 0 ]];then
|
||||
A_GFX_CARD_DATA[0]='Failed to Detect Video Card!'
|
||||
|
@ -1090,7 +1090,9 @@ get_graphics_x_data()
|
|||
BEGIN { IGNORECASE=1 }
|
||||
/vendor string/ {
|
||||
gsub(/the|,|inc|foundation|project|coorperation/, "", $2)
|
||||
gsub(/^ +| +$/, "", $2); gsub(/ +/," ",$2)
|
||||
gsub(/,/, " ", $2)
|
||||
gsub(/^ +| +$/, "", $2)
|
||||
gsub(/ [ \t]+/, " ", $2)
|
||||
print $2
|
||||
}' )
|
||||
|
||||
|
@ -1154,10 +1156,13 @@ get_hard_drive_data()
|
|||
if (b[i] ~ / *type: *direct-access.*/) {
|
||||
#c=gensub(/^ *vendor: (.+) +model: (.+) +rev: (.+)$/,"\\1 \\2 \\3","g",a[i])
|
||||
c=gensub(/^ *vendor: (.+) +model: (.+) +rev:.*$/,"\\1 \\2","g",a[i])
|
||||
gsub(/ [ ]+/, " ", c)
|
||||
gsub(/,/, " ", c)
|
||||
gsub(/^ +| +$/, "", c)
|
||||
gsub(/ [ \t]+/, " ", c)
|
||||
#print a[i]
|
||||
if (c ~ /\<flash\>|\<pendrive\>|memory stick|memory card/) continue
|
||||
if (c ~ /\<flash\>|\<pendrive\>|memory stick|memory card/) {
|
||||
continue
|
||||
}
|
||||
print c
|
||||
}
|
||||
}
|
||||
|
@ -1196,10 +1201,16 @@ get_hard_drive_data()
|
|||
if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) {
|
||||
if (NF == 1) {
|
||||
getline
|
||||
if (NF == 5) { c += $2 }
|
||||
else next
|
||||
if (NF == 5) {
|
||||
c += $2
|
||||
}
|
||||
else {
|
||||
next
|
||||
}
|
||||
}
|
||||
else if (NF == 6) {
|
||||
c += $3
|
||||
}
|
||||
else if (NF == 6) { c += $3 }
|
||||
}
|
||||
}
|
||||
/^Filesystem/ { p++ }
|
||||
|
@ -1247,14 +1258,16 @@ get_networking_data()
|
|||
nic=gensub(/^[0-9a-f:.]+ [^:]+: (.+)$/,"\\1","g",$0)
|
||||
gsub(/realtek semiconductor/, "Realtek", nic)
|
||||
gsub(/davicom semiconductor/, "Davicom", nic)
|
||||
gsub(/,/," ", nic)
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", nic)
|
||||
gsub(/ [ ]+/," ", nic)
|
||||
gsub(/,/, " ", nic)
|
||||
gsub(/^ +| +$/, "", nic)
|
||||
gsub(/ [ \t]+/, " ", nic)
|
||||
# The doublequotes above are necessary because of the pipes in the variable.
|
||||
eth[nic]++
|
||||
while (getline && !/^$/) {
|
||||
if (/I\/O/) ports[nic]=ports[nic]$4" "
|
||||
if (/I\/O/) {
|
||||
ports[nic]=ports[nic]$4" "
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue