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 ()
{
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
}

View File

@ -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

View File

@ -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 \

View File

@ -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

View File

@ -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

View File

@ -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" ) )

View File

@ -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]/}

View File

@ -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"