From 53e455c5eb200e91c05362f414ceaf35958d0629 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Wed, 26 Mar 2014 21:57:03 +0000 Subject: [PATCH] new version: this is only an optimization release, testing some slightly more efficient methods: something <<< $variable is signficantly slower than: echo $variable | something so I replaced almost all instances of <<< with echo ...| I've seen speed differences of up to 10% but it's not consistent, so this is just something to boost performance slightly on older systems I'd guess. --- inxi | 537 ++++++++++++++++++++++++------------------------- inxi.changelog | 18 ++ 2 files changed, 285 insertions(+), 270 deletions(-) diff --git a/inxi b/inxi index 3a1421c..a60dbcc 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/usr/bin/env bash ######################################################################## #### Script Name: inxi -#### Version: 2.1.11 +#### Version: 2.1.12 #### Date: 2014-03-26 #### Patch Number: 00 ######################################################################## @@ -1187,7 +1187,7 @@ select_default_color_scheme() print_lines_basic "0" "" "Global overrides all individual color schemes. Individual schemes remove the global setting." print_screen_output "$LINE1" read user_selection - if [[ -n $( grep -Es '^([0-9]+)$' <<< "$user_selection" ) && $user_selection -lt $i ]];then + if [[ "$user_selection" =~ ^([0-9]+)$ && $user_selection -lt $i ]];then case $COLOR_SELECTION in irc) config_variable='IRC_COLOR_SCHEME' @@ -1475,7 +1475,7 @@ script_self_updater() # then do the actual download if [[ $wget_error -eq 0 ]];then # make sure the whole file got downloaded and is in the variable - if [[ -n $( grep '###\*\*EOF\*\*###' <<< "$file_contents" ) ]];then + if [[ -n $( echo "$file_contents" | grep '###\*\*EOF\*\*###' ) ]];then echo "$file_contents" > $SCRIPT_PATH/$SCRIPT_NAME || error_handler 14 "$?" chmod +x $SCRIPT_PATH/$SCRIPT_NAME || error_handler 15 "$?" SCRIPT_VERSION_NUMBER=$( parse_version_data 'main' ) @@ -1634,8 +1634,8 @@ debug_data_collector() echo -e "ERROR: Failed to download required file: $xiin_file\nMaybe the remote site is down or your networking is broken?" echo "Continuing with incomplete data collection." echo "$xiin_file download failed and no existing $xiin_file" >> $debug_data_dir/xiin-error.txt - elif [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) || -f $xiin_file ]];then - if [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) ]];then + elif [[ -n $( echo "$xiin_download" | grep -s '# EOF' ) || -f $xiin_file ]];then + if [[ -n $( echo "$xiin_download" | grep -s '# EOF' ) ]];then echo "Updating $xiin_file from remote location" echo "$xiin_download" > $xiin_file else @@ -1968,34 +1968,34 @@ check_recommends_items() for item in $item_list do - if [[ $( awk -F ":" '{print NF-1}' <<< $item ) -eq 0 ]];then + if [[ $( echo $item | awk -F ":" '{print NF-1}' ) -eq 0 ]];then application=$item package='' feature='' location='' - elif [[ $( awk -F ":" '{print NF-1}' <<< $item ) -eq 1 ]];then - application=$( cut -d ':' -f 1 <<< $item ) + elif [[ $( echo $item | awk -F ":" '{print NF-1}' ) -eq 1 ]];then + application=$( echo $item | cut -d ':' -f 1 ) package='' - feature=$( cut -d ':' -f 2 <<< $item ) + feature=$( echo $item | cut -d ':' -f 2 ) location='' else - application=$( cut -d ':' -f 1 <<< $item ) - package=$( cut -d ':' -f 2 <<< $item ) + application=$( echo $item | cut -d ':' -f 1 ) + package=$( echo $item | cut -d ':' -f 2 ) location=$( type -p $application ) - if [[ $( awk -F ":" '{print NF-1}' <<< $item ) -eq 2 ]];then - feature=$( cut -d ':' -f 3 <<< $item ) + if [[ $( echo $item | awk -F ":" '{print NF-1}' ) -eq 2 ]];then + feature=$( echo $item | cut -d ':' -f 3 ) else feature='' fi fi if [[ -n $feature ]];then - print_string="$item_string$application (info: $( sed 's/_/ /g' <<< $feature ))" + print_string="$item_string$application (info: $( echo $feature | sed 's/_/ /g' ))" else print_string="$item_string$application" fi - starter="$( sed -e :a -e 's/^.\{1,'$width'\}$/&./;ta' <<< $print_string )" - if [[ -z $( grep '^/' <<< $application ) && -n $location ]] || [[ -d $application ]];then + starter="$( echo $print_string | sed -e :a -e 's/^.\{1,'$width'\}$/&./;ta' )" + if [[ -z $( echo $application | grep '^/' ) && -n $location ]] || [[ -d $application ]];then if [[ -n $location ]];then finisher=" $location" else @@ -2014,13 +2014,13 @@ check_recommends_items() echo "The following $type are missing from your system:" for item in $missing_items do - application=$( cut -d ':' -f 1 <<< $item ) + application=$( echo $item | cut -d ':' -f 1 ) if [[ $type == 'applications' ]];then echo - package=$( cut -d ':' -f 2 <<< $item ) - package_deb=$( cut -d '~' -f 1 <<< $package ) - package_pacman=$( cut -d '~' -f 2 <<< $package ) - package_rpm=$( cut -d '~' -f 3 <<< $package ) + package=$( echo $item | cut -d ':' -f 2 ) + package_deb=$( echo $package | cut -d '~' -f 1 ) + package_pacman=$( echo $package | cut -d '~' -f 2 ) + package_rpm=$( echo $package | cut -d '~' -f 3 ) echo "Application: $application" print_lines_basic "0" "" "To add to your system, install the proper distribution package for your system:" print_lines_basic "0" "" "Debian/Ubuntu:^$package_deb^:: Arch Linux:^$package_pacman^:: Redhat/Fedora/Suse:^$package_rpm" @@ -2032,7 +2032,7 @@ check_recommends_items() print_lines_basic "0" "" "These directories are created by the kernel, so don't worry if they are not present." fi else - echo "All the $( cut -d ' ' -f 1 <<< $item_string | sed -e 's/Re/re/' -e 's/Sy/sy/' ) $type are present." + echo "All the $( echo $item_string | cut -d ' ' -f 1 | sed -e 's/Re/re/' -e 's/Sy/sy/' ) $type are present." fi echo $Line } @@ -2057,7 +2057,7 @@ print_screen_output() if [[ $DEBUG -gt 5 ]];then if [[ $KONVI -eq 1 ]];then # konvi doesn't seem to like \n characters, it just prints them literally - # print_data="$( tr '\n' ' ' <<< "$print_data" )" + # print_data="$( echo "$print_data" | tr '\n' ' ' )" # dcop "$DCPORT" "$DCOPOBJ" say "$DCSERVER" "$DCTARGET" "konvi='$KONVI' saying : '$print_data'" print_data="KP-$KONVI: $print_data" elif [[ $KONVI -eq 2 ]];then @@ -2070,7 +2070,7 @@ print_screen_output() fi if [[ $KONVI -eq 1 && $B_DCOP == 'true' ]]; then ## dcop Konversation (<= 1.1 (qt3)) # konvi doesn't seem to like \n characters, it just prints them literally - $print_data="$( tr '\n' ' ' <<< "$print_data" )" + $print_data="$( echo "$print_data" | tr '\n' ' ' )" dcop "$DCPORT" "$DCOPOBJ" say "$DCSERVER" "$DCTARGET" "$print_data" elif [[ $KONVI -eq 3 && $B_QDBUS == 'true' ]]; then ## dbus Konversation (> 1.2 (qt4)) qdbus org.kde.konversation /irc say "$DCSERVER" "$DCTARGET" "$print_data" @@ -2162,7 +2162,7 @@ get_parameters() B_SHOW_NETWORK='true' B_SHOW_SYSTEM='true' ;; - c) if [[ -n $( grep -E '^[0-9][0-9]?$' <<< $OPTARG ) ]];then + c) if [[ $OPTARG =~ ^[0-9][0-9]?$ ]];then case $OPTARG in 99) B_RUN_COLOR_SELECTOR='true' @@ -2283,15 +2283,15 @@ get_parameters() S) B_SHOW_SYSTEM='true' use_short='false' ;; - t) if [[ -n $( grep -E '^(c|m|cm|mc)([1-9]|1[0-9]|20)?$' <<< $OPTARG ) ]];then + t) if [[ $OPTARG =~ ^(c|m|cm|mc)([1-9]|1[0-9]|20)?$ ]];then use_short='false' - if [[ -n $( grep -E '[0-9]+' <<< $OPTARG ) ]];then - PS_COUNT=$( sed 's/[^0-9]//g' <<< $OPTARG ) + if [[ -n $( echo $OPTARG | grep -E '[0-9]+' ) ]];then + PS_COUNT=$( echo $OPTARG | sed 's/[^0-9]//g' ) fi - if [[ -n $( grep 'c' <<< $OPTARG ) ]];then + if [[ -n $( echo $OPTARG | grep 'c' ) ]];then B_SHOW_PS_CPU_DATA='true' fi - if [[ -n $( grep 'm' <<< $OPTARG ) ]];then + if [[ -n $( echo $OPTARG | grep 'm' ) ]];then B_SHOW_PS_MEM_DATA='true' fi else @@ -2302,7 +2302,7 @@ get_parameters() B_SHOW_PARTITIONS='true' use_short='false' ;; - v) if [[ -n $( grep -E "^[0-9][0-9]?$" <<< $OPTARG ) && $OPTARG -le $VERBOSITY_LEVELS ]];then + v) if [[ $OPTARG =~ ^[0-9][0-9]?$ && $OPTARG -le $VERBOSITY_LEVELS ]];then if [[ $OPTARG -ge 1 ]];then use_short='false' B_SHOW_BASIC_CPU='true' @@ -2361,8 +2361,8 @@ get_parameters() w) B_SHOW_WEATHER=true use_short='false' ;; - W) ALTERNATE_WEATHER_LOCATION=$( sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<< $OPTARG ) - if [[ -n $( grep -Esi '([^,]+,.+|[0-9-]+)' <<< $ALTERNATE_WEATHER_LOCATION ) ]];then + W) ALTERNATE_WEATHER_LOCATION=$( echo $OPTARG | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' ) + if [[ -n $( echo $ALTERNATE_WEATHER_LOCATION | grep -Esi '([^,]+,.+|[0-9-]+)' ) ]];then B_SHOW_WEATHER=true use_short='false' else @@ -2391,7 +2391,7 @@ get_parameters() ## debuggers and testing tools %) B_HANDLE_CORRUPT_DATA='true' ;; - @) if [[ -n $( grep -E "^([1-9]|1[0-4])$" <<< $OPTARG ) ]];then + @) if [[ -n $( echo $OPTARG | grep -E "^([1-9]|1[0-4])$" ) ]];then DEBUG=$OPTARG if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then B_UPLOAD_DEBUG_DATA='true' @@ -2714,7 +2714,7 @@ print_lines_basic() else indent_working=$temp_count #$(( $temp_count + 1 )) fi - line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" <<< $2 )" + line_1_starter="$( echo $2 | sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" )" ;; # first left pad 2 and 3, then right pad them 2) indent_full=$(( $indent_main + 6 )) @@ -2727,8 +2727,8 @@ print_lines_basic() indent_working=$(( $temp_count + 1 )) #indent_working_full=$(( $indent_full - $indent_inner - 1 )) fi - line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" <<< $2 )" - line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_full\}$/ &/;ta" <<< "$line_1_starter" )" + line_1_starter="$( echo $2 | sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" )" + line_1_starter="$( echo "$line_1_starter" | sed -e :a -e "s/^.\{1,$indent_full\}$/ &/;ta" )" ;; 3) indent_full=$(( $indent_main + 8 )) indent_inner=3 @@ -2738,8 +2738,8 @@ print_lines_basic() else indent_working=$(( $temp_count + 1 )) fi - line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" <<< $2 )" - line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_full\}$/ &/;ta" <<< "$line_1_starter" )" + line_1_starter="$( echo $2 | sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" )" + line_1_starter="$( echo "$line_1_starter" | sed -e :a -e "s/^.\{1,$indent_full\}$/ &/;ta" )" ;; # for long options 4) indent_full=$(( $indent_main + 8 )) @@ -2749,7 +2749,7 @@ print_lines_basic() else indent_working=$temp_count #$(( $temp_count + 1 )) fi - line_1_starter="$( sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" <<< $2 )" + line_1_starter="$( echo $2 | sed -e :a -e "s/^.\{1,$indent_working\}$/& /;ta" )" ;; esac @@ -2813,7 +2813,7 @@ print_version_info() local script_path=$SCRIPT_PATH script_symbolic_start='' if [[ $script_path == '.' ]];then script_path=$( pwd ) - elif [[ -z $( grep '^/' <<< "$script_path" ) ]];then + elif [[ -z $( echo "$script_path" | grep '^/' ) ]];then script_path="$( pwd )/$script_path" fi # handle if it's a symbolic link, rare, but can happen with script directories in irc clients @@ -2824,7 +2824,7 @@ print_version_info() script_path=$( dirname $script_path ) fi local last_modified=$( parse_version_data 'date' ) - local year_modified=$( gawk '{print $NF}' <<< "$last_modified" ) + local year_modified=$( echo "$last_modified" | gawk '{print $NF}' ) print_screen_output "$SCRIPT_NAME $SCRIPT_VERSION_NUMBER-$SCRIPT_PATCH_NUMBER ($last_modified)" if [[ $B_IRC == 'false' ]];then @@ -2995,7 +2995,7 @@ get_irc_client_version() file_data="$( cat ~/.config/hexchat/xchat.conf )" fi if [[ -n $file_data ]];then - IRC_CLIENT_VERSION=$( gawk ' + IRC_CLIENT_VERSION=$( echo "$file_data" | gawk ' BEGIN { IGNORECASE=1 FS="=" @@ -3005,7 +3005,7 @@ get_irc_client_version() gsub(/[[:space:]]*/, "", $2 ) print $2 exit # usually this is the first line, no point in continuing - }' <<< "$file_data" ) + }' ) IRC_CLIENT_VERSION=" $IRC_CLIENT_VERSION" else @@ -3470,9 +3470,9 @@ get_audio_usb_data() # find the contents of usbid in lsusb and print everything after the 7th word on the # corresponding line. Finally, strip out commas as they will change the driver :) usb_id=$( cat $usb_proc_file/usbid ) - usb_data=$( grep "$usb_id" <<< "$lsusb_data" ) + usb_data=$( echo "$lsusb_data" | grep "$usb_id" ) if [[ -n $usb_data && -n $usb_id ]];then - usb_data=$( gawk ' + usb_data=$( echo "$usb_data" | gawk ' BEGIN { IGNORECASE=1 string="" @@ -3490,7 +3490,7 @@ get_audio_usb_data() sub(/:/,"", $4) print string ",USB Audio,,," $2 "-" $4 "," $6 } - }' <<< "$usb_data" ) + }' ) fi # this method is interesting, it shouldn't work but it does #A_AUDIO_DATA=( "${A_AUDIO_DATA[@]}" "$usb_data,USB Audio,," ) @@ -3573,13 +3573,13 @@ get_cpu_core_count() if [[ $BSD_VERSION == 'openbsd' ]];then gawk_fs='=' fi - cpu_core_count=$( gawk -F "$gawk_fs" ' + cpu_core_count=$( echo "$Sysctl_a_Data" | gawk -F "$gawk_fs" ' # note: on openbsd can also be hw.ncpufound so exit after first /^hw.ncpu/ { print $NF exit - }' <<< "$Sysctl_a_Data" ) - if [[ -n $( grep -E '^[0-9]+$' <<< "$cpu_core_count" ) ]];then + }' ) + if [[ $cpu_core_count =~ ^[0-9]+$ ]];then cpu_alpha_count=$( get_cpu_core_count_alpha "$cpu_core_count" ) if [[ $cpu_core_count -gt 1 ]];then cpu_type='SMP' @@ -3763,8 +3763,7 @@ get_cpu_data_bsd() # might be cases where the dmesg boot file was readable but sysctl perms failed if [[ -n $Sysctl_a_Data || -n $bsd_cpu_flags ]];then IFS=$'\n' - A_CPU_DATA=( $( - gawk -F "$gawk_fs" -v cpuFlags="$bsd_cpu_flags" ' + A_CPU_DATA=( $( echo "$Sysctl_a_Data" | gawk -F "$gawk_fs" -v cpuFlags="$bsd_cpu_flags" ' BEGIN { IGNORECASE=1 cpuModel="" @@ -3794,7 +3793,7 @@ get_cpu_data_bsd() END { print cpuModel "," cpuClock "," cpuCache "," cpuFlags "," cpuBogomips "," cpuVendor print "N/A" - }' <<< "$Sysctl_a_Data" ) ) + }' ) ) IFS="$ORIGINAL_IFS" fi @@ -3808,7 +3807,7 @@ get_cpu_flags_bsd() local cpu_flags='' if [[ -n $Dmesg_Boot_Data ]];then - cpu_flags=$( gawk -F '=' ' + cpu_flags=$( echo "$Dmesg_Boot_Data" | gawk -F '=' ' BEGIN { IGNORECASE=1 cpuFlags="" @@ -3827,7 +3826,7 @@ get_cpu_flags_bsd() cpuFlags=tolower(cpuFlags) print cpuFlags exit - }' <<< "$Dmesg_Boot_Data" ) + }' ) fi echo $cpu_flags log_function_data "$cpu_flags" @@ -4019,12 +4018,12 @@ get_desktop_environment() if [[ $XDG_CURRENT_DESKTOP == 'KDE' || -n $KDE_SESSION_VERSION ]]; then # note the command is actually like, kded4 --version, so we construct it version_data=$( kded$KDE_SESSION_VERSION --version 2>/dev/null ) - version=$( grep -si '^KDE Development Platform:' <<< "$version_data" | gawk '{print $4}' ) + version=$( echo "$version_data" | grep -si '^KDE Development Platform:' | gawk '{print $4}' ) if [[ -z $version ]];then version=$KDE_SESSION_VERSION fi if [[ $B_EXTRA_DATA == 'true' ]];then - toolkit=$( grep -si '^Qt:' <<< "$version_data" | gawk '{print $2}' ) + toolkit=$( echo "$version_data" | grep -si '^Qt:' | gawk '{print $2}' ) if [[ -n $toolkit ]];then version="$version (Qt $toolkit)" fi @@ -4034,13 +4033,13 @@ get_desktop_environment() # src: http://humanreadable.nfshost.com/files/startkde elif [[ $KDE_FULL_SESSION == 'true' ]]; then version_data=$( kded --version 2>/dev/null ) - version=$( grep -si '^KDE:' <<< "$version_data" | gawk '{print $2}' ) + version=$( echo "$version_data" | grep -si '^KDE:' | gawk '{print $2}' ) # version=$( get_program_version 'kded' '^KDE:' '2' ) if [[ -z $version ]];then version='3.5' fi if [[ $B_EXTRA_DATA == 'true' ]];then - toolkit=$( grep -si '^Qt:' <<< "$version_data" | gawk '{print $2}' ) + toolkit=$( echo "$version_data" | grep -si '^Qt:' | gawk '{print $2}' ) if [[ -n $toolkit ]];then version="$version (Qt $toolkit)" fi @@ -4064,12 +4063,13 @@ get_desktop_environment() if [[ -z $desktop_environment ]];then if type -p xprop &>/dev/null;then xprop_root="$( xprop -root 2>/dev/null )" + # xprop_root="${xprop_root,,}" fi # note that cinnamon split from gnome, and and can now be id'ed via xprop, # but it will still trigger the next gnome true case, so this needs to go before gnome test # eventually this needs to be better organized so all the xprop tests are in the same # section, but this is good enough for now. - if [[ -n $xprop_root && -n $( grep -is '^_MUFFIN' <<< "$xprop_root" ) ]];then + if [[ -n $xprop_root && -n $( echo "$xprop_root" | grep -is '^_MUFFIN' ) ]];then version=$( get_program_version 'cinnamon' '^cinnamon' '2' ) # not certain cinn will always have version, so keep output right if not if [[ -n $version ]];then @@ -4082,7 +4082,7 @@ get_desktop_environment() fi fi desktop_environment="Cinnamon" - elif [[ -n $xprop_root && -n $( grep -is '^_MARCO' <<< "$xprop_root" ) ]];then + elif [[ -n $xprop_root && -n $( echo "$xprop_root" | grep -is '^_MARCO' ) ]];then version=$( get_program_version 'mate-about' '^MATE[[:space:]]DESKTOP' 'NF' ) # not certain cinn/mate will always have version, so keep output right if not if [[ -n $version ]];then @@ -4117,7 +4117,7 @@ get_desktop_environment() if [[ -n $xprop_root ]];then # String: "This is xfdesktop version 4.2.12" # alternate: xfce4-about --version > xfce4-about 4.10.0 (Xfce 4.10) - if [[ -n $( grep -Eis '\"xfce4\"' <<< "$xprop_root" ) ]];then + if [[ -n $( echo "$xprop_root" | grep -Eis '\"xfce4\"' ) ]];then version=$( get_program_version 'xfdesktop' 'xfdesktop[[:space:]]version' '5' ) # arch linux reports null, so use alternate if null if [[ -z $version ]];then @@ -4134,7 +4134,7 @@ get_desktop_environment() fi desktop_environment="Xfce" # when 5 is released, the string may need updating - elif [[ -n $( grep -is '\"xfce5\"' <<< "$xprop_root" ) ]];then + elif [[ -n $( echo "$xprop_root" | grep -is '\"xfce5\"' ) ]];then version=$( get_program_version 'xfdesktop' 'xfdesktop[[:space:]]version' '5' ) # arch linux reports null, so use alternate if null if [[ -z $version ]];then @@ -4150,23 +4150,23 @@ get_desktop_environment() fi fi desktop_environment="Xfce" - elif [[ -n $( grep -is 'BLACKBOX_PID' <<< "$xprop_root" ) ]];then - if [[ -n $( grep -is 'fluxbox' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$xprop_root" | grep -is 'BLACKBOX_PID' ) ]];then + if [[ -n $( echo "$Ps_aux_Data" | grep -is 'fluxbox' ) ]];then version=$( get_program_version 'fluxbox' '^fluxbox' '2' ) desktop_environment='Fluxbox' else desktop_environment='Blackbox' fi - elif [[ -n $( grep -is 'OPENBOX_PID' <<< "$xprop_root" ) ]];then + elif [[ -n $( echo "$xprop_root" | grep -is 'OPENBOX_PID' ) ]];then # note: openbox-lxde --version may be present, but returns openbox data version=$( get_program_version 'openbox' '^openbox' '2' ) if [[ $XDG_CURRENT_DESKTOP == 'LXDE' || \ - -n $( grep -is 'lxde' <<< "$Ps_aux_Data" ) ]];then + -n $( echo "$Ps_aux_Data" | grep -is 'lxde' ) ]];then if [[ -n $version ]];then version="(Openbox $version)" fi desktop_environment='LXDE' - elif [[ -n $( grep -is 'razor-desktop' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$Ps_aux_Data" | grep -is 'razor-desktop' ) ]];then if [[ -n $version ]];then version="(Openbox $version)" fi @@ -4174,24 +4174,24 @@ get_desktop_environment() else desktop_environment='Openbox' fi - elif [[ -n $( grep -is 'ICEWM' <<< "$xprop_root" ) ]];then + elif [[ -n $( echo "$xprop_root" | grep -is 'ICEWM' ) ]];then version=$( get_program_version 'icewm' '^icewm' '2' ) desktop_environment='IceWM' - elif [[ -n $( grep -is 'ENLIGHTENMENT' <<< "$xprop_root" ) ]];then + elif [[ -n $( echo "$xprop_root" | grep -is 'ENLIGHTENMENT' ) ]];then # no -v or --version but version is in xprop -root # ENLIGHTENMENT_VERSION(STRING) = "Enlightenment 0.16.999.49898" - version=$( grep -is 'ENLIGHTENMENT_VERSION' <<< "$xprop_root" | cut -d '"' -f 2 | gawk '{print $2}' ) + version=$( echo "$xprop_root" | grep -is 'ENLIGHTENMENT_VERSION' | cut -d '"' -f 2 | gawk '{print $2}' ) desktop_environment='Enlightenment' - elif [[ -n $( grep -is '^I3_' <<< "$xprop_root" ) ]];then + elif [[ -n $( echo "$xprop_root" | grep -is '^I3_' ) ]];then version=$( get_program_version 'i3' '^i3' '3' ) desktop_environment='i3' - elif [[ -n $( grep -is 'WINDOWMAKER' <<< "$xprop_root" ) ]];then + elif [[ -n $( echo "$xprop_root" | grep -is 'WINDOWMAKER' ) ]];then version=$( get_program_version 'wmaker' '^Window[[:space:]]*Maker' 'NF' ) if [[ -n $version ]];then version="$version " fi desktop_environment="WindowMaker" - elif [[ -n $( grep -is '^_WM2' <<< "$xprop_root" ) ]];then + elif [[ -n $( echo "$xprop_root" | grep -is '^_WM2' ) ]];then # note; there isn't actually a wm2 version available but error handling should cover it and return null # maybe one day they will add it? version=$( get_program_version 'wm2' '^wm2' 'NF' ) @@ -4200,7 +4200,7 @@ get_desktop_environment() version="$version " fi desktop_environment="WM2" - elif [[ -n $( grep -is 'herbstluftwm' <<< "$xprop_root" ) ]];then + elif [[ -n $( echo "$xprop_root" | grep -is 'herbstluftwm' ) ]];then version=$( get_program_version 'herbstluftwm' '^herbstluftwm' 'NF' ) if [[ -n $version ]];then version="$version " @@ -4211,37 +4211,37 @@ get_desktop_environment() # a few manual hacks for things that don't id with xprop, these are just good guesses # note that gawk is going to exit after first occurance of search string, so no need for extra if [[ -z $desktop_environment ]];then - if [[ -n $( grep -is 'fvwm-crystal' <<< "$Ps_aux_Data" ) ]];then + if [[ -n $( echo "$Ps_aux_Data" | grep -is 'fvwm-crystal' ) ]];then version=$( get_program_version 'fvwm' '^fvwm' '2' ) desktop_environment='FVWM-Crystal' - elif [[ -n $( grep -is 'fvwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$Ps_aux_Data" | grep -is 'fvwm' ) ]];then version=$( get_program_version 'fvwm' '^fvwm' '2' ) desktop_environment='FVWM' - elif [[ -n $( grep -is 'pekwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$Ps_aux_Data" | grep -is 'pekwm' ) ]];then version=$( get_program_version 'pekwm' '^pekwm' '3' ) desktop_environment='pekwm' - elif [[ -n $( grep -is 'awesome' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$Ps_aux_Data" | grep -is 'awesome' ) ]];then version=$( get_program_version 'awesome' '^awesome' '2' ) desktop_environment='Awesome' - elif [[ -n $( grep -is 'scrotwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$Ps_aux_Data" | grep -is 'scrotwm' ) ]];then version=$( get_program_version 'scrotwm' '^welcome.*scrotwm' '4' ) desktop_environment='Scrotwm' # no --version for this one - elif [[ -n $( grep -is 'spectrwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$Ps_aux_Data" | grep -is 'spectrwm' ) ]];then version=$( get_program_version 'spectrwm' '^spectrwm.*welcome.*spectrwm' '5' ) desktop_environment='Spectrwm' # no --version for this one - elif [[ -n $( grep -Eis '([[:space:]]|/)twm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$Ps_aux_Data" | grep -Eis '([[:space:]]|/)twm' ) ]];then desktop_environment='Twm' # no --version for this one - elif [[ -n $( grep -Eis '([[:space:]]|/)dwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$Ps_aux_Data" | grep -Eis '([[:space:]]|/)dwm' ) ]];then version=$( get_program_version 'dwm' '^dwm' '1' ) desktop_environment='dwm' - elif [[ -n $( grep -is 'wmii2' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$Ps_aux_Data" | grep -is 'wmii2' ) ]];then version=$( get_program_version 'wmii2' '^wmii2' '1' ) desktop_environment='wmii2' # note: in debian at least, wmii is actuall wmii3 - elif [[ -n $( grep -is 'wmii' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$Ps_aux_Data" | grep -is 'wmii' ) ]];then version=$( get_program_version 'wmii' '^wmii' '1' ) desktop_environment='wmii' - elif [[ -n $( grep -Eis '([[:space:]]|/)jwm' <<< "$Ps_aux_Data" ) ]];then + elif [[ -n $( echo "$Ps_aux_Data" | grep -Eis '([[:space:]]|/)jwm' ) ]];then version=$( get_program_version 'jwm' '^jwm' '2' ) desktop_environment='JWM' fi @@ -4291,7 +4291,7 @@ get_program_version() esac if [[ -n $version_data ]];then - version=$( gawk ' + version=$( echo "$version_data" | gawk ' BEGIN { IGNORECASE=1 } @@ -4301,7 +4301,7 @@ get_program_version() gsub(/(,|dwm-|wmii2-|wmii-|v|V|\(|\))/, "",$'$3') print $'$3' exit # quit after first match prints - }' <<< "$version_data" ) + }' ) fi echo $version } @@ -4383,7 +4383,7 @@ get_display_manager() local dm_id_list='entranced.pid gdm.pid gdm3.pid kdm.pid ldm.pid lightdm.pid lxdm.pid mdm.pid nodm.pid slim.lock tint2.pid wdm.pid xdm.pid' local dm_id='' dm='' separator='' # note we don't need to filter grep if we do it this way - local x_is_running=$( grep '/usr.*/X' <<< "$Ps_aux_Data" | grep -iv '/Xprt' ) + local x_is_running=$( echo "$Ps_aux_Data" | grep '/usr.*/X' | grep -iv '/Xprt' ) for dm_id in $dm_id_list do @@ -4397,7 +4397,7 @@ get_display_manager() # might add this in, but the rate of new dm's makes it more likely it's an unknown dm, so # we'll keep output to N/A if [[ -n $x_is_running && -z $dm ]];then - if [[ -n $( grep 'startx$' <<< "$Ps_aux_Data" ) ]];then + if [[ -n $( echo "$Ps_aux_Data" | grep 'startx$' ) ]];then dm='(startx)' fi fi @@ -4466,7 +4466,8 @@ get_distro_data() log_function_data "distro_file: $distro_file" # first test for the legacy antiX distro id file if [[ -e /etc/antiX ]];then - distro="$( grep -Eoi 'antix.*\.iso' <<< $( remove_erroneous_chars '/etc/antiX' ) | sed 's/\.iso//' )" + distro="$( echo $( remove_erroneous_chars '/etc/antiX' ) | \ + grep -Eoi 'antix.*\.iso' | sed 's/\.iso//' )" # this handles case where only one release/version file was found, and it's lsb-release. This would # never apply for ubuntu or debian, which will filter down to the following conditions. In general # if there's a specific distro release file available, that's to be preferred, but this is a good backup. @@ -4509,7 +4510,7 @@ get_distro_data() # this handles an arch bug where /etc/arch-release is empty and /etc/issue is corrupted # only older arch installs that have not been updated should have this fallback required, new ones use # os-release - if [[ -n $( grep -i 'arch linux' <<< $distro ) ]];then + if [[ -n $( echo $distro | grep -i 'arch linux' ) ]];then distro='Arch Linux' fi fi @@ -4533,7 +4534,8 @@ get_distro_data() # if the file was null but present, which can happen in some cases, then use the file name itself to # set the distro value. Why say unknown if we have a pretty good idea, after all? if [[ -n $distro_file ]] && [[ " $DISTROS_DERIVED $DISTROS_PRIMARY " == *" $distro_file "* ]];then - distro=$( sed $SED_RX -e 's/[-_]//' -e 's/(release|version)//' <<< $distro_file | sed $SED_RX 's/^([a-z])/\u\1/' ) + distro=$( echo $distro_file | sed $SED_RX -e 's/[-_]//' -e 's/(release|version)//' | \ + sed $SED_RX 's/^([a-z])/\u\1/' ) fi ## finally, if all else has failed, give up if [[ -z $distro ]];then @@ -4542,14 +4544,14 @@ get_distro_data() fi # final step cleanup of unwanted information # opensuse has the x86 etc type string in names, not needed as redundant since -S already shows that - distro=$( gawk ' + distro=$( echo $distro | gawk ' BEGIN { IGNORECASE=1 } { sub(/ *\(*(x86_64|i486|i586|i686|686|586|486)\)*/, "", $0) print $0 - }' <<< $distro ) + }' ) echo "$distro" log_function_data "distro: $distro" eval $LOGFE @@ -4839,11 +4841,11 @@ get_gcc_system_version() for item in $gcc_others do item=${item##*/} - gcc_installed=$( gawk -F '-' ' + gcc_installed=$( echo $item | gawk -F '-' ' $2 ~ /^[0-9\.]+$/ { print $2 - }' <<< $item ) - if [[ -n $gcc_installed && -z $( grep "^$gcc_installed" <<< $gcc_version ) ]];then + }' ) + if [[ -n $gcc_installed && -z $( echo $gcc_version | grep "^$gcc_installed" ) ]];then gcc_list=$gcc_list$separator$gcc_installed separator=',' fi @@ -4896,7 +4898,7 @@ get_gpu_temp_data() END { print gpuTemp }' ) - screen_nu=$( cut -d ':' -f 2 <<< $screen_nu ) + screen_nu=$( echo $screen_nu | cut -d ':' -f 2 ) gpu_temp="$gpu_temp$screen_nu:$gpu_temp_looper " done elif type -p aticonfig &>/dev/null;then @@ -4915,12 +4917,11 @@ get_gpu_temp_data() } END { print gpuTemp - }' ) + }' ) # this handles some newer cases of free driver temp readouts, will require modifications as # more user data appears. elif [[ -n $Sensors_Data ]];then - gpu_temp=$( - gawk ' + gpu_temp=$( echo "$Sensors_Data" | gawk ' BEGIN { IGNORECASE=1 gpuTemp="" @@ -4938,7 +4939,7 @@ get_gpu_temp_data() } END { print gpuTemp - }' <<< "$Sensors_Data" ) + }' ) fi if [[ -n $gpu_temp ]];then @@ -4971,7 +4972,7 @@ get_graphics_card_data() local i='' a_temp='' IFS=$'\n' - A_GRAPHICS_CARD_DATA=( $( gawk -F': ' ' + A_GRAPHICS_CARD_DATA=( $( echo "$Lspci_v_Data" | gawk -F': ' ' BEGIN { IGNORECASE=1 busId="" @@ -4992,7 +4993,7 @@ get_graphics_card_data() if ( trueCard == 0 ) { print $NF "," busId } - }' <<< "$Lspci_v_Data" ) ) + }' ) ) IFS="$ORIGINAL_IFS" # for (( i=0; i < ${#A_GRAPHICS_CARD_DATA[@]}; i++ )) # do @@ -5148,7 +5149,7 @@ get_graphics_res_data() # Added the two ?'s , because the resolution is now reported without spaces around the 'x', as in # 1400x1050 instead of 1400 x 1050. Change as of X.org version 1.3.0 xdpy_data="$( xdpyinfo )" - xdpy_count=$( grep -c 'dimensions' <<< "$xdpy_data" ) + xdpy_count=$( echo "$xdpy_data" | grep -c 'dimensions' ) # we get a bit more info from xrandr than xdpyinfo, but xrandr fails to handle # multiple screens from different video cards if [[ $xdpy_count -eq 1 ]];then @@ -5168,7 +5169,7 @@ get_graphics_res_data() }' ) fi if [[ -z $screen_resolution || $xdpy_count -gt 1 ]];then - screen_resolution=$( gawk ' + screen_resolution=$( echo "$xdpy_data" | gawk ' BEGIN { IGNORECASE=1 screens = "" @@ -5181,7 +5182,7 @@ get_graphics_res_data() } END { print screens - }' <<< "$xdpy_data" ) + }' ) fi else if [[ $B_PROC_DIR == 'true' && -z $BSD_TYPE ]];then @@ -5265,7 +5266,7 @@ get_graphics_display_server_data() # some distros, like fedora, report themselves as the xorg vendor, so quick check # here to make sure the vendor string includes Xorg in string - if [[ -z $( grep -E '(X|xorg|x\.org)' <<< $vendor ) ]];then + if [[ -z $( echo $vendor | grep -E '(X|xorg|x\.org)' ) ]];then vendor="$vendor X.org" fi IFS="$ORIGINAL_IFS" @@ -5300,8 +5301,7 @@ get_graphics_display_server_version() x_data="$( Xorg -version 2>&1)" fi if [[ -n $x_data ]];then - version=$( - gawk ' + version=$( echo "$x_data" | gawk ' BEGIN { IGNORECASE=1 } @@ -5312,7 +5312,7 @@ get_graphics_display_server_version() /^X Window System Version/ { print $5 exit - }' <<< "$x_data" ) + }' ) fi echo $version log_function_data " version: $version" @@ -5470,14 +5470,14 @@ get_hard_drive_data_advanced() ## check for all ide type drives, non libata, only do it if hdx is in array ## this is now being updated for new /sys type paths, this may handle that ok too - if [[ -n $( grep -E 'hd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then + if [[ -n $( echo ${A_HDD_DATA[@]} | grep -E 'hd[a-z]' ) ]];then # remember, we're using the last array item to store the total size of disks for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ )) do IFS="," a_temp_working=( ${A_HDD_DATA[i]} ) IFS="$ORIGINAL_IFS" - if [[ -n $( grep -E '^hd[a-z]' <<< ${a_temp_working[0]} ) ]];then + if [[ -n $( echo ${a_temp_working[0]} | grep -E '^hd[a-z]' ) ]];then if [[ -e /proc/ide/${a_temp_working[0]}/model ]];then a_temp_working[2]="$( remove_erroneous_chars /proc/ide/${a_temp_working[0]}/model )" else @@ -5532,13 +5532,13 @@ get_hard_drive_data_advanced() IFS="$ORIGINAL_IFS" ## then we'll loop through that array looking for matches. - if [[ -n $( grep -E 'sd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then + if [[ -n $( echo ${A_HDD_DATA[@]} | grep -E 'sd[a-z]' ) ]];then # first pack the main ls variable so we don't have to keep using ls /dev... # not all systems have /dev/disk/by-id ls_disk_by_id="$( ls -l /dev/disk/by-id 2>/dev/null )" for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ )) do - if [[ -n $( grep -E '^sd[a-z]' <<< ${A_HDD_DATA[$i]} ) ]];then + if [[ -n $( echo ${A_HDD_DATA[$i]} | grep -E '^sd[a-z]' ) ]];then IFS="," a_temp_working=( ${A_HDD_DATA[$i]} ) IFS="$ORIGINAL_IFS" @@ -5546,16 +5546,15 @@ get_hard_drive_data_advanced() # this is handles the new /sys data types first if [[ -e /sys/block/${a_temp_working[0]}/device/model ]];then temp_name="$( remove_erroneous_chars /sys/block/${a_temp_working[0]}/device/model )" - temp_name=$( tr ' ' '_' <<< $temp_name | cut -d '-' -f 1 ) + temp_name=$( echo $temp_name | tr ' ' '_' | cut -d '-' -f 1 ) elif [[ ${#a_temp_scsi[@]} -gt 0 ]];then for (( j=0; j < ${#a_temp_scsi[@]}; j++ )) do ## ok, ok, it's incomprehensible, search /dev/disk/by-id for a line that contains the # discovered disk name AND ends with the correct identifier, sdx # get rid of whitespace for some drive names and ids, and extra data after - in name - temp_name=$( tr ' ' '_' <<< ${a_temp_scsi[$j]} | cut -d '-' -f 1 ) - sd_ls_by_id=$( grep -Em1 ".*$temp_name.*${a_temp_working[0]}$" <<< "$ls_disk_by_id" ) - + temp_name=$( echo ${a_temp_scsi[$j]} | tr ' ' '_' | cut -d '-' -f 1 ) + sd_ls_by_id=$( echo "$ls_disk_by_id" | grep -Em1 ".*$temp_name.*${a_temp_working[0]}$" ) if [[ -n $sd_ls_by_id ]];then temp_name=${a_temp_scsi[$j]} break @@ -5571,7 +5570,7 @@ get_hard_drive_data_advanced() if [[ -z $temp_name ]];then temp_name="Name n/a" else - usb_exists=$( grep -Em1 "usb-.*$temp_name.*${a_temp_working[0]}$" <<< "$ls_disk_by_id" ) + usb_exists=$( echo "$ls_disk_by_id" | grep -Em1 "usb-.*$temp_name.*${a_temp_working[0]}$" ) if [[ -n $usb_exists ]];then a_temp_working[3]='USB' fi @@ -5606,12 +5605,12 @@ get_hdd_serial_number() # lrwxrwxrwx 1 root root 9 Apr 26 09:32 scsi-SATA_ST3160827AS_5MT2HMH6 -> ../../sdc # exit on the first instance - hdd_serial=$( gawk ' + hdd_serial=$( echo "$DEV_DISK_ID" | gawk ' /'$1'$/ { serial=gensub( /^(.+)_([^_]+)$/, "\\2", 1, $9 ) print serial exit - }' <<< "$DEV_DISK_ID" ) + }' ) echo $hdd_serial log_function_data "hdd serial: $hdd_serial" @@ -5643,7 +5642,7 @@ get_hdd_temp_data() fi # this will fail if regular user and no sudo present, but that's fine, it will just return null hdd_temp=$( eval $sudo_command $HDDTEMP_PATH -nq -u C $1 ) - if [[ -n $hdd_temp && -n $( grep -E '^([0-9\.]+)$' <<< $hdd_temp ) ]];then + if [[ -n $hdd_temp && -n $( echo $hdd_temp | grep -E '^([0-9\.]+)$' ) ]];then echo $hdd_temp fi fi @@ -5694,14 +5693,14 @@ get_init_data() strings_init_version="$( strings /sbin/init | grep -E 'version[[:space:]]+[0-9]' )" fi if [[ -n $strings_init_version ]];then - init_version=$( gawk '{print $2}' <<< "$strings_init_version" ) + init_version=$( echo "$strings_init_version" | gawk '{print $2}' ) fi # freebsd at least elif [[ -f /etc/ttys ]];then init_type='init (bsd)' fi - if [[ -n $( grep 'openrc' <<< "$ls_run" ) ]];then + if [[ -n $( echo "$ls_run" | grep 'openrc' ) ]];then rc_type='OpenRC' # /sbin/openrc --version == openrc (OpenRC) 0.13 if type -p openrc &>/dev/null;then @@ -5784,12 +5783,12 @@ get_lspci_chip_id() local chip_id='' - chip_id=$( gawk ' + chip_id=$( echo "$Lspci_n_Data" | gawk ' /^'$1'/ { if ( $3 != "" ) { print $3 } - }' <<< "$Lspci_n_Data" ) + }' ) echo $chip_id @@ -5845,11 +5844,11 @@ get_machine_data() if [[ -n $DMIDECODE_DATA ]];then if [[ $B_ROOT == 'true' ]];then # this handles very old systems, like Lenny 2.6.26, with dmidecode, but no data - if [[ -n $( grep -i 'no smbios ' <<< "$DMIDECODE_DATA" ) ]];then + if [[ -n $( echo "$DMIDECODE_DATA" | grep -i 'no smbios ' ) ]];then array_string='dmidecode-no-smbios-dmi-data' # please note: only dmidecode version 2.11 or newer supports consistently the -s flag else - array_string=$( gawk -F ':' ' + array_string=$( echo "$DMIDECODE_DATA" | gawk -F ':' ' BEGIN { IGNORECASE=1 baseboardManufacturer="" @@ -5945,7 +5944,7 @@ get_machine_data() print fullString } - }' <<< "$DMIDECODE_DATA" ) + }' ) fi else array_string='dmidecode-non-root-user' @@ -5985,7 +5984,7 @@ get_memory_data() if [[ $BSD_VERSION == 'openbsd' ]];then gawk_fs='=' fi - memory=$( grep -i 'mem' <<< "$Sysctl_a_Data" | gawk -F "$gawk_fs" ' + memory=$( echo "$Sysctl_a_Data" | grep -i 'mem' | gawk -F "$gawk_fs" ' BEGIN { realMemory="" freeMemory="" @@ -6162,7 +6161,7 @@ get_network_advanced_data() oper_state='' usb_data='' chip_id='' - if [[ -z $( grep '^usb-' <<< ${a_network_adv_working[4]} ) ]];then + if [[ -z $( echo ${a_network_adv_working[4]} | grep '^usb-' ) ]];then # note although this may exist technically don't use it, it's a virtual path # and causes weird cat errors when there's a missing file as well as a virtual path # /sys/bus/pci/devices/0000:02:02.0/net/eth1 @@ -6186,8 +6185,8 @@ get_network_advanced_data() else # now we'll use the actual vendor:product string instead usb_data=${a_network_adv_working[10]} - usb_vendor=$( cut -d ':' -f 1 <<< $usb_data ) - usb_product=$( cut -d ':' -f 2 <<< $usb_data ) + usb_vendor=$( echo $usb_data | cut -d ':' -f 1 ) + usb_product=$( echo $usb_data | cut -d ':' -f 2 ) # this grep returns the path plus the contents of the file, with a colon separator, so slice that off # /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/idVendor working_path=$( grep -s "$usb_vendor" /sys/devices/pci*/*/usb*/*/*/idVendor | \ @@ -6239,7 +6238,7 @@ get_network_advanced_data() # 2.6.32 debian lenny kernel shows not: /net/eth0 but /net:eth0 else if_path=$( ls $working_path 2>/dev/null | grep 'net:' ) - if_id=$( cut -d ':' -f 2 <<< "$if_path" ) + if_id=$( echo "$if_path" | cut -d ':' -f 2 ) working_path=$working_path/$if_path fi log_function_data "POST: working_path: $working_path\nif_path: $if_path - if_id: $if_id" @@ -6287,8 +6286,7 @@ get_networking_usb_data() # corresponding line. Finally, strip out commas as they will change the driver :) if [[ -n $lsusb_data ]];then IFS=$'\n' - a_usb=( $( - gawk ' + a_usb=( $( echo "$lsusb_data" | gawk ' BEGIN { IGNORECASE=1 string="" @@ -6311,7 +6309,7 @@ get_networking_usb_data() sub(/:/, "", $4 ) print string ",,,,usb-" $2 "-" $4 ",,,,,," $6 } - }' <<< "$lsusb_data" ) ) + }' ) ) IFS="$ORIGINAL_IFS" if [[ ${#a_usb[@]} -gt 0 ]];then array_count=${#A_NETWORK_DATA[@]} @@ -6349,8 +6347,8 @@ get_networking_wan_ip_data() # validate the data if [[ -z $ip ]];then ip='None Detected!' - elif [[ -z $( grep -Es \ - '^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4})$' <<< $ip ) ]];then + elif [[ -z $( echo $ip | grep -Es \ + '^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4}:[[:alnum:]]{0,4})$' ) ]];then ip='IP Source Corrupt!' fi echo "$ip" @@ -6390,8 +6388,7 @@ get_networking_local_ip_data() A_INTERFACES_DATA=( "Interfaces program 'ip' missing. Please check: $SCRIPT_NAME --recommends" ) elif [[ -n "$ip_tool_data" ]];then IFS=$'\n' # $ip_tool_command - A_INTERFACES_DATA=( $( - gawk -v ipTool=$ip_tool -v bsdType=$BSD_TYPE ' + A_INTERFACES_DATA=( $( echo "$ip_tool_data" | gawk -v ipTool=$ip_tool -v bsdType=$BSD_TYPE ' BEGIN { IGNORECASE=1 interface="" @@ -6474,7 +6471,7 @@ get_networking_local_ip_data() } j++ } - }' <<< "$ip_tool_data" ) ) + }' ) ) IFS="$ORIGINAL_IFS" else A_INTERFACES_DATA=( "Interfaces program $ip_tool present but created no data. " ) @@ -6506,15 +6503,15 @@ get_optical_drive_data() disk=$working_disk fi disk=${disk##*/} # puppy shows this as /dev/sr0, not sr0 - # if [[ -z $dev_disks_real || -z $( grep $disk <<< $dev_disks_real ) ]];then - if [[ -n $disk && -z $( grep "$disk" <<< $dev_disks_real ) ]];then + # if [[ -z $dev_disks_real || -z $( echo $dev_disks_real | grep $disk ) ]];then + if [[ -n $disk && -z $( echo $dev_disks_real | grep "$disk" ) ]];then # need line break IFS for below, no white space dev_disks_real="$dev_disks_real$separator$disk" separator=$'\n' #separator=' ' fi done - dev_disks_real="$( sort -u <<< "$dev_disks_real" )" + dev_disks_real="$( echo "$dev_disks_real" | sort -u )" working_disk='' disk='' separator='' @@ -6566,7 +6563,7 @@ get_optical_drive_data() sys_path='' working_disk='' # this is only for new sd type paths in /sys, otherwise we'll use /proc/ide - if [[ -z $( grep '^hd' <<< $disk ) ]];then + if [[ -z $( echo $disk | grep '^hd' ) ]];then # maybe newer kernels use this, not enough data. sys_path=$( ls /sys/devices/pci*/*/ata*/host*/target*/*/block/$disk/uevent 2>/dev/null | sed "s|/block/$disk/uevent||" ) # maybe older kernels, this used to work (2014-03-16) @@ -6584,7 +6581,7 @@ get_optical_drive_data() vendor=$( cat /proc/ide/$disk/model 2>/dev/null ) fi if [[ -n $vendor ]];then - vendor=$( gawk ' + vendor=$( echo $vendor | gawk ' BEGIN { IGNORECASE=1 } @@ -6595,11 +6592,11 @@ get_optical_drive_data() gsub(/^[[:space:]]*|[[:space:]]*$/, "", $0) gsub(/ [[:space:]]+/, " ", $0) print $0 - }' <<< $vendor ) + }' ) fi # this needs to run no matter if there's proc data or not to create the array comma list if [[ $B_SHOW_FULL_OPTICAL == 'true' ]];then - proc_info_string=$( gawk -v diskId=$disk ' + proc_info_string=$( echo "$proc_cdrom" | gawk -v diskId=$disk ' BEGIN { IGNORECASE=1 position="" @@ -6651,8 +6648,7 @@ get_optical_drive_data() } END { print speed "," multisession "," mcn "," audio "," cdr "," cdrw "," dvd "," dvdr "," dvdram - } - ' <<< "$proc_cdrom" ) + }' ) fi item_string="$item_string,$vendor,$model,$rev_number,$proc_info_string,$state" echo $item_string @@ -6704,8 +6700,8 @@ get_partition_data() # new kernels/df have rootfs and / repeated, creating two entries for the same partition # so check for two string endings of / then slice out the rootfs one, I could check for it # before slicing it out, but doing that would require the same action twice re code execution - if [[ $( grep -cs '[[:space:]]/$' <<< "$main_partition_data" ) -gt 1 ]];then - main_partition_data="$( grep -vs '^rootfs' <<< "$main_partition_data" )" + if [[ $( echo "$main_partition_data" | grep -cs '[[:space:]]/$' ) -gt 1 ]];then + main_partition_data="$( echo "$main_partition_data" | grep -vs '^rootfs' )" fi log_function_data 'raw' "main_partition_data_post_rootfs:\n$main_partition_data\n\nswap_data:\n$swap_data" IFS=$'\n' @@ -6849,17 +6845,17 @@ get_partition_data() fs_type=${a_partition_working[5]} # older bsds have df minus -T so can't get fs type easily, try using mount instead if [[ $BSD_TYPE == 'bsd' && -z $fs_type && -n $dev_item ]];then - dev_bsd_item=$( sed -e 's/non-dev-//' -e 's|/|\\/|g' <<< "$dev_item" ) - fs_type=$( gawk -F '(' ' + dev_bsd_item=$( echo "$dev_item" | sed -e 's/non-dev-//' -e 's|/|\\/|g' ) + fs_type=$( echo "$mount_data" | gawk -F '(' ' /'$dev_bsd_item'/ { # slice out everything after / plus the first comma sub( /,.*/, "", $2 ) print $2 exit - }' <<< "$mount_data" ) + }' ) fi # note: for swap this will already be set - if [[ -n $( grep -E '(by-uuid|by-label)' <<< $dev_item ) ]];then + if [[ -n $( echo $dev_item | grep -E '(by-uuid|by-label)' ) ]];then dev_working_item=${dev_item##*/} if [[ -n $DEV_DISK_UUID ]];then dev_item=$( echo "$DEV_DISK_UUID" | gawk ' @@ -6878,7 +6874,7 @@ get_partition_data() exit }' ) fi - elif [[ -n $( grep 'mapper/' <<< $dev_item ) ]];then + elif [[ -n $( echo $dev_item | grep 'mapper/' ) ]];then # get the mapper actual dev item dev_item=$( get_dev_processed_item "$dev_item" ) fi @@ -6921,7 +6917,7 @@ get_partition_data_advanced() # note: for swap this will already be set if [[ -z ${a_partition_working[6]} ]];then - mount_point=$( sed 's|/|\\/|g' <<< ${a_partition_working[0]} ) + mount_point=$( echo ${a_partition_working[0]} | sed 's|/|\\/|g' ) #echo mount_point $mount_point dev_partition_data=$( gawk ' BEGIN { @@ -6973,7 +6969,7 @@ get_partition_data_advanced() } print partition "," label "," uuid exit - }' $FILE_MOUNTS ) + }' $FILE_MOUNTS ) # assemble everything we could get for dev/h/dx, label, and uuid IFS="," @@ -6987,7 +6983,7 @@ get_partition_data_advanced() # get the mapper actual dev item first, in case it's mapped dev_item=$( get_dev_processed_item "${a_partition_working[6]}" ) # make sure not to slice off rest if it's a network mounted file system - if [[ -n $dev_item && -z $( grep -E '(^//|:/)' <<< $dev_item ) ]];then + if [[ -n $dev_item && -z $( echo $dev_item | grep -E '(^//|:/)' ) ]];then dev_item=${dev_item##*/} ## needed to avoid error in case name still has / in it fi dev_label=${a_partition_working[7]} @@ -7018,7 +7014,7 @@ get_partition_data_advanced() fi # this can trigger all kinds of weird errors if it is a non /dev path, like: remote:/machine/name - if [[ -n $dev_item && -z $( grep -E '(^//|:/)' <<< $dev_item ) ]];then + if [[ -n $dev_item && -z $( echo $dev_item | grep -E '(^//|:/)' ) ]];then if [[ -n $DEV_DISK_UUID && -z $dev_uuid ]];then dev_uuid=$( echo "$DEV_DISK_UUID" | gawk ' /'$dev_item'$/ { @@ -7067,7 +7063,7 @@ get_partition_data_advanced_bsd() # no need to use the rest of the name if it's not a straight /dev/item dev_item=${a_partition_working[6]##*/} - label_uuid=$( gawk -F ':' ' + label_uuid=$( echo "$gpart_data" | gawk -F ':' ' BEGIN { IGNORECASE=1 label="" @@ -7086,7 +7082,7 @@ get_partition_data_advanced_bsd() } print label","uuid exit - }' <<< "$gpart_data" ) + }' ) # assemble everything we could get for dev/h/dx, label, and uuid IFS="," @@ -7160,7 +7156,7 @@ get_dev_processed_item() local dev_item=$1 dev_return='' - if [[ -n $DEV_DISK_MAPPER && -n $( grep -is 'mapper/' <<< $dev_item ) ]];then + if [[ -n $DEV_DISK_MAPPER && -n $( echo $dev_item | grep -is 'mapper/' ) ]];then dev_return=$( echo "$DEV_DISK_MAPPER" | gawk ' $( NF - 2 ) ~ /^'${dev_item##*/}'$/ { item=gensub( /..\/(.+)/, "\\1", 1, $NF ) @@ -7178,13 +7174,13 @@ get_dev_processed_item() get_patch_version_string() { - local patch_version_number=$( sed 's/^[0]*//' <<< $SCRIPT_PATCH_NUMBER ) + local patch_version_number=$( echo $SCRIPT_PATCH_NUMBER | sed 's/^[0]*//' ) if [[ -n $patch_version_number ]];then patch_version_number="-$patch_version_number" # for cases where it was for example: 00-bsd cleaned to --bsd trim out one - - if [[ -n $( grep '\--' <<< $patch_version_number ) ]];then - patch_version_number=$( sed 's/--/-/' <<< $patch_version_number ) + if [[ -n $( echo $patch_version_number | grep '\--' ) ]];then + patch_version_number=$( echo $patch_version_number | sed 's/--/-/' ) fi fi echo $patch_version_number @@ -7199,7 +7195,7 @@ get_pciconf_data() if [[ $B_PCICONF == 'true' ]];then pciconf_data="$( pciconf -lv 2>/dev/null )" if [[ -n $pciconf_data ]];then - pciconf_data=$( gawk ' + pciconf_data=$( echo "$pciconf_data" | gawk ' BEGIN { IGNORECASE=1 } @@ -7211,7 +7207,7 @@ get_pciconf_data() # line=gensub(/.*[[:space:]]+(class=[^[:space:]]*|card=[^[:space:]]*)|chip=[^[:space:]]*|rev=[^[:space:]]*|hdr=[^[:space:]]*).*/,"\n\\1","g",$0) line=gensub(/(.*@.*)/,"\n\\1",$0) print line - }' <<< "$pciconf_data" ) + }' ) # create empty last line with this spacing trick pciconf_data="$pciconf_data @@ -7219,7 +7215,7 @@ EOF" # echo "$pciconf_data" # now insert into arrays IFS=$'\n' - A_PCICONF_DATA=( $( gawk ' + A_PCICONF_DATA=( $( echo "$pciconf_data" | gawk ' BEGIN { fullLine="" driver="" @@ -7274,7 +7270,7 @@ EOF" } fullLine=class "," device "," vendor "," driver "," pciId "," chipId print fullLine - }' <<< "$pciconf_data" )) + }' )) IFS="$ORIGINAL_IFS" fi else @@ -7304,7 +7300,7 @@ get_pciconf_card_data() if [[ ${a_temp[0]} == $1 ]];then # don't print the vendor if it's already in the device name - if [[ -z $( grep -i "${a_temp[2]}" <<< "${a_temp[1]}" ) ]];then + if [[ -z $( echo "${a_temp[1]}" | grep -i "${a_temp[2]}" ) ]];then device_string="${a_temp[2]} ${a_temp[1]}" else device_string=${a_temp[1]} @@ -7348,10 +7344,10 @@ get_pciconf_card_data() }') fi if [[ -n $network_string ]];then - mac=$( cut -d '~' -f 3 <<< $network_string ) - state=$( cut -d '~' -f 1 <<< $network_string ) - speed=$( cut -d '~' -f 2 <<< $network_string ) - duplex=$( cut -d '~' -f 4 <<< $network_string ) + mac=$( echo $network_string | cut -d '~' -f 3 ) + state=$( echo $network_string | cut -d '~' -f 1 ) + speed=$( echo $network_string | cut -d '~' -f 2 ) + duplex=$( echo $network_string | cut -d '~' -f 4 ) fi array_string="$device_string,${a_temp[3]},,,${a_temp[4]},${a_temp[3]},$state,$speed,$duplex,$mac,${a_temp[5]}" A_NETWORK_DATA[j]=$array_string @@ -7473,15 +7469,14 @@ get_raid_data() if [[ -n $mdstat ]];then # need to make sure there's always a newline in front of each record type, and # also correct possible weird formats for the output from older kernels etc. - mdstat="$( sed -e 's/^md/\nmd/' -e 's/^unused[[:space:]]/\nunused /' \ + mdstat="$( echo "$mdstat" | sed -e 's/^md/\nmd/' -e 's/^unused[[:space:]]/\nunused /' \ -e 's/read_ahead/\nread_ahead/' -e 's/^resync=/\nresync=/' -e 's/^Event/\nEvent/' \ - -e 's/^[[:space:]]*$//' -e 's/[[:space:]]read_ahead/\nread_ahead/' <<< "$mdstat" )" + -e 's/^[[:space:]]*$//' -e 's/[[:space:]]read_ahead/\nread_ahead/' )" # some fringe cases do not end as expected, so need to add newlines plus EOF to make sure while loop doesn't spin mdstat=$( echo -e "$mdstat\n\nEOF" ) IFS=$'\n' - A_RAID_DATA=( $( - gawk ' + A_RAID_DATA=( $( echo "$mdstat" | gawk ' BEGIN { IGNORECASE=1 RS="\n" @@ -7593,8 +7588,7 @@ get_raid_data() raidString = raidString "," recoveryProgressBar "," recoveryPercent "," sectorsRecovered "," finishTime "," recoverSpeed print raidString - } - ' <<< "$mdstat" ) ) + }' ) ) IFS="$ORIGINAL_IFS" else if [[ $BSD_TYPE == 'bsd' ]];then @@ -7622,8 +7616,7 @@ get_raid_data_bsd() \1/' )" # echo "$zpool_data" IFS=$'\n' - A_RAID_DATA=( $( - gawk ' + A_RAID_DATA=( $( echo "$zpool_data" | gawk ' BEGIN { raidString="" separator="" @@ -7665,7 +7658,7 @@ get_raid_data_bsd() raidString = raidString "," sectorsRecovered "," finishTime "," recoverSpeed gsub(/~/,"",raidString) print raidString - }' <<< "$zpool_data" ) ) + }' ) ) IFS="$ORIGINAL_IFS" get_raid_component_data_bsd fi @@ -7694,7 +7687,7 @@ get_raid_component_data_bsd() # for print output display of issues with components for component in ${a_raid_data[3]} do - component_status=$( gawk ' + component_status=$( echo "$zpool_status" | gawk ' BEGIN { IGNORECASE=1 } @@ -7702,7 +7695,7 @@ get_raid_component_data_bsd() sub( /ONLINE/, "", $2 ) print "'$component'" $2 exit - }' <<< "$zpool_status" ) + }' ) component_string="$component_string$separator$component_status" separator=' ' done @@ -7835,7 +7828,7 @@ $repo_data_working" } ' $pacman_conf )" # sort into unique paths only, to be used to search for server = data - repo_data_working=$( sort -bu <<< "$repo_data_working" | uniq ) + repo_data_working=$( echo "$repo_data_working" | sort -bu | uniq ) repo_data_working="$repo_data_working $pacman_conf" for repo_file in $repo_data_working do @@ -7871,15 +7864,15 @@ $repo_data_working" # http://packages.pardus.org.tr/contrib-2009/pisi-index.xml.bz2 while read repo_line do - repo_line=$( gawk ' + repo_line=$( echo $repo_line | gawk ' { # need to dump leading/trailing spaces and clear out color codes for irc output sub(/^[[:space:]]+|[[:space:]]+$/,"",$0) # gsub(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/,"",$0) # leaving this pattern in case need it gsub(/\[([0-9];)?[0-9]+m/,"",$0) print $0 - }' <<< $repo_line ) - if [[ -n $( grep '://' <<< $repo_line ) ]];then + }' ) + if [[ -n $( echo $repo_line | grep '://' ) ]];then repo_data_working="$repo_data_working:$repo_line\n" else repo_data_working="${repo_data_working}pisi repo:$repo_line" @@ -7902,21 +7895,21 @@ $repo_data_working" # Nonfree Updates (Local19) /mnt/data/mirrors/mageia/distrib/cauldron/x86_64/media/nonfree/updates while read repo_line do - repo_line=$( gawk ' + repo_line=$( echo $repo_line | gawk ' { # need to dump leading/trailing spaces and clear out color codes for irc output sub(/^[[:space:]]+|[[:space:]]+$/,"",$0) # gsub(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/,"",$0) # leaving this pattern in case need it gsub(/\[([0-9];)?[0-9]+m/,"",$0) print $0 - }' <<< $repo_line ) + }' ) # urpmq output is the same each line, repo name space repo url, can be: # rsync://, ftp://, file://, http:// OR repo is locally mounted on FS in some cases - if [[ -n $( grep -E '(://|[[:space:]]/)' <<< $repo_line ) ]];then + if [[ -n $( echo $repo_line | grep -E '(://|[[:space:]]/)' ) ]];then # cut out the repo first - repo_data_working2=$( grep -Eo '([^[:space:]]+://|[[:space:]]/).*' <<< $repo_line ) + repo_data_working2=$( echo $repo_line | grep -Eo '([^[:space:]]+://|[[:space:]]/).*' ) # then get the repo name string by slicing out the url string - repo_name=$( sed "s|[[:space:]]*$repo_data_working2||" <<< $repo_line ) + repo_name=$( echo $repo_line | sed "s|[[:space:]]*$repo_data_working2||" ) repo_data_working="${repo_data_working}urpmq repo:$repo_name:$repo_data_working2\n" fi done <<< "$REPO_DATA" @@ -7996,8 +7989,7 @@ get_sensors_data() if [[ -n $Sensors_Data ]];then # note: non-configured sensors gives error message, which we need to redirect to stdout # also, -F ':' no space, since some cases have the data starting right after,like - :1287 - A_SENSORS_DATA=( $( - gawk -F ':' -v userCpuNo="$SENSORS_CPU_NO" ' + A_SENSORS_DATA=( $( echo "$Sensors_Data" | gawk -F ':' -v userCpuNo="$SENSORS_CPU_NO" ' BEGIN { IGNORECASE=1 core0Temp="" # only if all else fails... @@ -8313,7 +8305,7 @@ get_sensors_data() print fanMainString print fanDefaultString } - }' <<< "$Sensors_Data" ) ) + }' ) ) fi IFS="$ORIGINAL_IFS" @@ -8418,7 +8410,7 @@ get_tty_console_irc() eval $LOGFS local tty_number='' if [[ -n $IRC_CLIENT ]];then - tty_number=$( gawk ' + tty_number=$( echo "$Ps_aux_Data" | gawk ' BEGIN { IGNORECASE=1 } @@ -8428,7 +8420,7 @@ get_tty_console_irc() gsub(/[^0-9]/, "", $7) print $7 exit - }' <<< "$Ps_aux_Data" ) + }' ) fi log_function_data "tty_number: $tty_number" echo $tty_number @@ -8479,7 +8471,7 @@ get_unmounted_partition_data() a_raid_working=( ${A_RAID_DATA[i]} ) IFS="$ORIGINAL_IFS" if [[ -n ${a_raid_working[3]} ]];then - raid_partitions=$( sed $SED_RX 's/(\([^\)]*\)|\[[^\]]*\])//g' <<< ${a_raid_working[3]}\ + raid_partitions=$( echo ${a_raid_working[3]} | sed $SED_RX 's/(\([^\)]*\)|\[[^\]]*\])//g' \ | sed 's/[[:space:]]\+/|/g' ) mounted_partitions="$mounted_partitions$separator$raid_partitions" fi @@ -8503,10 +8495,12 @@ get_unmounted_partition_data() a_unmounted_working=( ${A_UNMOUNTED_PARTITION_DATA[i]} ) IFS="$ORIGINAL_IFS" - label_working=$( grep -E "${a_unmounted_working[0]}$" <<< "$DEV_DISK_LABEL" | gawk '{ + label_working=$( echo "$DEV_DISK_LABEL" | grep -E "${a_unmounted_working[0]}$" | \ + gawk '{ print $(NF - 2) }' ) - uuid_working=$( grep -E "${a_unmounted_working[0]}$" <<< "$DEV_DISK_UUID" | gawk '{ + uuid_working=$( echo "$DEV_DISK_UUID" | grep -E "${a_unmounted_working[0]}$" | \ + gawk '{ print $(NF - 2) }' ) unmounted_fs=$( get_unmounted_partition_filesystem "/dev/${a_unmounted_working[0]}" ) @@ -8609,16 +8603,16 @@ get_weather_data() fi if [[ -n $data_grab_error ]];then : - elif [[ -z $( grep -i '' <<< "$weather_data" | sed $SED_RX -e 's/<[^>]*>//g' \ + weather_data=$( echo "$weather_data" | sed 's/^[[:space:]]*//' ) + site_elevation=$( echo "$weather_data" | grep -im 1 '' | \ + sed $SED_RX -e 's/<[^>]*>//g' \ -e 's/\.[0-9]*//' ) # we need to grab the location data from the feed for remote checks if [[ -n $ALTERNATE_WEATHER_LOCATION && -n $weather_data ]];then - location_data=$( sed -e '//,//d' -e '/<\/display_location>/,/<\/current_observation>/d' <<< "$weather_data" ) + location_data=$( echo "$weather_data" | sed -e '//,//d' \ + -e '/<\/display_location>/,/<\/current_observation>/d' ) # echo -e "ld1:\n$location_data" - A_WEATHER_DATA[0]=$( gawk ' + A_WEATHER_DATA[0]=$( echo "$location_data" | gawk ' function clean(data) { returnData="" # some lines might be empty, so ignore those @@ -8761,16 +8757,16 @@ get_weather_data() } END { print city ";" state ";;;;" country - }' <<< "$location_data" ) + }' ) # echo -e "location:\n${A_WEATHER_DATA[0]}" fi # clean off everything before/after observation_location - weather_data=$( sed -e '//,//d' \ - -e '//,/<\/current_observation>/d' <<< "$weather_data" -e 's/^[[:space:]]*$//g' -e '/^$/d' ) + weather_data=$( echo "$weather_data" | sed -e '//,//d' \ + -e '//,/<\/current_observation>/d' -e 's/^[[:space:]]*$//g' -e '/^$/d' ) # echo "$weather_data";exit - weather_array_value=$( gawk -v siteElevation="$site_elevation" ' + weather_array_value=$( echo "$weather_data" | gawk -v siteElevation="$site_elevation" ' function clean(data) { returnData="" # some lines might be empty, so ignore those @@ -8827,7 +8823,7 @@ get_weather_data() weatherString = weatherString ";" windString ";" pressureString ";" dewpointString ";" heatIndexString weatherString = weatherString ";" windChillString ";" siteElevation print weatherString - }' <<< "$weather_data" ) + }' ) fi if [[ -z $weather_array_value ]];then data_grab_error="Error: weather info downloaded but no data detected." @@ -8863,7 +8859,7 @@ 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 ) + string=$( echo $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" ) count=${#string} echo $count } @@ -8875,12 +8871,12 @@ calculate_multicore_data() eval $LOGFS local string_number=$1 string_data='' - if [[ -n $( grep -Ei '( mb| kb)' <<< $1 ) ]];then - string_data=" $( gawk '{print $2}' <<< $1 )" # add a space for output - string_number=$( gawk '{print $1}' <<< $1 ) + if [[ -n $( echo $1 | grep -Ei '( mb| kb)' ) ]];then + string_data=" $( echo $1 | gawk '{print $2}' )" # add a space for output + string_number=$( echo $1 | gawk '{print $1}' ) fi # handle weird error cases where it's not a number - if [[ -n $( grep -E '^[0-9\.,]+$' <<< $string_number ) ]];then + if [[ $string_number =~ ^[0-9\.,]+$ ]];then string_number=$( echo $string_number $2 | gawk '{ total = $1*$2 print total @@ -8907,7 +8903,7 @@ process_cpu_flags() # no need to show pae for 64 bit cpus, it's pointless if [[ -n $bits ]];then - cpu_flags_working=$( sed 's/[[:space:]]*pae//' <<< "$cpu_flags_working" ) + cpu_flags_working=$( echo "$cpu_flags_working" | sed 's/[[:space:]]*pae//' ) fi # must have a space after last item in list for RS=" " cpu_flags_working="$cpu_flags_working " @@ -8917,7 +8913,7 @@ process_cpu_flags() # sse, sse2, pni = sse1,2,3,4,5 gfx extensions # svm = AMD pacifica virtualization extensions # vmx = Intel IVT (vanderpool) virtualization extensions - cpu_flags=$( gawk ' + cpu_flags=$( echo "$cpu_flags_working" | gawk ' BEGIN { RS=" " count = 0 @@ -8946,7 +8942,7 @@ process_cpu_flags() } } print flag_string - }' <<< "$cpu_flags_working" ) + }' ) #grep -oE '\<(nx|lm|sse[0-9]?|pni|svm|vmx)\>' | tr '\n' ' ')) if [[ -z $cpu_flags ]];then @@ -9044,7 +9040,7 @@ print_short_data() { eval $LOGFS local current_kernel=$( get_kernel_version ) - local processes=$(( $( wc -l <<< "$Ps_aux_Data" ) - 1 )) + local processes=$(( $( echo "$Ps_aux_Data" | wc -l ) - 1 )) local short_data='' i='' b_background_black='false' local memory=$( get_memory_data ) local up_time="$( get_uptime )" @@ -9205,14 +9201,14 @@ print_audio_data() if [[ -n ${a_audio_working[1]} ]];then # note: linux drivers can have numbers, like tg3 if [[ $BSD_TYPE == 'bsd' ]];then - driver=$( sed 's/[0-9]$//' <<< ${a_audio_working[1]} ) + driver=$( echo ${a_audio_working[1]} | sed 's/[0-9]$//' ) else driver=${a_audio_working[1]} fi audio_driver="${C1}driver$SEP3${C2} $driver " fi if [[ -n ${a_audio_working[2]} && $B_EXTRA_DATA == 'true' ]];then - if [[ $( wc -w <<< ${a_audio_working[2]} ) -gt 1 ]];then + if [[ $( echo ${a_audio_working[2]} | wc -w ) -gt 1 ]];then port_plural='s' fi port_data="${C1}port$port_plural$SEP3${C2} ${a_audio_working[2]} " @@ -9273,7 +9269,7 @@ print_audio_data() done fi if [[ -n $alsa_data ]];then - alsa_data=$( sed 's/ALSA/Advanced Linux Sound Architecture/' <<< $alsa_data ) + alsa_data=$( echo $alsa_data | sed 's/ALSA/Advanced Linux Sound Architecture/' ) alsa_data=$( create_print_line "$line_starter" "$alsa_data${CN}" ) print_screen_output "$alsa_data" fi @@ -9522,8 +9518,8 @@ print_graphics_data() local glx_renderer="${A_GLX_DATA[0]}" local glx_version="${A_GLX_DATA[1]}" # this can contain a long No case debugging message, so it's being sliced off - # note: using grep -ioE '(No|Yes)' <<< ${A_GLX_DATA[2]} did not work in Arch, no idea why - local glx_direct_render=$( gawk '{print $1}' <<< "${A_GLX_DATA[2]}" ) + # note: using echo ${A_GLX_DATA[2]} | grep -ioE '(No|Yes)' did not work in Arch, no idea why + local glx_direct_render=$( echo "${A_GLX_DATA[2]}" | gawk '{print $1}' ) # set A_GRAPHICS_CARD_DATA if [[ $BSD_TYPE == 'bsd' ]];then @@ -9647,7 +9643,7 @@ print_graphics_data() part_1_data='' line_starter=' ' fi - if [[ -n $( grep -vE '^[[:space:]]*$' <<< $part_1_data$part_2_data ) ]];then + if [[ -n $( echo $part_1_data$part_2_data | grep -vE '^[[:space:]]*$' ) ]];then graphics_data=$( create_print_line "$line_starter" "$part_1_data$part_2_data" ) print_screen_output "$graphics_data" fi @@ -9669,7 +9665,7 @@ print_graphics_data() part_1_data='' line_starter=' ' fi - if [[ -n $( grep -vE '^[[:space:]]*$' <<< $part_1_data$part_2_data ) ]];then + if [[ -n $( echo $part_1_data$part_2_data | grep -vE '^[[:space:]]*$' ) ]];then graphics_data=$( create_print_line "$line_starter" "$part_1_data$part_2_data" ) print_screen_output "$graphics_data" fi @@ -9680,7 +9676,7 @@ print_graphics_data() part_1_data="$display_server_string$driver_string" part_2_data="${C1}$res_tty$SEP3${C2} $screen_resolution $root_x_string" - if [[ -n $( grep -vE '^[[:space:]]*$' <<< $part_1_data$part_2_data ) && \ + if [[ -n $( echo $part_1_data$part_2_data | grep -vE '^[[:space:]]*$' ) && \ $( calculate_line_length "$part_1_data $part_2_data" ) -gt $COLS_INNER ]];then graphics_data=$( create_print_line "$line_starter" "$part_1_data" ) print_screen_output "$graphics_data" @@ -9688,7 +9684,7 @@ print_graphics_data() part_1_data='' graphics_data=$part_2_data fi - if [[ -n $( grep -vE '^[[:space:]]*$' <<< $part_1_data$part_2_data ) ]];then + if [[ -n $( echo $part_1_data$part_2_data | grep -vE '^[[:space:]]*$' ) ]];then graphics_data=$( create_print_line "$line_starter" "$part_1_data$part_2_data" ) print_screen_output "$graphics_data" line_starter=' ' @@ -9861,7 +9857,7 @@ print_info_data() local init_data='' init_type='' init_version='' rc_type='' rc_version='' local client_data='' shell_data='' shell_parent='' tty_session='' local memory="$( get_memory_data )" - local processes=$(( $( wc -l <<< "$Ps_aux_Data" ) - 1 )) + local processes=$(( $( echo "$Ps_aux_Data" | wc -l ) - 1 )) local up_time="$( get_uptime )" local patch_version_number=$( get_patch_version_string ) local gcc_string='' gcc_installed='' gcc_others='' closing_data='' @@ -9879,7 +9875,7 @@ print_info_data() gcc_installed='N/A' fi if [[ $B_EXTRA_EXTRA_DATA == 'true' && -n ${A_GCC_VERSIONS[1]} ]];then - # gcc_others=" ${C1}alt$SEP3${C2} $( tr ',' '/' <<< ${A_GCC_VERSIONS[1]} )" + # gcc_others=" ${C1}alt$SEP3${C2} $( echo ${A_GCC_VERSIONS[1]} | tr ',' '/' )" gcc_others=" ${C1}alt$SEP3${C2} ${A_GCC_VERSIONS[1]//,//}" fi gcc_installed="${C1}Gcc sys$SEP3${C2} $gcc_installed$gcc_others " @@ -9913,7 +9909,7 @@ print_info_data() # this only triggers if no X data is present or if extra data switch is on if [[ $B_SHOW_DISPLAY_DATA != 'true' || $B_EXTRA_DATA == 'true' ]];then get_init_data - if [[ ${A_INIT_DATA[0]} == 'systemd' && -z $( grep -E '^[0-9]$' <<< ${A_INIT_DATA[4]} ) ]];then + if [[ ${A_INIT_DATA[0]} == 'systemd' && -z $( echo ${A_INIT_DATA[4]} | grep -E '^[0-9]$' ) ]];then runlvl_title='target' fi init_type=${A_INIT_DATA[0]} @@ -10176,7 +10172,7 @@ print_module_version() # note that sound driver data tends to have upper case, but modules are lower if [[ $2 == 'audio' ]];then - if [[ -z $( grep -E '^snd' <<< $modules ) ]];then + if [[ -z $( echo $modules | grep -E '^snd' ) ]];then prefix='snd_' # sound modules start with snd_ fi modules=${modules,,} @@ -10249,20 +10245,20 @@ print_networking_data() if [[ -n ${a_network_working[1]} ]];then # note: linux drivers can have numbers, like tg3 if [[ $BSD_TYPE == 'bsd' ]];then - driver=$( sed 's/[0-9]*$//' <<< ${a_network_working[1]} ) + driver=$( echo ${a_network_working[1]} | sed 's/[0-9]*$//' ) else driver=${a_network_working[1]} fi driver_data="${C1}driver$SEP3${C2} $driver$module_version " fi if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then - if [[ $( wc -w <<< ${a_network_working[2]} ) -gt 1 ]];then + if [[ $( echo ${a_network_working[2]} | wc -w ) -gt 1 ]];then port_plural='s' fi port_data="${C1}port$port_plural$SEP3${C2} ${a_network_working[2]} " fi if [[ -n ${a_network_working[4]} && $B_EXTRA_DATA == 'true' ]];then - if [[ -z $( grep '^usb-' <<< ${a_network_working[4]} ) ]];then + if [[ -z $( echo ${a_network_working[4]} | grep '^usb-' ) ]];then bus_usb_text='bus-ID' bus_usb_id=${a_network_working[4]} if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then @@ -10274,7 +10270,7 @@ print_networking_data() fi else bus_usb_text='usb-ID' - bus_usb_id=$( cut -d '-' -f '2-4' <<< ${a_network_working[4]} ) + bus_usb_id=$( echo ${a_network_working[4]} | cut -d '-' -f '2-4' ) if [[ $B_EXTRA_EXTRA_DATA == 'true' ]];then chip_id=${a_network_working[10]} fi @@ -10317,7 +10313,7 @@ print_network_advanced_data() local b_is_wifi='false' speed_string='' duplex_string='' # first check if it's a known wifi id'ed card, if so, no print of duplex/speed - if [[ -n $( grep -Esi '(wireless|wifi|wi-fi|wlan|802\.11|centrino)' <<< ${a_network_working[0]} ) ]];then + if [[ -n $( echo ${a_network_working[0]} | grep -Esi '(wireless|wifi|wi-fi|wlan|802\.11|centrino)' ) ]];then b_is_wifi='true' fi if [[ -n ${a_network_working[5]} ]];then @@ -10332,7 +10328,7 @@ print_network_advanced_data() if [[ $b_is_wifi != 'true' && $oper_state != 'down' ]];then if [[ -n ${a_network_working[7]} ]];then # make sure the value is strictly numeric before appending Mbps - if [[ -n $( grep -E '^[0-9\.,]+$' <<< "${a_network_working[7]}" ) ]];then + if [[ -n $( echo "${a_network_working[7]}" | grep -E '^[0-9\.,]+$' ) ]];then speed="${a_network_working[7]} Mbps" else speed=${a_network_working[7]} @@ -10389,7 +10385,7 @@ print_networking_ip_data() if_ip='N/A' if_ipv6='N/A' if_ipv6_string='' - if [[ -z $( grep '^Interface' <<< ${a_interfaces_working[0]} ) ]];then + if [[ -z $( echo ${a_interfaces_working[0]} | grep '^Interface' ) ]];then if [[ -n ${a_interfaces_working[1]} ]];then if [[ $B_OUTPUT_FILTER == 'true' ]];then if_ip=$FILTER_STRING @@ -10473,7 +10469,7 @@ print_optical_drive_data() else drive_id="/dev/${a_drives[0]}" fi - drive_links=$( sed 's/~/,/g' <<< ${a_drives[1]} ) + drive_links=$( echo ${a_drives[1]} | sed 's/~/,/g' ) if [[ -z $drive_links ]];then drive_links='N/A' fi @@ -10617,11 +10613,11 @@ print_partition_data() if [[ $B_SHOW_LABELS == 'true' || $B_SHOW_UUIDS == 'true' ]];then if [[ -n ${a_partition_working[6]} ]];then - if [[ -z $( grep -E '(^//|:/|non-dev)' <<< ${a_partition_working[6]} ) ]];then + if [[ -z $( echo ${a_partition_working[6]} | grep -E '(^//|:/|non-dev)' ) ]];then part_dev="/dev/${a_partition_working[6]}" dev_remote='dev' - elif [[ -n $( grep '^non-dev' <<< ${a_partition_working[6]} ) ]];then - holder=$( sed 's/non-dev-//' <<< ${a_partition_working[6]} ) + elif [[ -n $( echo ${a_partition_working[6]} | grep '^non-dev' ) ]];then + holder=$( echo ${a_partition_working[6]} | sed 's/non-dev-//' ) part_dev="$holder" dev_remote='raid' else @@ -10652,7 +10648,8 @@ print_partition_data() fi # don't show user names in output if [[ $B_OUTPUT_FILTER == 'true' ]];then - partitionIdClean=$( sed $SED_RX "s|/home/([^/]+)/(.*)|/home/$FILTER_STRING/\2|" <<< ${a_partition_working[0]} ) + partitionIdClean=$( echo ${a_partition_working[0]} | \ + sed $SED_RX "s|/home/([^/]+)/(.*)|/home/$FILTER_STRING/\2|" ) else partitionIdClean=${a_partition_working[0]} fi @@ -10704,7 +10701,7 @@ print_program_version() # right pad: sed -e :a -e 's/^.\{1,80\}$/ &/;ta' # center pad: sed -e :a -e 's/^.\{1,80\}$/ & /;ta' #local line_max=$COLS_INNER - #program_version="$( sed -e :a -e "s/^.\{1,$line_max\}$/ &/;ta" <<< $program_version )" # use to create padding if needed + #program_version="$( echo $program_version | sed -e :a -e "s/^.\{1,$line_max\}$/ &/;ta" )" # use to create padding if needed # program_version=$( create_print_line "Version:" "$program_version${CN}" ) print_screen_output "$program_version" } @@ -10765,7 +10762,7 @@ print_ps_item() IFS="$ORIGINAL_IFS" # handle the converted app names, with ~..~ means it didn't have a path - if [[ -n $( grep -E '^~.*~$' <<< ${a_ps_data[0]} ) ]];then + if [[ -n $( echo ${a_ps_data[0]} | grep -E '^~.*~$' ) ]];then app_daemon='daemon' else app_daemon='command' @@ -10862,7 +10859,7 @@ print_raid_data() super_blocks='' u_data='' - if [[ -n $( grep '^md' <<< ${a_raid_working[0]} ) && -z $BSD_TYPE ]] || \ + if [[ -n $( echo ${a_raid_working[0]} | grep '^md' ) && -z $BSD_TYPE ]] || \ [[ -n $BSD_TYPE && ${a_raid_working[0]} != '' ]];then if [[ $B_SHOW_BASIC_RAID == 'true' ]];then if [[ $basic_raid != '' ]];then @@ -10937,15 +10934,15 @@ print_raid_data() for component in ${a_raid_working[3]} do if [[ $B_EXTRA_DATA != 'true' ]];then - component=$( sed 's/\[[0-9]\+\]//' <<< $component ) + component=$( echo $component | sed 's/\[[0-9]\+\]//' ) fi # NOTE: for bsd zfs, states are: ONLINE,DEGRADED,OFFLINE (at least) - if [[ -n $( grep -E '(F|DEGRADED)' <<< $component ) ]];then - component=$( sed -e 's/(F)//' -e 's/F//' -e 's/DEGRADED//' <<< $component ) + if [[ -n $( echo $component | grep -E '(F|DEGRADED)' ) ]];then + component=$( echo $component | sed -e 's/(F)//' -e 's/F//' -e 's/DEGRADED//' ) failed="$failed $component" component='' - elif [[ -n $( grep -E '(S|OFFLINE)' <<< $component ) ]];then - component=$( sed -e 's/(S)//' -e 's/S//' -e 's/OFFLINE//' <<< $component ) + elif [[ -n $( echo $component | grep -E '(S|OFFLINE)' ) ]];then + component=$( echo $component | sed -e 's/(S)//' -e 's/S//' -e 's/OFFLINE//' ) spare="$spare $component" component='' else @@ -10989,7 +10986,7 @@ print_raid_data() # now let's do the recover line if required if [[ ${a_raid_working[12]} != '' ]];then - recovery_percent=$( cut -d '~' -f 2 <<< ${a_raid_working[12]} ) + recovery_percent=$( echo ${a_raid_working[12]} | cut -d '~' -f 2 ) if [[ ${a_raid_working[14]} != '' ]];then finish_time=${a_raid_working[14]} else @@ -11118,9 +11115,9 @@ print_repo_data() while read repo_line do (( repo_count++ )) - repo_type=$( cut -d ':' -f 1 <<< $repo_line ) - file_name=$( cut -d ':' -f 2 <<< $repo_line ) - file_content=$( cut -d ':' -f 3-7 <<< $repo_line ) + repo_type=$( echo $repo_line | cut -d ':' -f 1 ) + file_name=$( echo $repo_line | cut -d ':' -f 2 ) + file_content=$( echo $repo_line | cut -d ':' -f 3-7 ) # this will dump unwanted white space line starters. Some irc channels # use bots that show page title for urls, so need to break the url by adding # a white space. @@ -11214,7 +11211,7 @@ print_sensors_data() fi gpu_temp=$( get_gpu_temp_data ) # dump the unneeded screen data for single gpu systems - if [[ $( wc -w <<< $gpu_temp ) -eq 1 && $B_EXTRA_DATA != 'true' ]];then + if [[ $( echo $gpu_temp | wc -w ) -eq 1 && $B_EXTRA_DATA != 'true' ]];then gpu_temp=${gpu_temp#*:} fi if [[ -n $gpu_temp ]];then diff --git a/inxi.changelog b/inxi.changelog index a64ef03..c43230a 100755 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,3 +1,21 @@ +===================================================================================== +Version: 2.1.12 +Patch Version: 00 +Script Date: 2014-03-26 +----------------------------------- +Changes: +----------------------------------- +new version: this is only an optimization release, testing some slightly more efficient +methods: +something <<< $variable is signficantly slower than: echo $variable | something +so I replaced almost all instances of <<< with echo ...| + +I've seen speed differences of up to 10% but it's not consistent, so this is just +something to boost performance slightly on older systems I'd guess. + +----------------------------------- +-- Harald Hope - Wed, 26 Mar 2014 14:54:39 -0700 + ===================================================================================== Version: 2.1.11 Patch Version: 00