From 2122cff7ca956e5fafac86320b7be09ddbd55d17 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Fri, 7 Nov 2008 19:59:11 +0000 Subject: [PATCH] Made all awk gawk to keep it consistent, this is the type of randomness we need to avoid in the future. --- inxi | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/inxi b/inxi index df9b824..0b69433 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 0.3.29 +#### version: 0.3.30 #### Date: November 7 2008 ######################################################################## #### inxi is a fork of infobash, the original bash sys info script by locsmif @@ -129,7 +129,7 @@ FL2='' ### Script names/paths SCRIPT_NAME="inxi" SCRIPT_PATH=$( dirname $0 ) -SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | awk '{print $3}' ) +SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3}' ) KONVI_CFG="konversation/scripts/$SCRIPT_NAME.conf" # relative path to $(kde-config --path data) ### Script Localization @@ -306,8 +306,8 @@ remove_erroneous_chars() }' "$1" ## prints (returns) cleaned input } -## note: this is now running inside each awk sequence directly to avoid exiting awk -## looping in bash through arrays, then re-entering awk to clean up, then writing back to array +## note: this is now running inside each gawk sequence directly to avoid exiting gawk +## looping in bash through arrays, then re-entering gawk to clean up, then writing back to array ## in bash. For now I'll leave this here because there's still some interesting stuff to get re methods # Enforce boilerplate and buzzword filters # args: $1 - BAN_LIST_NORMAL/BAN_LIST_CPU; $2 - string to sanitize @@ -533,7 +533,7 @@ show_options() ## print out version information for -V/--version print_version_info() { - local last_modified=$( grep -im 1 'date:' $SCRIPT_PATH/$SCRIPT_NAME | awk '{print $3,$4,$5}' ) + local last_modified=$( grep -im 1 'date:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3,$4,$5}' ) print_screen_output "$SCRIPT_NAME - the universal, portable, system info script for irc." print_screen_output "Version: $SCRIPT_VERSION_NUMBER" @@ -561,7 +561,7 @@ script_self_updater() print_screen_output "Updating $SCRIPT_NAME in $SCRIPT_PATH now..." wget -O $SCRIPT_PATH/$SCRIPT_NAME http://techpatterns.com/downloads/distro/$SCRIPT_NAME || error_handler 8 "$?" if [[ $? -eq 0 ]];then - SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | awk '{print $3}' ) + SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3}' ) print_screen_output "Successfully updated to version: $SCRIPT_VERSION_NUMBER\nTo run the new version, just start $SCRIPT_NAME again." exit 0 fi @@ -1106,7 +1106,7 @@ get_graphics_x_data() # new method added since radeon and X.org and the disappearance of version : ...etc # Later on, the normal textual version string returned, e.g. like: X.Org version: 6.8.2 # A failover mechanism is in place. (if $x_version is empty, the release number is parsed instead) - x_version=$( xdpyinfo | awk '/version:/ { print $NF }' ) + x_version=$( xdpyinfo | gawk '/version:/ { print $NF }' ) if [[ -z $x_version ]];then x_version=$(xdpyinfo | gawk -F': +' ' BEGIN { IGNORECASE=1 } @@ -1191,7 +1191,11 @@ get_hard_drive_data() hdd_cap1="$((disk_capacity/2))" fi # See http://lanana.org/docs/device-list/devices-2.6+.txt for major numbers used below - hdd_cap2=$( gawk '$1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {size+=$3} END {printf("%d\n",size)}' /proc/partitions ) + hdd_cap2=$( gawk ' + $1 ~ /^(3|22|33|8)$/ && $2 % 16 == 0 {size+=$3} + END { + printf("%d\n",size) + }' /proc/partitions ) ##print_screen_output "hdd_cap1=\"$hdd_cap1\" hdd_cap2=\"$hdd_cap2"" ; exit hdd_capacity=0 @@ -1201,6 +1205,9 @@ get_hard_drive_data() hdd_capacity="${!i}" fi done + +# echo "hdd_cap1=$hdd_cap1 hdd_cap2=$hdd_cap2" +# echo hdd_capacity $hdd_capacity if [[ $hdd_capacity -gt 0 ]];then hdd_used=$( df | gawk ' p { @@ -1223,8 +1230,10 @@ get_hard_drive_data() END { print c }' ) - hdd_used="$((hdd_used*100/hdd_capacity))% used" - hdd_capacity="$(($hdd_capacity*1024/1000**3))GB" + +# echo hdd_used $hdd_used + hdd_used="$(( hdd_used*100/hdd_capacity ))% used" + hdd_capacity="$(( $hdd_capacity*1024/1000**3 ))GB" else hdd_used='N/A' hdd_capacity='Unknown Capacity' @@ -1233,10 +1242,11 @@ get_hard_drive_data() A_HDD_DATA[1]=$hdd_capacity A_HDD_DATA[2]=$hdd_used } +# get_hard_drive_data;exit get_lspci_data() { - echo "$( lspci -v | awk '{ + echo "$( lspci -v | gawk '{ gsub(/\(prog-if[^)]*\)/,"") print }' )" @@ -1312,9 +1322,9 @@ get_partition_data() IFS=$'\n' # sample line: /dev/sda2 ext3 15G 8.9G 4.9G 65% /home # $NF = partition name; $(NF - 4) = partition size; $(NF - 3) = used, in gB; $(NF - 1) = percent used - ## note: by subtracting from the last field number NF, we avoid a subtle issue with df output, where if + ## note: by subtracting from the last field number NF, we avoid a subtle issue with LVM df output, where if ## the first field is too long, it will occupy its own line, this way we are getting only the needed data - A_PARTITION_DATA=( $( df -h -T | awk ' + A_PARTITION_DATA=( $( df -h -T | gawk ' /\/$|\/boot$|\/var$|\/home$/ { print $NF "," $(NF - 4) "," $(NF - 3) "," $(NF - 1) }' ) ) @@ -1342,12 +1352,12 @@ calculate_multicore_data() local string_number=$1 string_data='' if [[ -n $( egrep -i '( mb| kb)' <<< $1 ) ]];then - string_data=" $( awk '{print $2}' <<< $1 )" # add a space for output - string_number=$( awk '{print $1}' <<< $1 ) + string_data=" $( gawk '{print $2}' <<< $1 )" # add a space for output + string_number=$( gawk '{print $1}' <<< $1 ) fi # handle weird error cases where it's not a number if [[ -n $( egrep '^[0-9\.,]+$' <<< $string_number ) ]];then - string_number=$( echo $string_number $2 | awk '{total = $1*$2; print total}' ) + string_number=$( echo $string_number $2 | gawk '{total = $1*$2; print total}' ) elif [[ $string_number == '' ]];then string_number='Not Available' else @@ -1367,7 +1377,7 @@ process_cpu_flags() # sse, sse2, pni = sse1,2,3 gfx extensions # svm = AMD pacifica virtualization extensions # vmx = Intel IVT (vanderpool) virtualization extensions - cpu_flags=$( echo "$cpu_flags" | awk ' + cpu_flags=$( echo "$cpu_flags" | gawk ' BEGIN { RS=" " ssel["sse"] = 1 @@ -1636,8 +1646,7 @@ print_hard_disk_data() IFS="$ORIGINAL_IFS" partition_data="$partition_data ${C1}ID:${C2} ${a_partition_working[0]} ${C1}size:${C2} ${a_partition_working[1]} ${C1}used:${C2} ${a_partition_working[2]} (${a_partition_working[3]})" done - # hdd_data=$( create_print_line " " "${C1}Partition:${C2} ${root_home_data}" ) - hdd_data=$( create_print_line " " "${C1}Partition:${C2}${partition_data}" ) + hdd_data=$( create_print_line " " "${C1}Partition${C2}${partition_data}" ) print_screen_output "$hdd_data" fi }