mirror of
https://github.com/smxi/inxi.git
synced 2024-11-16 16:21:39 +00:00
added more robust array clearing
This commit is contained in:
parent
7dcc1e16a2
commit
ca4e5e1c1e
58
inxi
58
inxi
|
@ -625,11 +625,13 @@ DISTROS_OS_RELEASE_GOOD="arch-release SuSE-release "
|
|||
## OUTPUT FILTERS/SEARCH ##
|
||||
# Note that \<ltd\> bans only words, not parts of strings; in \<corp\> you can't use punctuation characters like . or ,
|
||||
# we're saving about 10+% of the total script exec time by hand building the ban lists here, using hard quotes.
|
||||
|
||||
BAN_LIST_NORMAL='chipset|components|computing|computer|corporation|communications|electronics|electrical|electric|gmbh|group|incorporation|industrial|international|nee|revision|semiconductor|software|technologies|technology|ltd\.|\<ltd\>|inc\.|\<inc\>|intl\.|co\.|\<co\>|corp\.|\<corp\>|\(tm\)|\(r\)|®|\(rev ..\)'
|
||||
BAN_LIST_CPU='@||cpu |cpu deca|dual core|dual-core|tri core|tri-core|quad core|quad-core|ennea|genuine|hepta|hexa|multi|octa|penta|processor|single|triple|[0-9\.]+ *[MmGg][Hh][Zz]'
|
||||
# See github issue 75 for more details on value: *, triggers weird behaviors if present in value
|
||||
# /sys/devices/virtual/dmi/id/product_name:['*']
|
||||
# this is for bash arrays AND avoiding * in arrays: ( fred * greg ) expands to the contents of the directory
|
||||
BAN_LIST_NORMAL='chipset|components|computing|computer|corporation|communications|electronics|electrical|electric|gmbh|group|incorporation|industrial|international|nee|revision|semiconductor|software|technologies|technology|ltd\.|\<ltd\>|inc\.|\<inc\>|intl\.|co\.|\<co\>|corp\.|\<corp\>|\(tm\)|\(r\)|®|^\*$|\(rev ..\)'
|
||||
BAN_LIST_CPU='@||cpu |cpu deca|dual core|dual-core|tri core|tri-core|quad core|quad-core|ennea|genuine|hepta|hexa|multi|octa|penta|processor|single|triple|[0-9\.]+ *[MmGg][Hh][Zz]'
|
||||
BAN_LIST_ARRAY=',|^[[:space:]]*\*[[:space:]]*$'
|
||||
|
||||
SENSORS_GPU_SEARCH='intel|radeon|nouveau'
|
||||
|
||||
|
@ -3748,7 +3750,7 @@ get_audio_data()
|
|||
audioCard=gensub(/^[0-9a-f:\.]+ [^:]+: (.+)$/,"\\1","g",$0)
|
||||
# The doublequotes are necessary because of the pipes in the variable.
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", audioCard)
|
||||
gsub(/,/, " ", audioCard)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", audioCard)
|
||||
gsub(/^ +| +$/, "", audioCard)
|
||||
gsub(/ [ \t]+/, " ", audioCard)
|
||||
aPciBusId[audioCard] = gensub(/(^[0-9a-f:\.]+) [^:]+: .+$/,"\\1","g",$0)
|
||||
|
@ -3756,7 +3758,7 @@ get_audio_data()
|
|||
|
||||
# loop until you get to the end of the data block
|
||||
while (getline && !/^$/) {
|
||||
gsub( /,/, "", $0 )
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, "", $0 )
|
||||
if (/driver in use/) {
|
||||
drivers[audioCard] = drivers[audioCard] gensub( /(.*): (.*)/ ,"\\2", "g" ,$0 ) ""
|
||||
}
|
||||
|
@ -3867,7 +3869,7 @@ get_audio_usb_data()
|
|||
separator=""
|
||||
}
|
||||
{
|
||||
gsub( /,/, " ", $0 )
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0 )
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $0)
|
||||
gsub(/ [ \t]+/, " ", $0)
|
||||
for ( i=7; i<= NF; i++ ) {
|
||||
|
@ -3916,7 +3918,7 @@ get_audio_alsa_data()
|
|||
# remove trailing . and remove possible second line if compiled by user
|
||||
$0 !~ /compile/ {
|
||||
gsub(/Driver | [(].*[)]|\.$/,"",$0 )
|
||||
gsub(/,/, " ", $0)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0)
|
||||
gsub(/^ +| +$/, "", $0)
|
||||
gsub(/ [ \t]+/, " ", $0)
|
||||
sub(/Advanced Linux Sound Architecture/, "ALSA", $0)
|
||||
|
@ -4075,7 +4077,7 @@ get_cpu_data()
|
|||
# TAKE NOTE: \t+ will work for $FILE_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES!
|
||||
# Therefore PATCH to use [ \t]+ when TESTING!
|
||||
/^processor[ \t]+:/ {
|
||||
gsub(/,/, " ", $NF)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $NF)
|
||||
gsub(/^ +| +$/, "", $NF)
|
||||
if ( $NF ~ "^[0-9]+$" ) {
|
||||
nr = $NF
|
||||
|
@ -4092,7 +4094,7 @@ get_cpu_data()
|
|||
/^model name|^cpu\t+:/ {
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
|
||||
gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
|
||||
gsub(/,/, " ", $NF)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $NF)
|
||||
gsub(/^ +| +$/, "", $NF)
|
||||
gsub(/ [ \t]+/, " ", $NF)
|
||||
cpu[nr, "model"] = $NF
|
||||
|
@ -4242,7 +4244,7 @@ get_cpu_data_bsd()
|
|||
/^hw.model/ && ( bsdVersion != "darwin" ) {
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
|
||||
gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
|
||||
gsub(/,/," ",$NF)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/," ",$NF)
|
||||
sub(/[a-z]+-core/, "", $NF )
|
||||
gsub(/^ +| +$|\"/, "", $NF)
|
||||
gsub(/ [ \t]+/, " ", $NF)
|
||||
|
@ -4299,7 +4301,7 @@ get_cpu_data_bsd()
|
|||
/^machdep.cpu.brand_string/ {
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
|
||||
gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
|
||||
gsub(/,/," ",$NF)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/," ",$NF)
|
||||
sub(/[a-z]+-core/, "", $NF )
|
||||
gsub(/^ +| +$|\"/, "", $NF)
|
||||
gsub(/ [ \t]+/, " ", $NF)
|
||||
|
@ -4346,7 +4348,7 @@ get_cpu_flags_bsd()
|
|||
gsub(/<[a-z0-9]+>/,"", $2)
|
||||
# all the flags are contained within < ... > on freebsd at least
|
||||
gsub(/.*<|>.*/,"", $2)
|
||||
gsub(/,/," ", $2)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/," ", $2)
|
||||
cpuFlags = cpuFlags " " $2
|
||||
}
|
||||
}
|
||||
|
@ -4422,7 +4424,7 @@ get_cpu_ht_multicore_smp_data()
|
|||
}
|
||||
# array of logical processors, both HT and physical
|
||||
/^processor/ {
|
||||
gsub(/,/, " ", $NF)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $NF)
|
||||
gsub(/^ +| +$/, "", $NF)
|
||||
if ( $NF ~ "^[0-9]+$" ) {
|
||||
a_processor_id[proc_iter] = $NF
|
||||
|
@ -5161,7 +5163,7 @@ get_distro_data()
|
|||
}
|
||||
{
|
||||
gsub(/\\[a-z]/, "")
|
||||
gsub(/,/, " ")
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ")
|
||||
gsub(/^ +| +$/, "")
|
||||
gsub(/ [ \t]+/, " ")
|
||||
print
|
||||
|
@ -5421,7 +5423,7 @@ get_dmidecode_data()
|
|||
cutExtraTab="true"
|
||||
}
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", twoData)
|
||||
gsub(/,/, " ", twoData)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", twoData)
|
||||
# clean out Handle line
|
||||
# sub(/^Handle.*/,"", $0)
|
||||
sub(/^[[:space:]]*Inactive.*/,"",twoData)
|
||||
|
@ -5492,7 +5494,7 @@ get_dmesg_boot_data()
|
|||
dmsg_boot_data="$( cat $FILE_DMESG_BOOT 2>/dev/null | gawk '
|
||||
{
|
||||
sub(/[[:space:]]*=[[:space:]]*|:[[:space:]]*/,":", $0)
|
||||
gsub(/,/," ", $0)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/," ", $0)
|
||||
gsub(/\"/, "", $0)
|
||||
gsub(/[[:space:]][[:space:]]/, " ", $0)
|
||||
print $0
|
||||
|
@ -5669,7 +5671,7 @@ get_graphics_card_data()
|
|||
# card. .1 would be for example: Display Adapter with bus id x:xx.1, not the right one
|
||||
/vga compatible controller|3D controller|Display controller/ {
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF)
|
||||
gsub(/,/, " ", $NF)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $NF)
|
||||
gsub(/^ +| +$/, "", $NF)
|
||||
gsub(/ [ \t]+/, " ", $NF)
|
||||
busId=gensub(/^([0-9a-f:\.]+) (.+)$/,"\\1","",$1)
|
||||
|
@ -5922,7 +5924,7 @@ get_graphics_display_server_data()
|
|||
}
|
||||
/vendor string/ {
|
||||
gsub(/the|inc|foundation|project|corporation/, "", $2)
|
||||
gsub(/,/, " ", $2)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $2)
|
||||
gsub(/^ +| +$/, "", $2)
|
||||
gsub(/ [ \t]+/, " ", $2)
|
||||
vendorString = $2
|
||||
|
@ -6147,7 +6149,7 @@ get_hdd_data_basic()
|
|||
gawk -v hddUsed=$hdd_used '
|
||||
/([hsv]d[a-z]+|(ada|mmcblk)[0-9]+)$/ {
|
||||
driveSize = $(NF - 1)*1024/1000**3
|
||||
gsub(/,/, " ", driveSize)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", driveSize)
|
||||
gsub(/^ +| +$/, "", driveSize)
|
||||
printf( $NF",%.1fGB,,\n", driveSize )
|
||||
}
|
||||
|
@ -6252,7 +6254,7 @@ get_hard_drive_data_advanced()
|
|||
#c=gensub( /^ *vendor: (.+) +model: (.+) +rev:.*$/,"\\1 \\2","g",a[i] )
|
||||
# the vendor: string is useless, and is a bug, ATA is not a vendor for example
|
||||
c=gensub( /^ *vendor: (.+) +model: (.+) +rev:.*$/, "\\2", "g", a[i] )
|
||||
gsub(/,/, " ", c)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", c)
|
||||
gsub(/^ +| +$/, "", c)
|
||||
gsub(/ [ \t]+/, " ", c)
|
||||
#print a[i]
|
||||
|
@ -6747,7 +6749,7 @@ get_machine_data()
|
|||
}
|
||||
{
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $0)
|
||||
gsub(/,/, " ", $0)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0)
|
||||
# yes, there is a typo in a user data set, unknow
|
||||
# Base Board Version|Base Board Serial Number
|
||||
# Chassis Manufacturer|Chassis Version|Chassis Serial Number
|
||||
|
@ -7024,7 +7026,7 @@ get_module_version_number()
|
|||
IGNORECASE=1
|
||||
}
|
||||
/^version/ {
|
||||
gsub(/,/, " ", $2)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $2)
|
||||
gsub(/^ +| +$/, "", $2)
|
||||
gsub(/ [ \t]+/, " ", $2)
|
||||
print $2
|
||||
|
@ -7061,12 +7063,12 @@ get_networking_data()
|
|||
#gsub(/davicom semiconductor/, "Davicom", aNic[counter])
|
||||
# The doublequotes are necessary because of the pipes in the variable.
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", aNic[counter])
|
||||
gsub(/,/, " ", aNic[counter])
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", aNic[counter])
|
||||
gsub(/^ +| +$/, "", aNic[counter])
|
||||
gsub(/ [ \t]+/, " ", aNic[counter])
|
||||
aPciBusId[counter] = gensub(/(^[0-9a-f:\.]+) [^:]+: .+$/,"\\1","g",$0)
|
||||
while ( getline && !/^$/ ) {
|
||||
gsub(/,/, "", $0)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, "", $0)
|
||||
if ( /^[[:space:]]*I\/O/ ) {
|
||||
aPorts[counter] = aPorts[counter] $4 " "
|
||||
}
|
||||
|
@ -7331,7 +7333,7 @@ get_networking_usb_data()
|
|||
}
|
||||
/'"$USB_NETWORK_SEARCH"'/ && !/bluetooth| hub|keyboard|mouse|printer| ps2|reader|scan|storage/ {
|
||||
string=""
|
||||
gsub( /,/, " ", $0 )
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0 )
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $0)
|
||||
gsub(/ [ \t]+/, " ", $0)
|
||||
#sub(/realtek semiconductor/, "Realtek", $0)
|
||||
|
@ -7466,7 +7468,7 @@ get_networking_local_ip_data()
|
|||
/^[a-zA-Z]+[0-9]/ {
|
||||
# not clear on why inet is coming through, but this gets rid of it
|
||||
# as first line item.
|
||||
gsub(/,/, " ", $0)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0)
|
||||
gsub(/^ +| +$/, "", $0)
|
||||
gsub(/ [ \t]+/, " ", $0)
|
||||
interface = $1
|
||||
|
@ -7650,7 +7652,7 @@ get_optical_drive_data()
|
|||
{
|
||||
gsub(/'"$BAN_LIST_NORMAL"'/, "", $0)
|
||||
sub(/TSSTcorp/, "TSST ", $0) # seen more than one of these weird ones
|
||||
gsub(/,/, " ", $0)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0)
|
||||
gsub(/^[[:space:]]*|[[:space:]]*$/, "", $0)
|
||||
gsub(/ [[:space:]]+/, " ", $0)
|
||||
print $0
|
||||
|
@ -8671,7 +8673,7 @@ get_raid_data()
|
|||
uData = ""
|
||||
|
||||
while ( !/^[[:space:]]*$/ ) {
|
||||
gsub(/,/, " ", $0 )
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/, " ", $0 )
|
||||
gsub(/[[:space:]]+/, " ", $0 )
|
||||
if ( $0 ~ /^md/ ) {
|
||||
device = gensub(/(md.*)[[:space:]]?:/, "\\1", "1", $1 )
|
||||
|
@ -9872,7 +9874,7 @@ get_repo_data()
|
|||
repoUrl=""
|
||||
enabled=""
|
||||
while ( getline && $0 !~ /^[[:space:]]*$/ ) {
|
||||
gsub(/,/,"",$0)
|
||||
gsub(/'"$BAN_LIST_ARRAY"'/,"",$0)
|
||||
gsub(/({|}|^[[:space:]]+|[[:space:]]+$)/,"",$1)
|
||||
gsub(/({|}|^[[:space:]]+|[[:space:]]+$)/,"",$2)
|
||||
if ( $1 == "url" ) {
|
||||
|
|
Loading…
Reference in a new issue