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

View File

@ -77,7 +77,6 @@ bashcomp_DATA = contrib/abook \
contrib/minicom \ contrib/minicom \
contrib/mkinitrd \ contrib/mkinitrd \
contrib/mock \ contrib/mock \
contrib/modules \
contrib/monodevelop \ contrib/monodevelop \
contrib/mplayer \ contrib/mplayer \
contrib/msynctool \ contrib/msynctool \
@ -152,4 +151,4 @@ profiledir = $(sysconfdir)/profile.d
profile_DATA = bash_completion.sh profile_DATA = bash_completion.sh
EXTRA_DIST = CHANGES $(sysconf_DATA) $(bashcomp_DATA) $(profile_DATA) \ 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> # module completion by Ted Stern <stern@cray.com>
# #
# Completion for Environment Modules `module' alias. # Completion for Environment Modules `module' alias.
@ -20,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
} }
@ -34,8 +37,8 @@ _module_avail ()
{ {
local modules="$( \ local modules="$( \
module avail 2>&1 | \ module avail 2>&1 | \
egrep -v '^(-|$)' | \ grep -E -v '^(-|$)' | \
xargs printf '%s\n' | sort )" xargs printf '%s\n' | sed -e 's/(default)//g' | sort )"
compgen -W "$modules" -- $1 compgen -W "$modules" -- $1
} }
@ -52,7 +55,7 @@ _module ()
if [ $COMP_CWORD -eq 1 ] ; then if [ $COMP_CWORD -eq 1 ] ; then
# First parameter on line -- we expect it to be a mode selection # 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 )" awk '{print $2}' | sed -e 's/|/ /g' | sort )"
COMPREPLY=( $(compgen -W "$options" -- "$cur") ) 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 # svn completion
have svn && 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 # yum(8) completion
have yum && { 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 # bash completion for repomanage
have repomanage && have repomanage &&

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

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

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

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

View File

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

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

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

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"