From b383f601e403c19cfa4fc06a4a612972e185a3ef Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Thu, 5 Feb 2009 18:52:17 +0000 Subject: [PATCH] (version change) Hopefully close to last cleanup and tweaks before releasing 1.0.0, but we'll see if more features or fixes need to be implemented. --- inxi | 76 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/inxi b/inxi index bbe2988..3706fd3 100755 --- a/inxi +++ b/inxi @@ -1,8 +1,8 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 0.10.0 -#### Date: 4 February 2009 +#### version: 0.10.1 +#### Date: 5 February 2009 ######################################################################## #### SPECIAL THANKS ######################################################################## @@ -63,6 +63,8 @@ #### Do not use `....`, those are totally non-reabable, use $(....) #### Do not use one liner flow controls. The ONLY time you should use ; is in #### this single case: if [[ condition ]];then (ie, never: [[ condition ]] && statement) +#### Note: [[ -n $something ]] - double brackets do not require quotes: "$something" for variables +#### Always use quotes, double or single, for all string values #### #### All new code/methods must be in a function. #### For all boolean tests, use 'true' / 'false'. Do NOT use 0 or 1 unless @@ -288,7 +290,7 @@ DISTROS_LSB_GOOD="mandrake-release mandriva-release mandrakelinux-release" # user@host $ ARR=($'\x01'"one two" three four); echo ${ARR[0]} | hd -v # 00000000 01 01 6f 6e 65 20 74 77 6f 0a |..one two.| A_NORMAL_BANS=( corporation communications gmbh technologies technology group $'\2'"\" ltd. $'\2'"\" inc. $'\2'\ co. "(tm)" "(r)" $'\2'"\(rev ..\)" ) -A_CPU_BANS=( @ cpu deca 'dual core' 'tri core' 'quad core' ennea genuine hepta hexa multi octa penta 'processor' processor single triple $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" ) +A_CPU_BANS=( @ cpu deca 'dual core' dual-core 'tri core' tri-core 'quad core' quad-core ennea genuine hepta hexa multi octa penta 'processor' processor single triple $'\2'"[0-9.]+ *[MmGg][Hh][Zz]" ) # after processing, the ban arrays will be put into these: BAN_LIST_NORMAL='' BAN_LIST_CPU='' @@ -421,27 +423,27 @@ initialize_script_data() error_handler 6 fi - if [[ -e "$DIR_CPUINFO" ]]; then + if [[ -e $DIR_CPUINFO ]]; then B_CPUINFO='true' fi - if [[ -e "$DIR_MEMINFO" ]];then + if [[ -e $DIR_MEMINFO ]];then B_MEMINFO='true' fi - if [[ -e "$DIR_ASOUND_DEVICE" ]];then + if [[ -e $DIR_ASOUND_DEVICE ]];then B_ASOUND_CARDS='true' fi - if [[ -e "$DIR_ASOUND_VERSION" ]];then + if [[ -e $DIR_ASOUND_VERSION ]];then B_ASOUND_VERSION='true' fi - if [[ -f "$DIR_LSB_RELEASE" ]];then + if [[ -f $DIR_LSB_RELEASE ]];then B_LSB_DIR='true' fi - if [[ -e "$DIR_SCSI" ]];then + if [[ -e $DIR_SCSI ]];then B_SCSI_DIR='true' fi @@ -449,7 +451,7 @@ initialize_script_data() if [[ -x ifconfig ]]; then B_IFCONFIG='true' DIR_IFCONFIG='ifconfig' # change from full path to use $PATH - elif [[ -x "$DIR_IFCONFIG" ]];then + elif [[ -x $DIR_IFCONFIG ]];then B_IFCONFIG='true' else A_INTERFACES_DATA=( "Interfaces tool requires missing app: $DIR_IFCONFIG" ) @@ -459,15 +461,15 @@ initialize_script_data() B_X_RUNNING='true' fi - if [[ -e "$DIR_MODULES" ]];then + if [[ -e $DIR_MODULES ]];then B_MODULES_DIR='true' fi - if [[ -e "$DIR_MOUNTS" ]];then + if [[ -e $DIR_MOUNTS ]];then B_MOUNTS_DIR='true' fi - if [[ -e "$DIR_PARTITIONS" ]];then + if [[ -e $DIR_PARTITIONS ]];then B_PARTITIONS_DIR='true' fi } @@ -1241,7 +1243,7 @@ get_cmdline() ##print_screen_output "\$ppid='$ppid' -=- $(< /proc/$ppid/cmdline)" unset A_CMDL ## note: need to figure this one out, and ideally clean it up and make it readable - while read -d $'\0' L && [ "$i" -lt 32 ] + while read -d $'\0' L && [[ $i -lt 32 ]] do A_CMDL[i++]="$L" ## note: make sure this is valid - What does L mean? ## done < /proc/$ppid/cmdline @@ -2348,7 +2350,7 @@ get_partition_data() }' ) ) IFS="$ORIGINAL_IFS" - if [[ "$B_SHOW_LABELS" == 'true' || "$B_SHOW_UUIDS" == 'true' ]];then + if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then get_partition_data_advanced fi } @@ -2367,14 +2369,14 @@ get_partition_data_advanced() dev_disk_uuid="$( ls -l /dev/disk/by-uuid )" fi - if [[ "$B_MOUNTS_DIR" == 'true' ]];then + if [[ $B_MOUNTS_DIR == 'true' ]];then for (( i=0; i < ${#A_PARTITION_DATA[@]}; i++ )) do IFS="," a_partition_working=( ${A_PARTITION_DATA[i]} ) IFS="$ORIGINAL_IFS" # note: for swap this will already be set - if [[ -z "${a_partition_working[5]}" ]];then + if [[ -z ${a_partition_working[5]} ]];then mount_point=$( sed 's|/|\\/|g' <<< ${a_partition_working[0]} ) #echo mount_point $mount_point dev_partition_data=$( gawk ' @@ -2440,13 +2442,13 @@ get_partition_data_advanced() dev_uuid=${a_partition_working[7]} # first if the dev data/label data is incomplete, try to get missing piece - if [[ -n "$dev_disk_label" ]];then - if [[ -n "$dev_item" && -z "$dev_label" ]];then + if [[ -n $dev_disk_label ]];then + if [[ -n $dev_item && -z $dev_label ]];then dev_label=$( echo "$dev_disk_label" | gawk ' /'$dev_item'$/ { print $(NF - 2) }' ) - elif [[ -z "$dev_item" && -n "$dev_label" ]];then + elif [[ -z $dev_item && -n $dev_label ]];then dev_item=$( echo "$dev_disk_label" | gawk ' /'$dev_label'/ { item=gensub( /..\/..\/(.+)/, "\\1", 1, $NF ) @@ -2455,13 +2457,13 @@ get_partition_data_advanced() fi fi # then if dev data/uuid is incomplete, try to get missing piece - if [[ -n "$dev_disk_uuid" ]];then - if [[ -n "$dev_item" && -z "$dev_uuid" ]];then + if [[ -n $dev_disk_uuid ]];then + if [[ -n $dev_item && -z $dev_uuid ]];then dev_uuid=$( echo "$dev_disk_uuid" | gawk ' /'$dev_item'$/ { print $(NF - 2) }' ) - elif [[ -z "$dev_item" && -n "$dev_uuid" ]];then + elif [[ -z $dev_item && -n $dev_uuid ]];then dev_item=$( echo "$dev_disk_uuid" | gawk ' /'$dev_uuid'/ { item=gensub( /..\/..\/(.+)/, "\\1", 1, $NF ) @@ -2631,7 +2633,7 @@ print_short_data() local cpu_core_alpha=${A_CPU_CORE_DATA[1]} local cpu_type=${A_CPU_CORE_DATA[2]} - if [[ "$cpu_physical_count" -gt 1 ]];then + if [[ $cpu_physical_count -gt 1 ]];then cpc_plural='(s)' model_plural='s' cpu_count_print="$cpu_physical_count " @@ -2678,7 +2680,7 @@ print_short_data() for i in C1 C2 CN do ## these need to be in quotes, don't know why - if [[ "${!i}" == "$NORMAL" ]];then + if [[ ${!i} == $NORMAL ]];then declare $i="${!i}15,1" else declare $i="${!i},1" @@ -2806,7 +2808,7 @@ print_cpu_data() local cpu_core_alpha=${A_CPU_CORE_DATA[1]} local cpu_type=${A_CPU_CORE_DATA[2]} - if [[ "$cpu_physical_count" -gt 1 ]];then + if [[ $cpu_physical_count -gt 1 ]];then cpc_plural='(s)' cpu_count_print="$cpu_physical_count " model_plural='s' @@ -3190,7 +3192,7 @@ print_partition_data() if [[ $SCHEME -eq 0 ]];then line_max=75 fi - if [[ "$B_SHOW_LABELS" == 'true' || "$B_SHOW_UUIDS" == 'true' ]];then + if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then line_max=20 fi @@ -3204,20 +3206,20 @@ print_partition_data() IFS="$ORIGINAL_IFS" if [[ $B_SHOW_PARTITIONS_FULL == 'true' ]] || [[ ${a_partition_working[4]} == 'swap' || ${a_partition_working[4]} == 'main' ]];then - if [[ -n "${a_partition_working[2]}" ]];then + if [[ -n ${a_partition_working[2]} ]];then partition_used=" ${C1}used:${C2} ${a_partition_working[2]} (${a_partition_working[3]})" else partition_used='' # reset partition used to null fi - if [[ "${a_partition_working[4]}" == 'swap' ]];then + if [[ ${a_partition_working[4]} == 'swap' ]];then swap=" ${C1}swap:${C2}" else swap='' fi # don't show user names in output - if [[ "$B_SHOW_LABELS" == 'true' || "$B_SHOW_UUIDS" == 'true' ]];then - if [[ -n "${a_partition_working[5]}" ]];then - if [[ -z "$( grep '^//' <<< ${a_partition_working[5]} )" ]];then + if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then + if [[ -n ${a_partition_working[5]} ]];then + if [[ -z $( grep '^//' <<< ${a_partition_working[5]} ) ]];then part_dev="/dev/${a_partition_working[5]}" dev_remote='dev' else @@ -3228,16 +3230,16 @@ print_partition_data() part_dev='N/A' fi full_dev=" ${C1}$dev_remote:${C2} $part_dev" - if [[ "$B_SHOW_LABELS" == 'true' ]];then - if [[ -n "${a_partition_working[6]}" ]];then + if [[ $B_SHOW_LABELS == 'true' ]];then + if [[ -n ${a_partition_working[6]} ]];then part_label="${a_partition_working[6]}" else part_label='N/A' fi full_label=" ${C1}label:${C2} $part_label" fi - if [[ "$B_SHOW_UUIDS" == 'true' ]];then - if [[ -n "${a_partition_working[7]}" ]];then + if [[ $B_SHOW_UUIDS == 'true' ]];then + if [[ -n ${a_partition_working[7]} ]];then part_uuid="${a_partition_working[7]}" else part_uuid='N/A' @@ -3274,7 +3276,7 @@ print_system_data() local current_kernel=$( uname -rm ) # | gawk '{print $1,$3,$(NF-1)}' ) local distro="$( get_distro_data )" # check for 64 bit first - if [[ -n "$( uname -m | grep -o 'x86_64' )" ]];then + if [[ -n $( uname -m | grep -o 'x86_64' ) ]];then bits="(64 bit)" else bits="(32 bit)"