Use here strings instead of echos where appropriate (part of Alioth: #312143).

This commit is contained in:
Ville Skyttä 2009-12-09 22:46:09 +02:00
parent 09045a63b6
commit 04b7883f7d
8 changed files with 18 additions and 20 deletions

View File

@ -23,13 +23,13 @@ have module || [ -f /etc/profile.d/modules.sh ] && {
_module_list () _module_list ()
{ {
local modules="$( echo $LOADEDMODULES | sed 's/:/ /g' | sort )" local modules="$( sed 's/:/ /g' <<<$LOADEDMODULES | sort )"
compgen -W "$modules" -- $1 compgen -W "$modules" -- $1
} }
_module_path () _module_path ()
{ {
local modules="$( echo $MODULEPATH | sed 's/:/ /g' | sort )" local modules="$( sed 's/:/ /g' <<<$MODULEPATH | sort )"
compgen -W "$modules" -- $1 compgen -W "$modules" -- $1
} }

View File

@ -92,7 +92,7 @@ _find()
# opposition to "tests" and "actions", as in the find(1) manpage). # opposition to "tests" and "actions", as in the find(1) manpage).
onlyonce=' -daystart -depth -follow -help -maxdepth -mindepth -mount \ onlyonce=' -daystart -depth -follow -help -maxdepth -mindepth -mount \
-noleaf -version -xdev ' -noleaf -version -xdev '
COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \ COMPREPLY=( $( \
(while read -d ' ' i; do (while read -d ' ' i; do
[[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] && [[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] &&
continue continue
@ -103,7 +103,7 @@ _find()
# remove word from list of completions # remove word from list of completions
COMPREPLY=( ${COMPREPLY/ ${i%% *} / } ) COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
done done
echo "${COMPREPLY[@]}") echo "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}"
) ) ) )
_filedir _filedir

View File

@ -20,8 +20,8 @@ _gdb()
# functions and aliases. Thus we need to retrieve the program # functions and aliases. Thus we need to retrieve the program
# names manually. # names manually.
IFS=":" IFS=":"
local path_array=( $( echo "$PATH" | \ local path_array=( $( \
sed -e 's/:\{2,\}/:/g' -e 's/^:\|:$//g' ) ) sed -e 's/:\{2,\}/:/g' -e 's/^:\|:$//g' <<<"$PATH" ) )
IFS=$'\n' IFS=$'\n'
COMPREPLY=( $( compgen -d -W '$(find "${path_array[@]}" . \ COMPREPLY=( $( compgen -d -W '$(find "${path_array[@]}" . \
-mindepth 1 -maxdepth 1 -not -type d -executable \ -mindepth 1 -maxdepth 1 -not -type d -executable \

View File

@ -108,7 +108,7 @@ _java_packages()
fi fi
done done
# keep only packages # keep only packages
COMPREPLY=( $( echo "${COMPREPLY[@]}" | tr " " "\n" | grep "/$" ) ) COMPREPLY=( $( tr " " "\n" <<<"${COMPREPLY[@]}" | grep "/$" ) )
# remove packages extension # remove packages extension
COMPREPLY=( ${COMPREPLY[@]%/} ) COMPREPLY=( ${COMPREPLY[@]%/} )
# convert path syntax to package syntax # convert path syntax to package syntax

View File

@ -22,14 +22,14 @@ _povray()
;; ;;
[-+]O*) [-+]O*)
# guess what output file type user may want # 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 ;; [-+]FN) oext=png ;;
[-+]FP) oext=ppm ;; [-+]FP) oext=ppm ;;
[-+]F[CT]) oext=tga ;; [-+]F[CT]) oext=tga ;;
*) oext=$defoext ;; *) oext=$defoext ;;
esac esac
# complete filename corresponding to previously specified +I # 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[@]#[-+]I} )
COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} ) COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} )
cur="${povcur#[-+]O}" # to confuse _filedir cur="${povcur#[-+]O}" # to confuse _filedir

View File

@ -19,14 +19,13 @@ _update_rc_d()
if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
valid_options=( $( \ valid_options=( $( \
echo "${COMP_WORDS[@]} ${options[@]}" \ tr " " "\n" <<<"${COMP_WORDS[@]} ${options[@]}" \
| tr " " "\n" \ | sed -ne "/$( sed "s/ /\\|/g" <<<"${options[@]}" )/p" \
| sed -ne "/$( echo "${options[@]}" | sed "s/ /\\|/g" )/p" \
| sort | uniq -u \ | sort | uniq -u \
) ) ) )
COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \ COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \
-X '$( echo ${COMP_WORDS[@]} | tr " " "|" )' -- "$cur" ) ) -X '$( tr " " "|" <<<${COMP_WORDS[@]} )' -- "$cur" ) )
elif [[ "$prev" == ?($( echo ${services[@]} | tr " " "|" )) ]]; then elif [[ "$prev" == ?($( tr " " "|" <<<${services[@]} )) ]]; then
COMPREPLY=( $( compgen -W 'remove defaults start stop' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'remove defaults start stop' -- "$cur" ) )
elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then
COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 ) 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 if [[ ($COMP_CWORD -eq 1) || ("$prev" == --* ) ]]; then
valid_options=( $( \ valid_options=( $( \
echo ${COMP_WORDS[@]} ${options[@]} \ tr " " "\n" <<<"${COMP_WORDS[@]} ${options[@]}" \
| tr " " "\n" \ | sed -ne "/$( sed "s/ /\\\\|/g" <<<"${options[@]}" )/p" \
| sed -ne "/$( echo ${options[@]} | sed "s/ /\\\\|/g" )/p" \
| sort | uniq -u \ | sort | uniq -u \
) ) ) )
COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- "$cur" ) )

View File

@ -45,7 +45,7 @@ _tar()
# complete on files in tar file # complete on files in tar file
# #
# get name of tar file from command line # 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 # devise how to untar and list it
untar=t${COMP_WORDS[1]//[^Izjyf]/} untar=t${COMP_WORDS[1]//[^Izjyf]/}

View File

@ -114,8 +114,8 @@ _xvnc4viewer()
# Variable 'nocasematch' isn't available; # Variable 'nocasematch' isn't available;
# Convert completions to lowercase # Convert completions to lowercase
COMPREPLY=( $( compgen -W "$( COMPREPLY=( $( compgen -W "$(
echo ${options[@]/#/$dash} | tr [:upper:] [:lower:] tr [:upper:] [:lower:] <<<${options[@]/#/$dash}
)" -- "$(echo "$cur" | tr [:upper:] [:lower:])" ) ) )" -- "$( tr [:upper:] [:lower:] <<<"$cur" )" ) )
fi fi
else else
_known_hosts_real "$cur" _known_hosts_real "$cur"