Cleaned up more awk one liner flow controls, removed ; and added new lines, please check to make sure I didn't mess up!

This commit is contained in:
inxi-svn 2008-11-05 23:54:14 +00:00
parent 32a9957109
commit 1169e86347

73
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
#### version: 0.3.23
#### version: 0.3.24
#### Date: November 5 2008
########################################################################
#### inxi is a fork of infobash, the original bash sys info script by locsmif
@ -412,7 +412,8 @@ get_cmdline()
local i=0 ppid=$1
if [ ! -e /proc/$ppid/cmdline ];then
{ echo 0; return; }
echo 0
return
fi
##print_screen_output "Marker"
##print_screen_output "\$ppid='$ppid' -=- $(< /proc/$ppid/cmdline)"
@ -595,7 +596,18 @@ get_start_source()
else
KONVI=1
fi
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk '/Konversation:/ { for (i=2;i<=NF;i++) { if (i == NF) { print $i } else { printf $i" " } } exit }' )"
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk '
/Konversation:/ {
for ( i=2; i<=NF; i++ ) {
if (i == NF) {
print $i
}
else {
printf $i" "
}
}
exit
}' )"
T=($IRC_CLIENT_VERSION)
if [[ ${T[0]} == *+* ]];then
# < Sho_> locsmif: The version numbers of SVN versions look like this:
@ -608,7 +620,13 @@ get_start_source()
T2="${T[0]}"
fi
# Remove any dots except the first, and make sure there are no trailing zeroes,
T2=$( echo "$T2" | gawk '{ sub(/\./, " "); gsub(/\./, ""); sub(/ /, "."); printf("%g\n", $0) }' )
T2=$( echo "$T2" | gawk '
{
sub(/\./, " ")
gsub(/\./, "")
sub(/ /, ".")
printf("%g\n", $0)
}' )
# Since Konversation 1.0, the DCOP interface has changed a bit: dcop "$DCPORT" Konversation ..etc
# becomes : dcop "$DCPORT" default ... or dcop "$DCPORT" irc ..etc. So we check for versions smaller
# than 1 and change the DCOP parameter/object accordingly.
@ -627,8 +645,16 @@ get_start_source()
;;
*bitchx*)
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk '
/Version/ { a=tolower($2); gsub(/[()]|bitchx-/,"",a); print a; exit }
$2 == "version" { a=tolower($3); sub(/bitchx-/,"",a); print a; exit }
/Version/ {
a=tolower($2)
gsub(/[()]|bitchx-/,"",a)
print a; exit
}
$2 == "version" {
a=tolower($3)
sub(/bitchx-/,"",a)
print a; exit
}
' )"
IRC_CLIENT="BitchX"
;;
@ -649,7 +675,17 @@ get_start_source()
IRC_CLIENT="Weechat"
;;
*kvirc*)
IRC_CLIENT_VERSION=" $( $irc_client_path -v 2>&1 | gawk '{ for (i=2;i<=NF;i++) { if (i==NF) print $i; else printf $i" " }; exit }' )"
IRC_CLIENT_VERSION=" $( $irc_client_path -v 2>&1 | gawk '
{
for ( i=2; i<=NF; i++) {
if (i==NF) {
print $i
}
else {
printf $i" "
}
}exit
}' )"
IRC_CLIENT="KVIrc"
;;
*kopete*)
@ -847,7 +883,7 @@ get_cpu_data()
END {
#if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that
for (i = 0; i <= nr; i++) {
for ( i = 0; i <= nr; i++ ) {
print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"] "," cpu[nr, "vendor"]
}
if (!min) {
@ -904,10 +940,11 @@ get_distro_data()
distro_file="issue"
distro=$( gawk '
BEGIN { RS="" } {
gsub(/\\[a-z]/,"");
gsub(/ [ ]+/," ");
gsub(/^ +| +$/,"");
print }' "/etc/${distro_file}" )
gsub(/\\[a-z]/,"")
gsub(/ [ ]+/," ")
gsub(/^ +| +$/,"")
print
}' "/etc/${distro_file}" )
fi
if [ "${#distro}" -gt 80 -a "$B_HANDLE_CORRUPT_DATA" != 'true' ];then
distro="${RED}/etc/${distro_file} corrupted, use -C to override${NORMAL}"
@ -1037,8 +1074,7 @@ get_graphics_x_data()
gsub(/the|,|inc|foundation|project|coorperation/, "", $2)
gsub(/^ +| +$/, "", $2); gsub(/ +/," ",$2)
print $2
}
' )
}' )
# new method added since radeon and X.org and the disappearance of <X server name> version : ...etc
# Later on, the normal textual version string returned, e.g. like: X.Org version: 6.8.2
@ -1100,7 +1136,8 @@ 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(/^ +| +$/, "", c)
#print a[i]
if (c ~ /\<flash\>|\<pendrive\>|memory stick|memory card/) continue
print c
@ -1243,7 +1280,11 @@ get_partition_data()
get_uptime()
{
## note: removing gsub(/ /,"",a); to get get space back in there, goes right before print a
echo $( uptime | gawk '{ a = gensub(/^.*up *([^,]*).*$/,"\\1","g",$0); print a }' )
echo $( uptime | gawk '
{
a = gensub(/^.*up *([^,]*).*$/,"\\1","g",$0)
print a
}' )
}
#### -------------------------------------------------------------------