branch one, test for esc handling gnu sed vs bsd sed

This commit is contained in:
inxi-svn 2014-04-03 04:19:16 +00:00
parent 7cdef2526f
commit e4a8a76c15

27
inxi
View file

@ -2,8 +2,8 @@
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### Version: 2.1.15 #### Version: 2.1.15
#### Date: 2014-04-01 #### Date: 2014-04-02
#### Patch Number: 02-b1 #### Patch Number: 01-b1
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
######################################################################## ########################################################################
@ -521,6 +521,7 @@ C2=''
CN='' CN=''
## Always leave these blank, these are only going to be set in inxi.conf files, that makes testing ## Always leave these blank, these are only going to be set in inxi.conf files, that makes testing
## for user changes easier after sourcing the files ## for user changes easier after sourcing the files
ESC='\x1b'
GLOBAL_COLOR_SCHEME='' GLOBAL_COLOR_SCHEME=''
IRC_COLOR_SCHEME='' IRC_COLOR_SCHEME=''
IRC_CONS_COLOR_SCHEME='' IRC_CONS_COLOR_SCHEME=''
@ -825,6 +826,7 @@ initialize_data()
BSD_TYPE='bsd' # all other bsds BSD_TYPE='bsd' # all other bsds
SED_I="-i ''" SED_I="-i ''"
SED_RX='-E' SED_RX='-E'
ESC=$(echo | tr '\n' '\033')
fi fi
fi fi
# now set the script BOOLEANS for files required to run features # now set the script BOOLEANS for files required to run features
@ -8908,11 +8910,12 @@ get_weather_data()
# args: $1 - string to strip color code characters out of # args: $1 - string to strip color code characters out of
# returns count of string length minus colors # returns count of string length minus colors
# note; this cleanup may not be working on bsd sed
calculate_line_length() calculate_line_length()
{ {
local string=$1 local string=$1
# ansi:  irc: \x0312 # ansi:  irc: \x0312
string=$( sed -e "s/\x1b\[[0-9]\{1,2\}\(;[0-9]\{1,2\}\)\{0,2\}m//g" -e "s/\\\x0[0-9]\{1,3\}//g" <<< $string ) string=$( sed -e 's/'$ESC'\[[0-9]\{1,2\}\(;[0-9]\{1,2\}\)\{0,2\}m//g' -e 's/\\\x0[0-9]\{1,3\}//g' <<< $string )
count=${#string} count=${#string}
echo $count echo $count
} }
@ -10526,12 +10529,14 @@ print_networking_ip_data()
if_string='' if_string=''
fi fi
else else
if [[ $( calculate_line_length "$if_string_holding$if_string" ) -lt $COLS_INNER ]];then if [[ $( calculate_line_length "$if_string_holding$if_string" ) -gt $COLS_INNER ]];then
if_string_holding="$if_string_holding$if_string" if [[ -n $if_string_holding ]];then
else
full_string=$( create_print_line " " "$if_string_holding${CN}" ) full_string=$( create_print_line " " "$if_string_holding${CN}" )
print_screen_output "$full_string" print_screen_output "$full_string"
fi
if_string_holding="$if_string" if_string_holding="$if_string"
else
if_string_holding="$if_string_holding$if_string"
fi fi
fi fi
((i++)) ((i++))
@ -10679,7 +10684,7 @@ print_optical_drive_data()
else else
multisession='no' multisession='no'
fi fi
multisession=" ${C1}multisession$SEP3${C2} $multisession" multisession="${C1}multisession$SEP3${C2} $multisession "
if [[ -z ${a_drives[11]} ]];then if [[ -z ${a_drives[11]} ]];then
dvd='N/A' dvd='N/A'
elif [[ ${a_drives[11]} == 1 ]];then elif [[ ${a_drives[11]} == 1 ]];then
@ -10693,7 +10698,7 @@ print_optical_drive_data()
else else
state="${a_drives[14]}" state="${a_drives[14]}"
fi fi
state=" ${C1}state$SEP3${C2} $state" state="${C1}state$SEP3${C2} $state "
fi fi
if [[ -n ${a_drives[9]} && ${a_drives[9]} == 1 ]];then if [[ -n ${a_drives[9]} && ${a_drives[9]} == 1 ]];then
rw_support='cd-r' rw_support='cd-r'
@ -10714,8 +10719,8 @@ print_optical_drive_data()
if [[ -z $rw_support ]];then if [[ -z $rw_support ]];then
rw_support='none' rw_support='none'
fi fi
drive_data="${C1}Features: speed$SEP3${C2} $speed$multisession " drive_data="${C1}Features: speed$SEP3${C2} $speed $multisession"
part_2_data="$audio ${C1}dvd$SEP3${C2} $dvd ${C1}rw$SEP3${C2} $rw_support$state" part_2_data="$audio${C1}dvd$SEP3${C2} $dvd ${C1}rw$SEP3${C2} $rw_support $state"
if [[ $( calculate_line_length "$drive_data$part_2_data" ) -lt $COLS_INNER ]];then if [[ $( calculate_line_length "$drive_data$part_2_data" ) -lt $COLS_INNER ]];then
drive_data=$( create_print_line "$Line_Starter" "$drive_data$part_2_data${CN}" ) drive_data=$( create_print_line "$Line_Starter" "$drive_data$part_2_data${CN}" )
print_screen_output "$drive_data" print_screen_output "$drive_data"
@ -10841,8 +10846,10 @@ print_partition_data()
else else
line_starter=' ' line_starter=' '
fi fi
if [[ -n ${a_partition_data[$i]} ]];then
partition_data=$( create_print_line "$line_starter" "${a_partition_data[$i]}${CN}" ) partition_data=$( create_print_line "$line_starter" "${a_partition_data[$i]}${CN}" )
print_screen_output "$partition_data" print_screen_output "$partition_data"
fi
done done
eval $LOGFE eval $LOGFE