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-02 21:15:50 +01:00
commit 048e27bf28
12 changed files with 245 additions and 7 deletions

View File

@ -26,7 +26,7 @@ bash-completion (2.x)
* Improve configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer,
mysqladmin, service, scp, ssh, and general hostname completions.
* Add abook and wtf completion, based on work by Raphaël Droz.
* Add k3b and lftpget completion.
* Add jarsigner, k3b, lftpget, pack200 and unpack200 completions.
* Don't overwrite other host completions when completing from multiple
SSH known hosts files.
* Speed up installed rpm package completion on SUSE, based on work by
@ -43,6 +43,7 @@ bash-completion (2.x)
* Combine dcop and qdbus completions into the latter.
* sed usage portability fixes.
* Fix leaking local variables from various completions.
* Turn on -o filenames in _filedir on bash >= 4.
[ Freddy Vulto ]
* Added _get_pword() helper function, thanks to Sung Pae (Alioth: #312030)

View File

@ -456,6 +456,8 @@ _filedir()
fi
COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
[ ${#COMPREPLY[@]} -ne 0 ] && type compopt &>/dev/null && \
compopt -o filenames
} # _filedir()

View File

@ -224,7 +224,7 @@ _dpkg_source()
"-D")
# -D: override or add a .dsc field and value
# if $cur doesn't contain a = yet, suggest variable names
if echo -- "$cur" | grep -q "="; then
if [[ "$cur" == *=* ]]; then
# $cur contains a "="
COMPREPLY=()
return 0

View File

@ -250,6 +250,172 @@ _javac()
} &&
complete -F _javac -o filenames javac
have pack200 &&
_pack200()
{
COMPREPLY=()
local cur=`_get_cword` prev=`_get_pword`
case "$prev" in
-S|--segment-limit|-P|--pass-file|-C|--class-attribute|\
-F|--field-attribute|-M|--method-attribute|-D|--code-attribute|\
'-?'|-h|--help|-V|--version|-J)
return 0
;;
-E|--effort)
COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- "$cur" ) )
return 0
;;
-H|--deflate-hint)
COMPREPLY=( $( compgen -W 'true false keep' -- "$cur" ) )
return 0
;;
-m|--modification-time)
COMPREPLY=( $( compgen -W 'latest keep' -- "$cur" ) )
return 0
;;
-U|--unknown-attribute)
COMPREPLY=( $( compgen -W 'error strip pass' -- "$cur" ) )
return 0
;;
-f|--config-file)
_filedir properties
return 0
;;
-l|--log-file)
COMPREPLY=( $( compgen -W '-' -- "$cur" ) )
_filedir log
return 0
;;
esac
# Check if a pack or a jar was already given.
local i pack=false jar=false
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )) ; do
case "${COMP_WORDS[i]}" in
*.pack|*.pack.gz) pack=true ;;
*.jar) jar=true ;;
esac
done
if ! $pack ; then
if [[ "$cur" == -* ]] ; then
COMPREPLY=( $( compgen -W '--no-gzip --gzip --strip-debug \
--no-keep-file-order --segment-limit= --effort= \
--deflate-hint= --modification-time= --pass-file= \
--unknown-attribute= --class-attribute= --field-attribute= \
--method-attribute= --code-attribute= --config-file= \
--verbose --quiet --log-file= --help --version -J' -- "$cur" ) )
[[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == *= ]] && \
type compopt &>/dev/null && compopt -o nospace
else
_filedir 'pack?(.gz)'
fi
elif ! $jar ; then
_filedir jar
fi
} &&
complete -F _pack200 pack200
have unpack200 &&
_unpack200()
{
COMPREPLY=()
local cur=`_get_cword` prev=`_get_pword`
case "$prev" in
'-?'|-h|--help|-V|--version|-J)
return 0
;;
-H|--deflate-hint)
COMPREPLY=( $( compgen -W 'true false keep' -- "$cur" ) )
return 0
;;
-l|--log-file)
COMPREPLY=( $( compgen -W '-' -- "$cur" ) )
_filedir log
return 0
;;
esac
# Check if a pack or a jar was already given.
local i pack=false jar=false
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )) ; do
case "${COMP_WORDS[i]}" in
*.pack|*.pack.gz) pack=true ;;
*.jar) jar=true ;;
esac
done
if ! $pack ; then
if [[ "$cur" == -* ]] ; then
COMPREPLY=( $( compgen -W '--deflate-hint= --remove-pack-file \
--verbose --quiet --log-file= --help --version' -- "$cur" ) )
[[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == *= ]] && \
type compopt &>/dev/null && compopt -o nospace
else
_filedir 'pack?(.gz)'
fi
elif ! $jar ; then
_filedir jar
fi
} &&
complete -F _unpack200 unpack200
have jarsigner &&
_jarsigner()
{
COMPREPLY=()
local cur=`_get_cword` prev=`_get_pword`
case "$prev" in
-keystore)
COMPREPLY=( $( compgen -W 'NONE' -- "$cur" ) )
_filedir '@(jks|ks|p12|pfx)'
return 0
;;
-storepass|-keypass|-sigfile|-digestalg|-sigalg|-tsacert|-altsigner|\
-altsignerpath|-providerName|-providerClass|-providerArg)
return 0
;;
-storetype)
COMPREPLY=( $( compgen -W 'JKS PKCS11 PKCS12' -- "$cur" ) )
return 0
;;
-signedjar)
_filedir jar
return 0
;;
-tsa)
_filedir
return 0
;;
esac
# Check if a jar was already given.
local i jar=false
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )) ; do
if [[ "${COMP_WORDS[i]}" == *.jar && \
"${COMP_WORDS[i-1]}" != -signedjar ]] ; then
jar=true
break
fi
done
if ! $jar ; then
if [[ "$cur" == -* ]] ; then
# Documented as "should not be used": -internalsf, -sectionsonly
COMPREPLY=( $( compgen -W '-keystore -storepass -storetype \
-keypass -sigfile -signedjar -digestalg -sigalg -verify \
-verbose -certs -tsa -tsacert -altsigner -altsignerpath \
-protected -providerName -providerClass -providerArg' \
-- "$cur" ) )
fi
_filedir jar
fi
} &&
complete -F _jarsigner -o filenames jarsigner
# Local variables:
# mode: shell-script
# sh-basic-offset: 4

View File

@ -182,7 +182,7 @@ _postsuper()
-[dr])
len=${#cur}
idx=0
for pval in $( echo ALL; mailq 2>/dev/null | \
for pval in ALL $( mailq 2>/dev/null | \
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
if [[ "$cur" == "${pval:0:$len}" ]]; then
COMPREPLY[$idx]=$pval
@ -194,7 +194,7 @@ _postsuper()
-h)
len=${#cur}
idx=0
for pval in $( echo ALL; mailq 2>/dev/null | \
for pval in ALL $( mailq 2>/dev/null | \
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//; /!$/d' ); do
if [[ "$cur" == "${pval:0:$len}" ]]; then
COMPREPLY[$idx]=$pval
@ -206,7 +206,7 @@ _postsuper()
-H)
len=${#cur}
idx=0
for pval in $( echo ALL; mailq 2>/dev/null | \
for pval in ALL $( mailq 2>/dev/null | \
sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do
if [[ "$cur" == "${pval:0:$len}" ]]; then
COMPREPLY[$idx]=$pval

View File

@ -8,8 +8,8 @@ _qdbus()
COMPREPLY=()
cur=`_get_cword`
[ -n "$cur" ] && unset COMP_WORDS[${#COMP_WORDS[@]}-1]
COMPREPLY=( $( compgen -W '$( command ${COMP_WORDS[@]} | sed s/\(.*\)// )' \
-- "$cur" ) )
COMPREPLY=( $( compgen -W '$( command ${COMP_WORDS[@]} 2>/dev/null | \
sed s/\(.*\)// )' -- "$cur" ) )
} &&
complete -F _qdbus qdbus dcop

View File

@ -0,0 +1,3 @@
if {[assert_bash_type jarsigner]} {
source "lib/completions/jarsigner.exp"
}; # if

View File

@ -0,0 +1,3 @@
if {[assert_bash_type pack200]} {
source "lib/completions/pack200.exp"
}; # if

View File

@ -0,0 +1,3 @@
if {[assert_bash_type unpack200]} {
source "lib/completions/unpack200.exp"
}; # if

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
setup
assert_complete_any "jarsigner "
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
setup
assert_complete_any "pack200 "
sync_after_int
teardown

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
setup
assert_complete_any "unpack200 "
sync_after_int
teardown