From 04b7883f7dd06ffe1f45e90e430c7d3fa03b99b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 9 Dec 2009 22:46:09 +0200 Subject: [PATCH] Use here strings instead of echos where appropriate (part of Alioth: #312143). --- contrib/_modules | 4 ++-- contrib/findutils | 4 ++-- contrib/gdb | 4 ++-- contrib/java | 2 +- contrib/povray | 4 ++-- contrib/sysv-rc | 14 ++++++-------- contrib/tar | 2 +- contrib/vncviewer | 4 ++-- 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/contrib/_modules b/contrib/_modules index 33b367c3..b6f51b0b 100644 --- a/contrib/_modules +++ b/contrib/_modules @@ -23,13 +23,13 @@ have module || [ -f /etc/profile.d/modules.sh ] && { _module_list () { - local modules="$( echo $LOADEDMODULES | sed 's/:/ /g' | sort )" + local modules="$( sed 's/:/ /g' <<<$LOADEDMODULES | sort )" compgen -W "$modules" -- $1 } _module_path () { - local modules="$( echo $MODULEPATH | sed 's/:/ /g' | sort )" + local modules="$( sed 's/:/ /g' <<<$MODULEPATH | sort )" compgen -W "$modules" -- $1 } diff --git a/contrib/findutils b/contrib/findutils index 09d2f447..ea0c1121 100644 --- a/contrib/findutils +++ b/contrib/findutils @@ -92,7 +92,7 @@ _find() # opposition to "tests" and "actions", as in the find(1) manpage). onlyonce=' -daystart -depth -follow -help -maxdepth -mindepth -mount \ -noleaf -version -xdev ' - COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \ + COMPREPLY=( $( \ (while read -d ' ' i; do [[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] && continue @@ -103,7 +103,7 @@ _find() # remove word from list of completions COMPREPLY=( ${COMPREPLY/ ${i%% *} / } ) done - echo "${COMPREPLY[@]}") + echo "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}" ) ) _filedir diff --git a/contrib/gdb b/contrib/gdb index 0cbf1ec7..04e725cb 100644 --- a/contrib/gdb +++ b/contrib/gdb @@ -20,8 +20,8 @@ _gdb() # functions and aliases. Thus we need to retrieve the program # names manually. IFS=":" - local path_array=( $( echo "$PATH" | \ - sed -e 's/:\{2,\}/:/g' -e 's/^:\|:$//g' ) ) + local path_array=( $( \ + sed -e 's/:\{2,\}/:/g' -e 's/^:\|:$//g' <<<"$PATH" ) ) IFS=$'\n' COMPREPLY=( $( compgen -d -W '$(find "${path_array[@]}" . \ -mindepth 1 -maxdepth 1 -not -type d -executable \ diff --git a/contrib/java b/contrib/java index 068a918f..58562f5d 100644 --- a/contrib/java +++ b/contrib/java @@ -108,7 +108,7 @@ _java_packages() fi done # keep only packages - COMPREPLY=( $( echo "${COMPREPLY[@]}" | tr " " "\n" | grep "/$" ) ) + COMPREPLY=( $( tr " " "\n" <<<"${COMPREPLY[@]}" | grep "/$" ) ) # remove packages extension COMPREPLY=( ${COMPREPLY[@]%/} ) # convert path syntax to package syntax diff --git a/contrib/povray b/contrib/povray index a2ff7b31..c56a71f4 100644 --- a/contrib/povray +++ b/contrib/povray @@ -22,14 +22,14 @@ _povray() ;; [-+]O*) # guess what output file type user may want - case $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]F' ) ) in + case $( ( IFS=$'\n'; grep '^[-+]F' <<<"${COMP_WORDS[*]}" ) ) in [-+]FN) oext=png ;; [-+]FP) oext=ppm ;; [-+]F[CT]) oext=tga ;; *) oext=$defoext ;; esac # complete filename corresponding to previously specified +I - COMPREPLY=( $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]I' ) ) ) + COMPREPLY=( $( ( IFS=$'\n'; grep '^[-+]I' <<<"${COMP_WORDS[*]}" ) ) ) COMPREPLY=( ${COMPREPLY[@]#[-+]I} ) COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} ) cur="${povcur#[-+]O}" # to confuse _filedir diff --git a/contrib/sysv-rc b/contrib/sysv-rc index a11c9b12..32634dde 100644 --- a/contrib/sysv-rc +++ b/contrib/sysv-rc @@ -19,14 +19,13 @@ _update_rc_d() if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then valid_options=( $( \ - echo "${COMP_WORDS[@]} ${options[@]}" \ - | tr " " "\n" \ - | sed -ne "/$( echo "${options[@]}" | sed "s/ /\\|/g" )/p" \ + tr " " "\n" <<<"${COMP_WORDS[@]} ${options[@]}" \ + | sed -ne "/$( sed "s/ /\\|/g" <<<"${options[@]}" )/p" \ | sort | uniq -u \ ) ) COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \ - -X '$( echo ${COMP_WORDS[@]} | tr " " "|" )' -- "$cur" ) ) - elif [[ "$prev" == ?($( echo ${services[@]} | tr " " "|" )) ]]; then + -X '$( tr " " "|" <<<${COMP_WORDS[@]} )' -- "$cur" ) ) + elif [[ "$prev" == ?($( tr " " "|" <<<${services[@]} )) ]]; then COMPREPLY=( $( compgen -W 'remove defaults start stop' -- "$cur" ) ) elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 ) @@ -86,9 +85,8 @@ _invoke_rc_d() if [[ ($COMP_CWORD -eq 1) || ("$prev" == --* ) ]]; then valid_options=( $( \ - echo ${COMP_WORDS[@]} ${options[@]} \ - | tr " " "\n" \ - | sed -ne "/$( echo ${options[@]} | sed "s/ /\\\\|/g" )/p" \ + tr " " "\n" <<<"${COMP_WORDS[@]} ${options[@]}" \ + | sed -ne "/$( sed "s/ /\\\\|/g" <<<"${options[@]}" )/p" \ | sort | uniq -u \ ) ) COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- "$cur" ) ) diff --git a/contrib/tar b/contrib/tar index 7ca80f71..cf0009c8 100644 --- a/contrib/tar +++ b/contrib/tar @@ -45,7 +45,7 @@ _tar() # complete on files in tar file # # get name of tar file from command line - tar=$( echo "$COMP_LINE" | sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' ) + tar=$( sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' <<<"$COMP_LINE" ) # devise how to untar and list it untar=t${COMP_WORDS[1]//[^Izjyf]/} diff --git a/contrib/vncviewer b/contrib/vncviewer index 7e9c00da..dd2525ac 100644 --- a/contrib/vncviewer +++ b/contrib/vncviewer @@ -114,8 +114,8 @@ _xvnc4viewer() # Variable 'nocasematch' isn't available; # Convert completions to lowercase COMPREPLY=( $( compgen -W "$( - echo ${options[@]/#/$dash} | tr [:upper:] [:lower:] - )" -- "$(echo "$cur" | tr [:upper:] [:lower:])" ) ) + tr [:upper:] [:lower:] <<<${options[@]/#/$dash} + )" -- "$( tr [:upper:] [:lower:] <<<"$cur" )" ) ) fi else _known_hosts_real "$cur"