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

This commit is contained in:
Freddy Vulto 2010-10-26 22:42:37 +02:00
commit bf763033b7
19 changed files with 105 additions and 77 deletions

12
CHANGES
View File

@ -9,13 +9,13 @@ bash-completion (2.x)
[ Ville Skyttä ] [ Ville Skyttä ]
* Activate hping2 completion also for hping and hping3. * Activate hping2 completion also for hping and hping3.
* Add badblocks, compgen, crontab, dumpe2fs, e2freefrag, e2label, ether-wake, * Add badblocks, compgen, crontab, dumpe2fs, e2freefrag, e2label, ether-wake,
filefrag, iftop, lrzip, POSIX sh, sysbench, tune2fs, xmodmap, and xrdb filefrag, iftop, lrzip, POSIX sh, sha{,224,256,384,512}sum, sysbench,
completions. tune2fs, xmodmap, and xrdb completions.
* Add *.gif (Alioth: #312512), *.m2t (Alioth: #312770), *.3gpp, *.3gpp2, * Add *.gif (Alioth: #312512), *.m2t (Alioth: #312770), *.3gpp, *.3gpp2,
and *.awb to mplayer filename completions. and *.awb to mplayer filename completions.
* Add "short" tarball extensions to unxz, unlzma etc completions. * Add "short" tarball extensions to unxz, unlzma etc completions.
* Improve /etc/init.d/*, ipmitool, jar, mencoder, mkdir, mplayer, povray, * Improve /etc/init.d/*, ipmitool, jar, man, mencoder, mkdir, mplayer,
sqlite3, wodim, and general help parsing completions. povray, rpmbuild, sqlite3, wodim, and general help parsing completions.
* Fix p4 and povray completions (Alioth: #312625). * Fix p4 and povray completions (Alioth: #312625).
* Add *.xsd, *.xsl, *.rng, and *.wsdl to xmllint filename completions. * Add *.xsd, *.xsl, *.rng, and *.wsdl to xmllint filename completions.
* Recognize rpm query mode based on the --file, --group, --package, and * Recognize rpm query mode based on the --file, --group, --package, and
@ -28,6 +28,10 @@ bash-completion (2.x)
* Fixes to completions for filenames containing tabs (RedHat: #629518). * Fixes to completions for filenames containing tabs (RedHat: #629518).
* Add *.m2t and *.m2ts to xine-based player filename completions * Add *.m2t and *.m2ts to xine-based player filename completions
(Alioth: #312770). (Alioth: #312770).
* Add /etc/ethers to MAC address completion sources.
* Add *.gem to tar completions.
* Complete known hosts from avahi-browse only if $COMP_KNOWN_HOSTS_WITH_AVAHI
is non-empty (Alioth: #312691, RedHat: #630326).
[ Freddy Vulto ] [ Freddy Vulto ]
* Added _tilde(), fix ~username completion (Alioth: #312613, Debian: #587095) * Added _tilde(), fix ~username completion (Alioth: #312613, Debian: #587095)

View File

@ -126,7 +126,7 @@ complete -f -X '!*.lyx' lyx
# start of section containing compspecs that can be handled within bash # start of section containing compspecs that can be handled within bash
# user commands see only users # user commands see only users
complete -u su passwd write chfn groups slay w sux complete -u su write chfn groups slay w sux
# bg completes with stopped jobs # bg completes with stopped jobs
complete -A stopped -P '"%' -S '"' bg complete -A stopped -P '"%' -S '"' bg
@ -712,6 +712,10 @@ _mac_addresses()
"s/.*[[:space:]]\($re\)[[:space:]].*/\1/p" -ne \ "s/.*[[:space:]]\($re\)[[:space:]].*/\1/p" -ne \
"s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p" ) ) "s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p" ) )
# /etc/ethers
COMPREPLY=( "${COMPREPLY[@]}" $( sed -ne \
"s/^[[:space:]]*\($re\)[[:space:]].*/\1/p" /etc/ethers 2>/dev/null ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
__ltrim_colon_completions "$cur" __ltrim_colon_completions "$cur"
} }
@ -1149,7 +1153,8 @@ _known_hosts()
# Helper function for completing _known_hosts. # Helper function for completing _known_hosts.
# This function performs host completion based on ssh's config and known_hosts # This function performs host completion based on ssh's config and known_hosts
# files, as well as hostnames reported by avahi-browse. Also hosts from # files, as well as hostnames reported by avahi-browse if
# COMP_KNOWN_HOSTS_WITH_AVAHI is set to a non-empty value. Also hosts from
# HOSTFILE (compgen -A hostname) are added, unless # HOSTFILE (compgen -A hostname) are added, unless
# COMP_KNOWN_HOSTS_WITH_HOSTFILE is set to an empty value. # COMP_KNOWN_HOSTS_WITH_HOSTFILE is set to an empty value.
# Usage: _known_hosts_real [OPTIONS] CWORD # Usage: _known_hosts_real [OPTIONS] CWORD
@ -1294,12 +1299,14 @@ _known_hosts_real()
-S "$suffix" -W "$hosts" -- "$cur" ) ) -S "$suffix" -W "$hosts" -- "$cur" ) )
fi fi
# Add hosts reported by avahi-browse, if it's available. # Add hosts reported by avahi-browse, if desired and it's available.
# The original call to avahi-browse also had "-k", to avoid lookups into if [[ ${COMP_KNOWN_HOSTS_WITH_AVAHI:-} ]] && \
# avahi's services DB. We don't need the name of the service, and if it type avahi-browse &>/dev/null; then
# contains ";", it may mistify the result. But on Gentoo (at least), # The original call to avahi-browse also had "-k", to avoid lookups
# -k isn't available (even if mentioned in the manpage), so... # into avahi's services DB. We don't need the name of the service, and
if type avahi-browse >&/dev/null; then # if it contains ";", it may mistify the result. But on Gentoo (at
# least), -k wasn't available (even if mentioned in the manpage) some
# time ago, so...
COMPREPLY=( "${COMPREPLY[@]}" $( \ COMPREPLY=( "${COMPREPLY[@]}" $( \
compgen -P "$prefix$user" -S "$suffix" -W \ compgen -P "$prefix$user" -S "$suffix" -W \
"$( avahi-browse -cpr _workstation._tcp 2>/dev/null | \ "$( avahi-browse -cpr _workstation._tcp 2>/dev/null | \
@ -1473,15 +1480,15 @@ _command_offset()
[ ${#COMPREPLY[@]} -eq 0 ] && _filedir [ ${#COMPREPLY[@]} -eq 0 ] && _filedir
} }
complete -F _command -o filenames nohup exec nice eval time ltrace then \ complete -F _command -o filenames aoss command do else eval exec ltrace nice \
else do vsound command xargs tsocks aoss padsp nohup padsp then time tsocks vsound xargs
_root_command() _root_command()
{ {
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
_command $1 $2 $3 _command $1 $2 $3
} }
complete -F _root_command -o filenames sudo fakeroot really gksudo gksu kdesudo complete -F _root_command -o filenames fakeroot gksu gksudo kdesudo really sudo
_longopt() _longopt()
{ {
@ -1514,12 +1521,12 @@ _longopt()
fi fi
} }
# makeinfo and texi2dvi are defined elsewhere. # makeinfo and texi2dvi are defined elsewhere.
for i in a2ps autoconf automake bc gprof ld nm objcopy objdump readelf strip \ for i in a2ps autoconf automake awk bash bc bison cat colordiff cp csplit \
bison colordiff diff patch enscript cp df dir du ln ls mkfifo mknod mv rm \ curl cut date df diff dir du enscript expand fmt fold gperf gprof grep \
touch vdir awk gperf grep grub indent less m4 sed shar date \ grub head indent irb ld ldd less ln ls m4 md5sum mkdir mkfifo mknod mv nl \
tee who texindex cat csplit cut expand fmt fold head \ nm objcopy objdump od paste patch pr ptx readelf rm rmdir sed \
md5sum nl od paste pr ptx sha1sum sort split tac tail tr unexpand \ sha{,1,224,256,384,512}sum shar sort split strip tac tail tee texindex \
uniq wc ldd bash id irb mkdir rmdir wget curl; do touch tr unexpand uniq vdir wc wget who; do
have $i && complete -F _longopt -o filenames $i have $i && complete -F _longopt -o filenames $i
done done

View File

@ -27,7 +27,8 @@ _mock()
_split_longopt && split=true _split_longopt && split=true
case $prev in case $prev in
-h|--help|--copyin|--copyout|--arch|-D|--define|--with|--without|--uniqueext|--rpmbuild_timeout|--sources|--cwd) -h|--help|--copyin|--copyout|--arch|-D|--define|--with|--without|\
--uniqueext|--rpmbuild_timeout|--sources|--cwd)
return 0 return 0
;; ;;
-r|--root) -r|--root)
@ -62,15 +63,13 @@ _mock()
$split && return 0 $split && return 0
if [[ "$cur" == -* ]] ; then if [[ "$cur" == -* ]] ; then
COMPREPLY=( $( compgen -W '--version --help --rebuild \ COMPREPLY=( $( compgen -W '--version --help --rebuild --buildsrpm
--buildsrpm --shell --chroot --clean --init \ --shell --chroot --clean --init --installdeps --install --update
--installdeps --install --update --orphanskill \ --orphanskill --copyin --copyout --root --offline --no-clean
--copyin --copyout --root --offline --no-clean \ --cleanup-after --no-cleanup-after --arch --target --define --with
--cleanup-after --no-cleanup-after --arch --target \ --without --resultdir --uniqueext --configdir --rpmbuild_timeout
--define --with --without --resultdir --uniqueext \ --unpriv --cwd --spec --sources --verbose --quiet --trace
--configdir --rpmbuild_timeout --unpriv --cwd --spec \ --enable-plugin --disable-plugin --print-root-path' -- "$cur" ) )
--sources --verbose --quiet --trace --enable-plugin \
--disable-plugin --print-root-path' -- "$cur" ) )
else else
_filedir '@(?(no)src.r|s)pm' _filedir '@(?(no)src.r|s)pm'
fi fi

View File

@ -10,7 +10,7 @@ _configure()
_split_longopt && split=true _split_longopt && split=true
case $prev in case $prev in
--prefix|--exec-prefix|--*dir) --*prefix|--*dir)
_filedir -d _filedir -d
;; ;;
esac esac

View File

@ -9,24 +9,24 @@ _dd()
_get_comp_words_by_ref -n = cur _get_comp_words_by_ref -n = cur
case $cur in case $cur in
if=*|of=*) if=*|of=*)
cur=${cur#*=} cur=${cur#*=}
_filedir _filedir
return 0 return 0
;; ;;
conv=*) conv=*)
cur=${cur#*=} cur=${cur#*=}
COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock \ COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock lcase
lcase notrunc ucase swab noerror sync' -- "$cur" ) ) notrunc ucase swab noerror sync' -- "$cur" ) )
return 0 return 0
;; ;;
esac esac
_expand || return 0 _expand || return 0
COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) \ COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) \
$( compgen -W 'bs cbs conv count ibs if obs of seek skip'\ $( compgen -W 'bs cbs conv count ibs if obs of seek skip' \
-S '=' -- "$cur" ) ) -S '=' -- "$cur" ) )
} && } &&
complete -F _dd -o nospace -o filenames dd complete -F _dd -o nospace -o filenames dd

View File

@ -27,7 +27,6 @@ _dselect()
remove quit' -- "$cur" ) ) remove quit' -- "$cur" ) )
fi fi
return 0 return 0
} && } &&
complete -F _dselect -o filenames dselect complete -F _dselect -o filenames dselect

View File

@ -144,8 +144,9 @@ _tune2fs()
return 0 return 0
;; ;;
-O) -O)
local -a opts=(^dir_index ^filetype ^flex_bg ^has_journal local -a opts=(^dir_index ^dir_nlink ^extent ^extra_isize ^filetype
^large_file ^resize_inode ^sparse_super ^uninit_bg) ^flex_bg ^has_journal ^huge_file ^large_file ^resize_inode
^sparse_super ^uninit_bg)
COMPREPLY=( $( compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur" ) )
return 0 return 0
;; ;;

View File

@ -11,7 +11,7 @@ _man()
mansect="@([0-9lnp]|[0-9][px]|3pm)" mansect="@([0-9lnp]|[0-9][px]|3pm)"
COMPREPLY=() COMPREPLY=()
_get_comp_words_by_ref cur prev _get_comp_words_by_ref -n : cur prev
if [[ "$prev" == -l ]]; then if [[ "$prev" == -l ]]; then
_filedir $manext _filedir $manext
@ -66,11 +66,9 @@ _man()
done done
fi fi
__ltrim_colon_completions "$cur"
return 0 return 0
} } &&
[ $USERLAND = GNU -o $UNAME = Darwin \
-o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
-o $UNAME = OpenBSD ] && \
complete -F _man -o filenames man apropos whatis complete -F _man -o filenames man apropos whatis
# Local variables: # Local variables:

View File

@ -51,13 +51,13 @@ _postmap()
esac esac
if [[ $cur == -* ]]; then if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '-N -f -i -n -o -p -r -v -w -c -d -q'\ COMPREPLY=( $( compgen -W '-N -f -i -n -o -p -r -v -w -c -d -q' \
-- "$cur" ) ) -- "$cur" ) )
return 0 return 0
fi fi
if [[ "$cur" == *:* ]]; then if [[ "$cur" == *:* ]]; then
COMPREPLY=( $( compgen -f -- "${cur#*:}" ) ) COMPREPLY=( $( compgen -f -- "${cur#*:}" ) )
else else
len=${#cur} len=${#cur}
idx=0 idx=0
@ -143,7 +143,7 @@ _postconf()
esac esac
if [[ $cur == -* ]]; then if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '-A -a -b -c -d -e -h -m -l -n -t -v'\ COMPREPLY=( $( compgen -W '-A -a -b -c -d -e -h -m -l -n -t -v' \
-- "$cur" ) ) -- "$cur" ) )
return 0 return 0
fi fi

View File

@ -43,8 +43,6 @@ _python()
-U -v -V -W -x -c" -- "$cur" ) ) -U -v -V -W -x -c" -- "$cur" ) )
fi fi
return 0 return 0
} && } &&
complete -F _python -o filenames python complete -F _python -o filenames python

View File

@ -248,7 +248,7 @@ _rpm()
elif [[ ${COMP_WORDS[1]} == -b* ]]; then elif [[ ${COMP_WORDS[1]} == -b* ]]; then
_filedir spec _filedir spec
else else
_filedir '@(t?(ar.)@([gx]z|bz?(2))|tar.@(lzma|Z))' _filedir '@(t?(ar.)@([gx]z|bz?(2))|tar?(.@(lzma|Z)))'
fi fi
;; ;;
--rebuild|--recompile) --rebuild|--recompile)
@ -260,7 +260,7 @@ _rpm()
fi fi
;; ;;
--tarbuild) --tarbuild)
_filedir '@(t?(ar.)@([gx]z|bz?(2))|tar.@(lzma|Z))' _filedir '@(t?(ar.)@([gx]z|bz?(2))|tar?(.@(lzma|Z)))'
;; ;;
--resign|--addsign) --resign|--addsign)
_filedir '[rs]pm' _filedir '[rs]pm'

View File

@ -11,11 +11,11 @@ _sbcl()
# completing an option (may or may not be separated by a space) # completing an option (may or may not be separated by a space)
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--core --noinform --help --version \ COMPREPLY=( $( compgen -W '--core --noinform --help --version
--sysinit --userinit --eval --noprint --disable-debugger \ --sysinit --userinit --eval --noprint --disable-debugger
--end-runtime-options --end-toplevel-options ' -- "$cur" ) ) --end-runtime-options --end-toplevel-options ' -- "$cur" ) )
else else
_filedir _filedir
fi fi
return 0 return 0

View File

@ -14,7 +14,8 @@ _useradd()
# with -u/--uid # with -u/--uid
case $prev in case $prev in
-c|--comment|-h|--help|-e|--expiredate|-f|--inactive|-k|--key|-p|--password|-u|--uid|-Z|--selinux-user) -c|--comment|-h|--help|-e|--expiredate|-f|--inactive|-k|--key|\
-p|--password|-u|--uid|-Z|--selinux-user)
return 0 return 0
;; ;;
-b|--base-dir|-d|--home|-k|--skel) -b|--base-dir|-d|--home|-k|--skel)
@ -64,7 +65,8 @@ _usermod()
# with -u/--uid # with -u/--uid
case $prev in case $prev in
-c|--comment|-d|--home|-e|--expiredate|-f|--inactive|-h|--help|-l|--login|-p|--password|-u|--uid|-Z|--selinux-user) -c|--comment|-d|--home|-e|--expiredate|-f|--inactive|-h|--help|\
-l|--login|-p|--password|-u|--uid|-Z|--selinux-user)
return 0 return 0
;; ;;
-g|--gid) -g|--gid)
@ -126,7 +128,8 @@ _chage()
_split_longopt && split=true _split_longopt && split=true
case $prev in case $prev in
-d|--lastday|-E|--expiredate|-h|--help|-I|--inactive|-m|--mindays|-M|--maxdays|-W|--warndays) -d|--lastday|-E|--expiredate|-h|--help|-I|--inactive|-m|--mindays|\
-M|--maxdays|-W|--warndays)
return 0 return 0
;; ;;
esac esac

View File

@ -19,20 +19,20 @@ _tar()
return 0 return 0
;; ;;
+([^IZzJjy])f) +([^IZzJjy])f)
ext='t@(ar?(.@(Z|gz|bz?(2)|lz?(ma)|xz))|gz|bz?(2)|lz?(ma)|xz)' ext='@(@(tar|gem)?(.@(Z|[gx]z|bz?(2)|lzma))|t@([glx]z|bz?(2)))'
regex='t\(ar\(\.\(Z\|gz\|bz2\?\|lzma\|xz\)\)\?\|gz\|bz2\?\|lzma\|xz\)' regex='\(\(tar\|gem\)\(\.\(Z\|[gx]z\|bz?(2)\|lzma\)\)\?\|t\([glx]z\|bz2\?\)\)'
;; ;;
*[Zz]*f) *[Zz]*f)
ext='t?(ar.)@(gz|Z)' ext='@(t?(ar.)|gem.)@(gz|Z)'
regex='t\(ar\.\)\?\(gz\|Z\)' regex='\(t\(ar\.\)\?\|gem\.\)\(gz\|Z\)'
;; ;;
*[Ijy]*f) *[Ijy]*f)
ext='t?(ar.)bz?(2)' ext='@(t?(ar.)|gem.)bz?(2)'
regex='t\(ar\.\)\?bz2\?' regex='\(t\(ar\.\)\?\|gem\.\)bz2\?'
;; ;;
*[J]*f) *[J]*f)
ext='t?(ar.)@(lz?(ma)|xz)' ext='@(t?(ar.)|gem.)@(lz?(ma)|xz)'
regex='t\(ar\.\)\?\(lzma\|xz\)\?' regex='\(t\(ar\.\)\?\|gem\.\)\(lzma\|xz\)\?'
;; ;;
*) *)
_filedir _filedir

View File

@ -19,7 +19,7 @@ Environment variables
*COMP_KNOWN_HOSTS_WITH_HOSTFILE*:: *COMP_KNOWN_HOSTS_WITH_HOSTFILE*::
If set and not null (default), known_hosts completion will complement If set and not null (default), known hosts completion will complement
hostnames from ssh's known_hosts_files with hostnames taken from the file hostnames from ssh's known_hosts_files with hostnames taken from the file
specified by the HOSTFILE shell variable (compgen -A hostname). If null, specified by the HOSTFILE shell variable (compgen -A hostname). If null,
known_hosts completion will omit hostnames from HOSTFILE. Omitting known_hosts completion will omit hostnames from HOSTFILE. Omitting
@ -27,6 +27,12 @@ Environment variables
local web development or ad-blocking. local web development or ad-blocking.
*COMP_KNOWN_HOSTS_WITH_AVAHI*::
If set and not null, known hosts completion will try to use `avahi-browse`
for additional completions. This may be a slow operation in some setups.
Default is unset.
*COMP_TAR_INTERNAL_PATHS*:: *COMP_TAR_INTERNAL_PATHS*::
If set and not null *before* sourcing bash_completion, `tar` completion If set and not null *before* sourcing bash_completion, `tar` completion
will do correct path completion for tar file contents. If unset or null, will do correct path completion for tar file contents. If unset or null,

0
test/fixtures/man/man1/bar.1.bz2 vendored Normal file
View File

0
test/fixtures/man/man1/foo.1 vendored Normal file
View File

View File

View File

@ -1,4 +1,5 @@
proc setup {} { proc setup {} {
assert_bash_exec {export MANPATH=$TESTDIR/fixtures/man}
save_env save_env
} }
@ -11,7 +12,19 @@ proc teardown {} {
setup setup
assert_complete_any "man man" assert_complete "bar" "man b"
sync_after_int
assert_complete "fixtures/man/man1/foo.1" "man fixtures/man/man1/f"
sync_after_int
assert_complete "Bash::Completion" "man Bash::C"
sync_after_int sync_after_int