Merge branch 'master' of git+ssh://fvu-guest@git.debian.org/git/bash-completion/bash-completion

This commit is contained in:
Freddy Vulto 2009-12-09 22:17:02 +01:00
commit cbf7e1f963
17 changed files with 95 additions and 79 deletions

View File

@ -24,7 +24,8 @@ bash-completion (2.x)
* Apply pine completion to alpine too.
* Remove many unnecessary short option completions where long ones exist.
* Improve configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer,
mysqladmin, service, scp, ssh, and general hostname completions.
mysqladmin, screen, service, scp, ssh, update-alternatives, and general
hostname completions.
* Add abook and wtf completion, based on work by Raphaël Droz.
* Add jarsigner, k3b, lftpget, pack200 and unpack200 completions.
* Don't overwrite other host completions when completing from multiple
@ -44,10 +45,14 @@ bash-completion (2.x)
* sed usage portability fixes.
* Fix leaking local variables from various completions.
* Turn on -o filenames in _filedir on bash >= 4.
* Deprecate modules completion, upstream modules >= 3.2.7 ships one.
[ Freddy Vulto ]
* Added _get_pword() helper function, thanks to Sung Pae (Alioth: #312030)
[ Ted Stern ]
* Fix modules completion for "(default)" entries.
-- David Paleino <d.paleino@gmail.com> Sun, 11 Oct 2009 11:11:57 +0200
bash-completion (1.1)

View File

@ -77,7 +77,6 @@ bashcomp_DATA = contrib/abook \
contrib/minicom \
contrib/mkinitrd \
contrib/mock \
contrib/modules \
contrib/monodevelop \
contrib/mplayer \
contrib/msynctool \
@ -152,4 +151,4 @@ profiledir = $(sysconfdir)/profile.d
profile_DATA = bash_completion.sh
EXTRA_DIST = CHANGES $(sysconf_DATA) $(bashcomp_DATA) $(profile_DATA) \
contrib/_subversion contrib/_yum contrib/_yum-utils
contrib/_modules contrib/_subversion contrib/_yum contrib/_yum-utils

View File

@ -1,3 +1,6 @@
# Use of this file is deprecated, upstream completion is available in
# modules >= 3.2.7, use that instead.
#
# module completion by Ted Stern <stern@cray.com>
#
# Completion for Environment Modules `module' alias.
@ -20,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
}
@ -34,8 +37,8 @@ _module_avail ()
{
local modules="$( \
module avail 2>&1 | \
egrep -v '^(-|$)' | \
xargs printf '%s\n' | sort )"
grep -E -v '^(-|$)' | \
xargs printf '%s\n' | sed -e 's/(default)//g' | sort )"
compgen -W "$modules" -- $1
}
@ -52,7 +55,7 @@ _module ()
if [ $COMP_CWORD -eq 1 ] ; then
# First parameter on line -- we expect it to be a mode selection
options="$( module help 2>&1 | egrep '^[[:space:]]*\+' | \
options="$( module help 2>&1 | grep -E '^[[:space:]]*\+' | \
awk '{print $2}' | sed -e 's/|/ /g' | sort )"
COMPREPLY=( $(compgen -W "$options" -- "$cur") )

View File

@ -1,3 +1,6 @@
# Use of this file is deprecated. Upstream completion is available in
# subversion >= 0.12.0, use that instead.
# svn completion
have svn &&

View File

@ -1,3 +1,6 @@
# Use of this file is deprecated. Upstream completion is available in
# yum > 3.2.25, use that instead.
# yum(8) completion
have yum && {

View File

@ -1,3 +1,6 @@
# Use of this file is deprecated. Upstream completion is available in
# yum-utils >= 1.1.24, use that instead.
# bash completion for repomanage
have repomanage &&

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

@ -36,8 +36,8 @@ _portinstall()
[[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0
COMPREPLY=( $( egrep "^$cur" < $indexfile | cut -d'|' -f1 ) )
COMPREPLY2=( $( egrep "^[^\|]+\|$portsdir$cur" < $indexfile | \
COMPREPLY=( $( grep -E "^$cur" < $indexfile | cut -d'|' -f1 ) )
COMPREPLY2=( $( grep -E "^[^\|]+\|$portsdir$cur" < $indexfile | \
cut -d'|' -f2 ) )
COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
COMPREPLY=( "${COMPREPLY[@]}" "${COMPREPLY2[@]}" )

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

@ -13,7 +13,7 @@ _rdesktop()
-k)
COMPREPLY=( $( command ls \
/usr/share/rdesktop/keymaps 2>/dev/null | \
egrep -v '(common|modifiers)' ) )
grep -E -v '(common|modifiers)' ) )
COMPREPLY=( ${COMPREPLY[@]:-} $( command ls \
$HOME/.rdesktop/keymaps 2>/dev/null ) )
COMPREPLY=( ${COMPREPLY[@]:-} $( command ls \

View File

@ -43,8 +43,8 @@ _screen()
return 0
;;
-s)
# shells
COMPREPLY=( $( grep ^${cur:-[^#]} /etc/shells ) )
_shells
return 0
;;
-c)
_filedir
@ -53,9 +53,9 @@ _screen()
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a -A -c -d -D -e -f -fn -fa -h -i \
-l -ln -ls -list -L -m -O -p -q -r -R -s -S -t -U -v \
-wipe -x -X' -- "$cur" ) )
COMPREPLY=( $( compgen -W '-a -A -c -d -D -e -f -fn -fa -h -i -ln \
-list -L -m -O -p -q -r -R -s -S -t -U -v -wipe -x -X --help \
--version' -- "$cur" ) )
fi
} &&
complete -F _screen -o default screen

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

@ -30,14 +30,14 @@ _update_alternatives()
_filedir -d
return 0
;;
--help|--version)
--help|--usage|--version)
return 0
;;
esac
# find which mode to use and how many real args used so far
for (( i=1; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all) ]]; then
if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all|set) ]]; then
mode=${COMP_WORDS[i]}
args=$(($COMP_CWORD - i))
break
@ -47,18 +47,30 @@ _update_alternatives()
case $mode in
--install)
case $args in
1)
1|3)
_filedir
;;
2)
_installed_alternatives
;;
3)
4)
# priority - no completions
;;
*)
case $((args % 4)) in
0|2)
_filedir
;;
1)
COMPREPLY=( $( compgen -W '--slave' -- "$cur" ) )
;;
3)
_installed_alternatives
;;
esac
esac
;;
--remove)
--remove|--set)
case $args in
1)
_installed_alternatives
@ -68,23 +80,13 @@ _update_alternatives()
;;
esac
;;
--auto)
_installed_alternatives
;;
--remove-all)
_installed_alternatives
;;
--display)
_installed_alternatives
;;
--config)
--auto|--remove-all|--display|--config)
_installed_alternatives
;;
*)
COMPREPLY=( $( compgen -W '--verbose --quiet --help --version \
--altdir --admindir' -- "$cur" ) \
$( compgen -W '--install --remove --auto --display \
--config' -- "$cur" ) )
--altdir --admindir --install --remove --auto --display \
--config --set' -- "$cur" ) )
esac
}
complete -F _update_alternatives update-alternatives alternatives

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"