mirror of
https://github.com/smxi/inxi.git
synced 2024-11-16 16:21:39 +00:00
replaced eat() with remove_errooneous_characters function by trash80
This commit is contained in:
parent
65ff6dd284
commit
cde859ac3b
27
inxi
27
inxi
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### version: 0.1.21
|
||||
#### version: 0.1.22
|
||||
#### Date: October 27 2008
|
||||
########################################################################
|
||||
#### inxi is a fork of infobash, the original bash sys info script by locsmif
|
||||
|
@ -199,10 +199,23 @@ script_debugger()
|
|||
fi
|
||||
}
|
||||
|
||||
eat()
|
||||
remove_erroneous_chars()
|
||||
{
|
||||
gawk 'BEGIN { RS="" } { gsub(/\n$/,""); gsub(/\n/," "); gsub(/^ *| *$/, ""); gsub(/ +/, " "); printf $0 }' "$1"
|
||||
## this removes newline and pipes
|
||||
## RS is input record separator
|
||||
## gsub is substitute;
|
||||
gawk 'BEGIN { RS="" } { gsub(/\n$/,""); ## (newline; end of string) with (nothing)
|
||||
gsub(/\n/," "); ## (newline) with (space)
|
||||
gsub(/^ *| *$/, ""); ## (pipe char) with (nothing)
|
||||
gsub(/ +/, " "); ## ( +) with (space)
|
||||
gsub(/ [ ]+/, " "); ## ([ ]+) with (space)
|
||||
gsub(/^ +| +$/, ""); ## (pipe char) with (nothing)
|
||||
printf $0 }' "$1" ## prints (returns) cleaned input
|
||||
}
|
||||
# remove_erroneous_chars()
|
||||
# {
|
||||
# gawk 'BEGIN { RS="" } { gsub(/\n$/,""); gsub(/\n/," "); gsub(/^ *| *$/, ""); gsub(/ +/, " "); printf $0 }' "$1"
|
||||
# }
|
||||
|
||||
# Determine if any of the absolutely necessary tools are absent
|
||||
check_script_depends()
|
||||
|
@ -591,7 +604,7 @@ get_distro_data()
|
|||
fi
|
||||
if [ -n "$DISTFILE" -a -s /etc/$DISTFILE -a " $DISTROS_BLIST " != *" $DISTFILE "* ]
|
||||
then
|
||||
DISTRO=$( eat "/etc/$DISTFILE" )
|
||||
DISTRO=$( remove_erroneous_chars "/etc/$DISTFILE" )
|
||||
else
|
||||
# Debian pure should fall through here
|
||||
DISTFILE="issue"
|
||||
|
@ -740,7 +753,7 @@ get_hard_drive_data()
|
|||
{
|
||||
for I in /proc/ide/ide*/hd*
|
||||
do
|
||||
if [[ -e $I/media && $(eat $I/media) = disk ]]
|
||||
if [[ -e $I/media && $( remove_erroneous_chars $I/media ) = disk ]]
|
||||
then
|
||||
# BUGFIX: Ran into a debian sarge kernel that did not have the "capacity" file in the hd* directories
|
||||
if [[ ! -e $I/capacity ]]
|
||||
|
@ -748,8 +761,8 @@ get_hard_drive_data()
|
|||
CAP=0
|
||||
break
|
||||
fi
|
||||
(( CAP+=$( eat $I/capacity ) ))
|
||||
HDDMOD="${HDDMOD}${HDDMOD+,}$(eat $I/model)"
|
||||
(( CAP+=$( remove_erroneous_chars $I/capacity ) ))
|
||||
HDDMOD="${HDDMOD}${HDDMOD+,}$( remove_erroneous_chars $I/model )"
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in a new issue