summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Paleino <dapal@debian.org>2011-02-06 17:50:38 +0100
committerDavid Paleino <dapal@debian.org>2011-02-06 17:50:38 +0100
commita0bb238dc80e47a1f75ac97bc6fc3000eaffee05 (patch)
treeb025f5f7e356e4cba4fe0b0d2ee8911e54ace336
parent99522d8ce4a697b649d93796939a78fc98dd5297 (diff)
parentcb01d8ea5434c2c9f4826b35f5f687d7723102e8 (diff)
downloadbash-completion-a0bb238dc80e47a1f75ac97bc6fc3000eaffee05.tar.gz
Merge branch 'master' into 1.x
-rw-r--r--CHANGES6
-rw-r--r--bash_completion43
-rw-r--r--completions/java40
-rw-r--r--completions/mutt7
-rw-r--r--completions/rpm10
-rw-r--r--completions/service4
-rw-r--r--test/completion/javaws.exp1
-rw-r--r--test/lib/completions/javaws.exp20
-rw-r--r--test/lib/completions/xhost.exp17
-rw-r--r--test/lib/library.exp2
10 files changed, 99 insertions, 51 deletions
diff --git a/CHANGES b/CHANGES
index 5e2e02c7..8692b202 100644
--- a/CHANGES
+++ b/CHANGES
@@ -14,9 +14,9 @@ bash-completion (1.3)
[ Ville Skyttä ]
* Activate hping2 completion also for hping and hping3.
* Add badblocks, compgen, crontab, dumpe2fs, e2freefrag, e2label, ether-wake,
- filefrag, growisofs, iftop, ip (Debian: #600617), lrzip, lsof, mktemp,
- portecle, POSIX sh, sha{,224,256,384,512}sum, sysbench, tune2fs, xmodmap,
- and xrdb completions.
+ filefrag, gendiff, growisofs, iftop, ip (Debian: #600617), javaws, kid3,
+ lrzip, lsof, mktemp, portecle, POSIX sh, sha{,224,256,384,512}sum,
+ sysbench, tune2fs, xmodmap, and xrdb completions.
* Add *.gif (Alioth: #312512), *.m2t (Alioth: #312770), *.3gpp, *.3gpp2,
*.awb, and *.iso (Alioth: #311420) to mplayer filename completions.
* Add "short" tarball extensions to unxz, unlzma etc completions.
diff --git a/bash_completion b/bash_completion
index a9b8120a..97d25abb 100644
--- a/bash_completion
+++ b/bash_completion
@@ -123,6 +123,7 @@ complete -f -X '!*.ly' lilypond ly2dvi
complete -f -X '!*.@(dif?(f)|?(d)patch)?(.@([gx]z|bz2|lzma))' cdiff
complete -f -X '!*.lyx' lyx
complete -f -X '!@(*.@(ks|jks|jceks|p12|pfx|bks|ubr|gkr|cer|crt|cert|p7b|pkipath|pem|p10|csr|crl)|cacerts)' portecle
+complete -f -X '!*.@(mp[234c]|og[ag]|@(fl|a)ac|m4[abp]|spx|tta|w?(a)v|wma|aif?(f)|asf|ape)' kid3 kid3-qt
# FINISH exclude -- do not remove this line
# start of section containing compspecs that can be handled within bash
@@ -687,7 +688,7 @@ _split_longopt()
#
_parse_help() {
$1 ${2:---help} 2>&1 | sed -e '/^[[:space:]]*-/!d' -e 's|[,/]| |g' | \
- awk '{ print $1; if ($2 ~ /^-/) { print $2 } }' | sed -e 's|=.*||'
+ awk '{ print $1; if ($2 ~ /^-/) { print $2 } }' | sed -e 's|[<=].*||'
}
# This function completes on signal names
@@ -1244,12 +1245,10 @@ _known_hosts_real()
[ -r "$configfile" ] &&
config=( "${config[@]}" "$configfile" )
else
- [ -r /etc/ssh/ssh_config ] &&
- config=( "${config[@]}" "/etc/ssh/ssh_config" )
- [ -r "${HOME}/.ssh/config" ] &&
- config=( "${config[@]}" "${HOME}/.ssh/config" )
- [ -r "${HOME}/.ssh2/config" ] &&
- config=( "${config[@]}" "${HOME}/.ssh2/config" )
+ for i in /etc/ssh/ssh_config "${HOME}/.ssh/config" \
+ "${HOME}/.ssh2/config"; do
+ [ -r $i ] && config=( "${config[@]}" "$i" )
+ done
fi
# Known hosts files from configs
@@ -1271,28 +1270,16 @@ _known_hosts_real()
IFS=$OIFS
fi
- # Global known_hosts files
- if [ -z "$configfile" ]; then
- [ -r /etc/ssh/ssh_known_hosts ] &&
- kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts )
- [ -r /etc/ssh/ssh_known_hosts2 ] &&
- kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts2 )
- [ -r /etc/known_hosts ] &&
- kh=( "${kh[@]}" /etc/known_hosts )
- [ -r /etc/known_hosts2 ] &&
- kh=( "${kh[@]}" /etc/known_hosts2 )
- [ -d /etc/ssh2/knownhosts ] &&
- khd=( "${khd[@]}" /etc/ssh2/knownhosts/*pub )
- fi
-
- # User known_hosts files
if [ -z "$configfile" ]; then
- [ -r ~/.ssh/known_hosts ] &&
- kh=( "${kh[@]}" ~/.ssh/known_hosts )
- [ -r ~/.ssh/known_hosts2 ] &&
- kh=( "${kh[@]}" ~/.ssh/known_hosts2 )
- [ -d ~/.ssh2/hostkeys ] &&
- khd=( "${khd[@]}" ~/.ssh2/hostkeys/*pub )
+ # Global and user known_hosts files
+ for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 \
+ /etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts \
+ ~/.ssh/known_hosts2; do
+ [ -r $i ] && kh=( "${kh[@]}" $i )
+ done
+ for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do
+ [ -d $i ] && khd=( "${khd[@]}" $i/*pub )
+ done
fi
# If we have known_hosts files to use
diff --git a/completions/java b/completions/java
index eacd85e3..460ae285 100644
--- a/completions/java
+++ b/completions/java
@@ -1,13 +1,14 @@
# bash completion for java, javac and javadoc
# available path elements completion
-have java && {
+have java || have javac || have javadoc &&
_java_path()
{
cur=${cur##*:}
_filedir '@(jar|zip)'
}
+have java || have javadoc && {
# exact classpath determination
_java_find_classpath()
{
@@ -60,7 +61,7 @@ _java_classes()
cur=${cur//.//}
# parse each classpath element for classes
for i in ${classpath//:/ }; do
- if [[ -r $i && "$i" == *.@(jar|zip) ]]; then
+ if [[ "$i" == *.@(jar|zip) && -r $i ]]; then
if type zipinfo &>/dev/null; then
COMPREPLY=( "${COMPREPLY[@]}" $( zipinfo -1 \
"$i" "$cur*" 2>/dev/null | \
@@ -113,9 +114,11 @@ _java_packages()
# convert path syntax to package syntax
cur=${COMPREPLY[@]//\//.}
}
+}
# java completion
#
+have java &&
_java()
{
local cur prev words cword i
@@ -230,9 +233,8 @@ _java()
type compopt &>/dev/null && compopt -o nospace
__ltrim_colon_completions "$cur"
-}
+} &&
complete -F _java java
-}
have javadoc &&
_javadoc()
@@ -492,6 +494,36 @@ _jarsigner()
} &&
complete -F _jarsigner jarsigner
+have javaws &&
+_javaws()
+{
+ COMPREPLY=()
+ local cur prev
+ _get_comp_words_by_ref cur prev
+
+ case $prev in
+ -help|-license|-about|-viewer|-arg|-param|-property|-update|-umask)
+ return 0
+ ;;
+ -basedir|-codebase)
+ _filedir -d
+ return 0
+ ;;
+ -uninstall|-import)
+ _filedir jnlp
+ return 0
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=( $( compgen -W "$( _parse_help "$1" -help ) " -- "$cur" ) )
+ return 0
+ fi
+
+ _filedir jnlp
+} &&
+complete -F _javaws javaws
+
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
diff --git a/completions/mutt b/completions/mutt
index a753a652..e5e9d289 100644
--- a/completions/mutt
+++ b/completions/mutt
@@ -37,8 +37,11 @@ _muttrc()
done
if [ -z "$muttrc" ]; then
- [ -f ~/.${muttcmd}/${muttcmd}rc ] && muttrc="~/.${muttcmd}/${muttcmd}rc"
- [ -f ~/.${muttcmd}rc ] && muttrc="~/.${muttcmd}rc"
+ if [ -f ~/.${muttcmd}rc ]; then
+ muttrc="~/.${muttcmd}rc"
+ elif [ -f ~/.${muttcmd}/${muttcmd}rc ]; then
+ muttrc="~/.${muttcmd}/${muttcmd}rc"
+ fi
fi
printf "%s" "$muttrc"
} # _muttrc()
diff --git a/completions/rpm b/completions/rpm
index f07ba7de..bbab0368 100644
--- a/completions/rpm
+++ b/completions/rpm
@@ -290,6 +290,16 @@ _rpm()
complete -F _rpm rpm rpmbuild
}
+have gendiff &&
+_gendiff()
+{
+ COMPREPLY=()
+ local cur cword
+ _get_comp_words_by_ref cur cword
+ [[ $cword != 1 ]] || _filedir -d
+} &&
+complete -F _gendiff gendiff
+
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
diff --git a/completions/service b/completions/service
index ffd24366..1a36f59b 100644
--- a/completions/service
+++ b/completions/service
@@ -19,11 +19,11 @@ _service()
# don't complete past 2nd token
[ $COMP_CWORD -gt 2 ] && return 0
- [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
-
if [[ $COMP_CWORD -eq 1 && $prev == "service" ]]; then
_services
else
+ [ -d /etc/rc.d/init.d ] && \
+ sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
-ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
$sysvdir/${prev##*/} 2>/dev/null`' -- "$cur" ) )
diff --git a/test/completion/javaws.exp b/test/completion/javaws.exp
new file mode 100644
index 00000000..c1c6b106
--- /dev/null
+++ b/test/completion/javaws.exp
@@ -0,0 +1 @@
+assert_source_completions javaws
diff --git a/test/lib/completions/javaws.exp b/test/lib/completions/javaws.exp
new file mode 100644
index 00000000..cb29c65a
--- /dev/null
+++ b/test/lib/completions/javaws.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "javaws "
+
+
+sync_after_int
+
+
+teardown
diff --git a/test/lib/completions/xhost.exp b/test/lib/completions/xhost.exp
index d4098ade..82e2e9c6 100644
--- a/test/lib/completions/xhost.exp
+++ b/test/lib/completions/xhost.exp
@@ -13,12 +13,7 @@ setup
set test "Tab should complete hostnames"
- # Build string list of hostnames
-set hosts {}
-foreach h [exec bash -c "compgen -A hostname"] {
- lappend hosts $h
-}
-assert_complete $hosts "xhost " $test
+assert_complete [get_hosts] "xhost " $test
sync_after_int
@@ -28,7 +23,7 @@ set test "Tab should complete partial hostname"
# Build string list of hostnames, starting with the character of the first hostname
set hosts {}
set char ""
-foreach h [exec bash -c "compgen -A hostname"] {
+foreach h [get_hosts] {
if {$char == ""} {set char [string range $h 0 0]}
# Only append hostname if starting with $char
if {[string range $h 0 0] == "$char"} {
@@ -44,7 +39,7 @@ sync_after_int
set test "Tab should complete hostnames prefixed with +"
# Build string list of hostnames, prefixed with plus (+)
set hosts {}
-foreach h [exec bash -c "compgen -A hostname"] {
+foreach h [get_hosts] {
lappend hosts "+$h"
}
assert_complete $hosts "xhost \+" $test
@@ -56,7 +51,7 @@ sync_after_int
set test "Tab should complete partial hostname prefixed with +"
# Build string list of hostnames, starting with character of first host.
set hosts {}
-foreach h [exec bash -c "compgen -A hostname"] {
+foreach h [get_hosts] {
if {$char == ""} {set char [string range $h 0 0]}
# Only append hostname if starting with $char
if {[string range $h 0 0] == "$char"} {
@@ -72,7 +67,7 @@ sync_after_int
set test "Tab should complete hostnames prefixed with -"
# Build string list of hostnames, prefix with minus (-)
set hosts {}
-foreach h [exec bash -c "compgen -A hostname"] {
+foreach h [get_hosts] {
lappend hosts "-$h"
}
assert_complete $hosts "xhost -" $test
@@ -84,7 +79,7 @@ sync_after_int
set test "Tab should complete partial hostname prefixed with -"
# Build list of hostnames, starting with character of first host
set hosts {}
-foreach h [exec bash -c "compgen -A hostname"] {
+foreach h [get_hosts] {
if {$char == ""} {set char [string range $h 0 0]}
# Only append hostname if starting with $char
if {[string range $h 0 0] == "$char"} {
diff --git a/test/lib/library.exp b/test/lib/library.exp
index 61b3f409..491da212 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -636,7 +636,7 @@ proc get_known_hosts {{cword ''}} {
# @return list Hostnames
# @see get_known_hosts()
proc get_hosts {} {
- set hosts [exec bash -c "compgen -A hostname"]
+ set hosts [exec bash -c "compgen -A hostname | sort -u"]
# NOTE: Circumventing var `avahi_hosts' and appending directly to `hosts'
# causes an empty element to be inserted in `hosts'.
# -- FVu, Fri Jul 17 23:11:46 CEST 2009