mirror of
https://github.com/smxi/inxi.git
synced 2025-01-19 08:57:57 +00:00
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:
parent
32a9957109
commit
1169e86347
73
inxi
73
inxi
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 0.3.23
|
#### version: 0.3.24
|
||||||
#### Date: November 5 2008
|
#### Date: November 5 2008
|
||||||
########################################################################
|
########################################################################
|
||||||
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
#### 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
|
local i=0 ppid=$1
|
||||||
|
|
||||||
if [ ! -e /proc/$ppid/cmdline ];then
|
if [ ! -e /proc/$ppid/cmdline ];then
|
||||||
{ echo 0; return; }
|
echo 0
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
##print_screen_output "Marker"
|
##print_screen_output "Marker"
|
||||||
##print_screen_output "\$ppid='$ppid' -=- $(< /proc/$ppid/cmdline)"
|
##print_screen_output "\$ppid='$ppid' -=- $(< /proc/$ppid/cmdline)"
|
||||||
|
@ -595,7 +596,18 @@ get_start_source()
|
||||||
else
|
else
|
||||||
KONVI=1
|
KONVI=1
|
||||||
fi
|
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)
|
T=($IRC_CLIENT_VERSION)
|
||||||
if [[ ${T[0]} == *+* ]];then
|
if [[ ${T[0]} == *+* ]];then
|
||||||
# < Sho_> locsmif: The version numbers of SVN versions look like this:
|
# < Sho_> locsmif: The version numbers of SVN versions look like this:
|
||||||
|
@ -608,7 +620,13 @@ get_start_source()
|
||||||
T2="${T[0]}"
|
T2="${T[0]}"
|
||||||
fi
|
fi
|
||||||
# Remove any dots except the first, and make sure there are no trailing zeroes,
|
# 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
|
# 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
|
# becomes : dcop "$DCPORT" default ... or dcop "$DCPORT" irc ..etc. So we check for versions smaller
|
||||||
# than 1 and change the DCOP parameter/object accordingly.
|
# than 1 and change the DCOP parameter/object accordingly.
|
||||||
|
@ -627,8 +645,16 @@ get_start_source()
|
||||||
;;
|
;;
|
||||||
*bitchx*)
|
*bitchx*)
|
||||||
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk '
|
IRC_CLIENT_VERSION=" $( $irc_client_path -v | gawk '
|
||||||
/Version/ { a=tolower($2); gsub(/[()]|bitchx-/,"",a); print a; exit }
|
/Version/ {
|
||||||
$2 == "version" { a=tolower($3); sub(/bitchx-/,"",a); print a; exit }
|
a=tolower($2)
|
||||||
|
gsub(/[()]|bitchx-/,"",a)
|
||||||
|
print a; exit
|
||||||
|
}
|
||||||
|
$2 == "version" {
|
||||||
|
a=tolower($3)
|
||||||
|
sub(/bitchx-/,"",a)
|
||||||
|
print a; exit
|
||||||
|
}
|
||||||
' )"
|
' )"
|
||||||
IRC_CLIENT="BitchX"
|
IRC_CLIENT="BitchX"
|
||||||
;;
|
;;
|
||||||
|
@ -649,7 +675,17 @@ get_start_source()
|
||||||
IRC_CLIENT="Weechat"
|
IRC_CLIENT="Weechat"
|
||||||
;;
|
;;
|
||||||
*kvirc*)
|
*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"
|
IRC_CLIENT="KVIrc"
|
||||||
;;
|
;;
|
||||||
*kopete*)
|
*kopete*)
|
||||||
|
@ -847,7 +883,7 @@ get_cpu_data()
|
||||||
|
|
||||||
END {
|
END {
|
||||||
#if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that
|
#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"]
|
print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"] "," cpu[nr, "vendor"]
|
||||||
}
|
}
|
||||||
if (!min) {
|
if (!min) {
|
||||||
|
@ -904,10 +940,11 @@ get_distro_data()
|
||||||
distro_file="issue"
|
distro_file="issue"
|
||||||
distro=$( gawk '
|
distro=$( gawk '
|
||||||
BEGIN { RS="" } {
|
BEGIN { RS="" } {
|
||||||
gsub(/\\[a-z]/,"");
|
gsub(/\\[a-z]/,"")
|
||||||
gsub(/ [ ]+/," ");
|
gsub(/ [ ]+/," ")
|
||||||
gsub(/^ +| +$/,"");
|
gsub(/^ +| +$/,"")
|
||||||
print }' "/etc/${distro_file}" )
|
print
|
||||||
|
}' "/etc/${distro_file}" )
|
||||||
fi
|
fi
|
||||||
if [ "${#distro}" -gt 80 -a "$B_HANDLE_CORRUPT_DATA" != 'true' ];then
|
if [ "${#distro}" -gt 80 -a "$B_HANDLE_CORRUPT_DATA" != 'true' ];then
|
||||||
distro="${RED}/etc/${distro_file} corrupted, use -C to override${NORMAL}"
|
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(/the|,|inc|foundation|project|coorperation/, "", $2)
|
||||||
gsub(/^ +| +$/, "", $2); gsub(/ +/," ",$2)
|
gsub(/^ +| +$/, "", $2); gsub(/ +/," ",$2)
|
||||||
print $2
|
print $2
|
||||||
}
|
}' )
|
||||||
' )
|
|
||||||
|
|
||||||
# new method added since radeon and X.org and the disappearance of <X server name> version : ...etc
|
# 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
|
# 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.*/) {
|
if (b[i] ~ / *type: *direct-access.*/) {
|
||||||
#c=gensub(/^ *vendor: (.+) +model: (.+) +rev: (.+)$/,"\\1 \\2 \\3","g",a[i])
|
#c=gensub(/^ *vendor: (.+) +model: (.+) +rev: (.+)$/,"\\1 \\2 \\3","g",a[i])
|
||||||
c=gensub(/^ *vendor: (.+) +model: (.+) +rev:.*$/,"\\1 \\2","g",a[i])
|
c=gensub(/^ *vendor: (.+) +model: (.+) +rev:.*$/,"\\1 \\2","g",a[i])
|
||||||
gsub(/ [ ]+/, " ", c); gsub(/^ +| +$/, "", c)
|
gsub(/ [ ]+/, " ", c)
|
||||||
|
gsub(/^ +| +$/, "", c)
|
||||||
#print a[i]
|
#print a[i]
|
||||||
if (c ~ /\<flash\>|\<pendrive\>|memory stick|memory card/) continue
|
if (c ~ /\<flash\>|\<pendrive\>|memory stick|memory card/) continue
|
||||||
print c
|
print c
|
||||||
|
@ -1243,7 +1280,11 @@ get_partition_data()
|
||||||
get_uptime()
|
get_uptime()
|
||||||
{
|
{
|
||||||
## note: removing gsub(/ /,"",a); to get get space back in there, goes right before print a
|
## 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
|
||||||
|
}' )
|
||||||
}
|
}
|
||||||
|
|
||||||
#### -------------------------------------------------------------------
|
#### -------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue