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ä ]
* Activate hping2 completion also for hping and hping3.
* Add badblocks, compgen, crontab, dumpe2fs, e2freefrag, e2label, ether-wake,
filefrag, iftop, lrzip, POSIX sh, sysbench, tune2fs, xmodmap, and xrdb
completions.
filefrag, iftop, lrzip, POSIX sh, sha{,224,256,384,512}sum, sysbench,
tune2fs, xmodmap, and xrdb completions.
* Add *.gif (Alioth: #312512), *.m2t (Alioth: #312770), *.3gpp, *.3gpp2,
and *.awb to mplayer filename completions.
* Add "short" tarball extensions to unxz, unlzma etc completions.
* Improve /etc/init.d/*, ipmitool, jar, mencoder, mkdir, mplayer, povray,
sqlite3, wodim, and general help parsing completions.
* Improve /etc/init.d/*, ipmitool, jar, man, mencoder, mkdir, mplayer,
povray, rpmbuild, sqlite3, wodim, and general help parsing completions.
* Fix p4 and povray completions (Alioth: #312625).
* Add *.xsd, *.xsl, *.rng, and *.wsdl to xmllint filename completions.
* 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).
* Add *.m2t and *.m2ts to xine-based player filename completions
(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 ]
* 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
# 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
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" ) )
# /etc/ethers
COMPREPLY=( "${COMPREPLY[@]}" $( sed -ne \
"s/^[[:space:]]*\($re\)[[:space:]].*/\1/p" /etc/ethers 2>/dev/null ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
__ltrim_colon_completions "$cur"
}
@ -1149,7 +1153,8 @@ _known_hosts()
# Helper function for completing _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
# COMP_KNOWN_HOSTS_WITH_HOSTFILE is set to an empty value.
# Usage: _known_hosts_real [OPTIONS] CWORD
@ -1294,12 +1299,14 @@ _known_hosts_real()
-S "$suffix" -W "$hosts" -- "$cur" ) )
fi
# Add hosts reported by avahi-browse, if it's available.
# The original call to avahi-browse also had "-k", to avoid lookups into
# avahi's services DB. We don't need the name of the service, and if it
# contains ";", it may mistify the result. But on Gentoo (at least),
# -k isn't available (even if mentioned in the manpage), so...
if type avahi-browse >&/dev/null; then
# Add hosts reported by avahi-browse, if desired and it's available.
if [[ ${COMP_KNOWN_HOSTS_WITH_AVAHI:-} ]] && \
type avahi-browse &>/dev/null; then
# The original call to avahi-browse also had "-k", to avoid lookups
# into avahi's services DB. We don't need the name of the service, and
# 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[@]}" $( \
compgen -P "$prefix$user" -S "$suffix" -W \
"$( avahi-browse -cpr _workstation._tcp 2>/dev/null | \
@ -1473,15 +1480,15 @@ _command_offset()
[ ${#COMPREPLY[@]} -eq 0 ] && _filedir
}
complete -F _command -o filenames nohup exec nice eval time ltrace then \
else do vsound command xargs tsocks aoss padsp
complete -F _command -o filenames aoss command do else eval exec ltrace nice \
nohup padsp then time tsocks vsound xargs
_root_command()
{
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
_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()
{
@ -1514,12 +1521,12 @@ _longopt()
fi
}
# makeinfo and texi2dvi are defined elsewhere.
for i in a2ps autoconf automake bc gprof ld nm objcopy objdump readelf strip \
bison colordiff diff patch enscript cp df dir du ln ls mkfifo mknod mv rm \
touch vdir awk gperf grep grub indent less m4 sed shar date \
tee who texindex cat csplit cut expand fmt fold head \
md5sum nl od paste pr ptx sha1sum sort split tac tail tr unexpand \
uniq wc ldd bash id irb mkdir rmdir wget curl; do
for i in a2ps autoconf automake awk bash bc bison cat colordiff cp csplit \
curl cut date df diff dir du enscript expand fmt fold gperf gprof grep \
grub head indent irb ld ldd less ln ls m4 md5sum mkdir mkfifo mknod mv nl \
nm objcopy objdump od paste patch pr ptx readelf rm rmdir sed \
sha{,1,224,256,384,512}sum shar sort split strip tac tail tee texindex \
touch tr unexpand uniq vdir wc wget who; do
have $i && complete -F _longopt -o filenames $i
done

View File

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

View File

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

View File

@ -16,8 +16,8 @@ _dd()
;;
conv=*)
cur=${cur#*=}
COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock \
lcase notrunc ucase swab noerror sync' -- "$cur" ) )
COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock lcase
notrunc ucase swab noerror sync' -- "$cur" ) )
return 0
;;
esac
@ -25,7 +25,7 @@ _dd()
_expand || return 0
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" ) )
} &&
complete -F _dd -o nospace -o filenames dd

View File

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

View File

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

View File

@ -11,7 +11,7 @@ _man()
mansect="@([0-9lnp]|[0-9][px]|3pm)"
COMPREPLY=()
_get_comp_words_by_ref cur prev
_get_comp_words_by_ref -n : cur prev
if [[ "$prev" == -l ]]; then
_filedir $manext
@ -66,11 +66,9 @@ _man()
done
fi
__ltrim_colon_completions "$cur"
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
# Local variables:

View File

@ -51,7 +51,7 @@ _postmap()
esac
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" ) )
return 0
fi
@ -143,7 +143,7 @@ _postconf()
esac
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" ) )
return 0
fi

View File

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

View File

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

View File

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

View File

@ -14,7 +14,8 @@ _useradd()
# with -u/--uid
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
;;
-b|--base-dir|-d|--home|-k|--skel)
@ -64,7 +65,8 @@ _usermod()
# with -u/--uid
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
;;
-g|--gid)
@ -126,7 +128,8 @@ _chage()
_split_longopt && split=true
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
;;
esac

View File

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

View File

@ -19,7 +19,7 @@ Environment variables
*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
specified by the HOSTFILE shell variable (compgen -A hostname). If null,
known_hosts completion will omit hostnames from HOSTFILE. Omitting
@ -27,6 +27,12 @@ Environment variables
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*::
If set and not null *before* sourcing bash_completion, `tar` completion
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 {} {
assert_bash_exec {export MANPATH=$TESTDIR/fixtures/man}
save_env
}
@ -11,7 +12,19 @@ proc teardown {} {
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