diff --git a/inxi b/inxi index 67c4d5e..ba6a489 100755 --- a/inxi +++ b/inxi @@ -3,7 +3,7 @@ #### Script Name: inxi #### Version: 2.0.0 #### Date: 2014-03-12 -#### Patch Number: 01-b1 +#### Patch Number: 02-b1 ######################################################################## #### SPECIAL THANKS ######################################################################## @@ -166,6 +166,7 @@ ######################################################################## #### Valuable Resources #### CPU flags: http://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean +#### Advanced Bash: http://wiki.bash-hackers.org/syntax/pe #### gawk arrays: http://www.math.utah.edu/docs/info/gawk_12.html #### raid mdstat: http://www-01.ibm.com/support/docview.wss?uid=isg3T1011259 #### http://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array @@ -2638,7 +2639,8 @@ print_lines_basic() b_indent_x='false' ;; 1) indent_full=$indent_main - temp_count=$( wc -c <<< $2 ) + # temp_count=$( wc -c <<< $2 ) + temp_count=${#2} if [[ $temp_count -lt $indent_full ]];then indent_working=$indent_full else @@ -2649,7 +2651,7 @@ print_lines_basic() # first left pad 2 and 3, then right pad them 2) indent_full=$(( $indent_main + 6 )) indent_inner=3 - temp_count=$( wc -c <<< $2 ) + temp_count=${#2} if [[ $temp_count -lt $indent_inner ]];then indent_working=$indent_inner else @@ -2660,7 +2662,7 @@ print_lines_basic() ;; 3) indent_full=$(( $indent_main + 8 )) indent_inner=3 - temp_count=$( wc -c <<< $2 ) + temp_count=${#2} if [[ $temp_count -lt $indent_inner ]];then indent_working=$indent_inner else @@ -2671,7 +2673,7 @@ print_lines_basic() ;; # for long options 4) indent_full=$(( $indent_main + 8 )) - temp_count=$( wc -c <<< $2 ) + temp_count=${#2} if [[ $temp_count -lt $indent_full ]];then indent_working=$indent_full else @@ -2689,13 +2691,16 @@ print_lines_basic() line_count=$(( $line_width - $indent_full )) # bash loop is so slow, only run this if required - if [[ $( wc -c <<< $3 ) -gt $line_count ]];then + # temp_count=$( wc -c <<< $3 ) + temp_count=${#3} + if [[ $temp_count -gt $line_count ]];then for word in $3 do temp_string="$print_string$spacer$word" spacer=' ' # note: wc -c here will return +1 actual string length - temp_count=$( wc -c <<< $temp_string ) + #temp_count=$( wc -c <<< $temp_string ) + temp_count=${#temp_string} if [[ $temp_count -lt $line_count ]];then print_string=$temp_string # lose any white space start/end # echo -n $(( $line_width - $indent_full )) @@ -8730,7 +8735,8 @@ calculate_line_length() local string="$1" # 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 ) - count=$( wc -c <<< $string ) + # count=$( wc -c <<< $string ) + count=${#string} echo $count } @@ -9287,7 +9293,7 @@ print_cpu_flags_full() eval $LOGFS # note: sort only sorts lines, not words in a string, so convert to lines local cpu_flags_full="$( echo $1 | tr " " "\n" | sort )" - local a_cpu_flags='' line_starter='' + local a_cpu_flags='' line_starter='' temp_count='' local i=0 counter=0 max_length=85 max_length_minus=15 flag='' flag_data='' local line_length_max='' flag_feature='Flags' @@ -9305,8 +9311,9 @@ print_cpu_flags_full() else line_length_max=$max_length fi - - if [[ $( wc -c <<< ${a_cpu_flags[$counter]} ) -gt $line_length_max ]];then + # temp_count=$( wc -c <<< ${a_cpu_flags[$counter]} ) + temp_count=${#a_cpu_flags[$counter]} + if [[ $temp_count -gt $line_length_max ]];then (( counter++ )) fi done