diff --git a/CHANGES b/CHANGES index 92f05543..d685f93f 100644 --- a/CHANGES +++ b/CHANGES @@ -38,8 +38,9 @@ bash-completion (1.x) * Add _split_longopt() helper for improved handling of long options that take arguments in both "--foo bar" and "--foo=bar" formats. * Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig, - iptables, make, mii-diag, mii-tool, mkinitrd, smartctl, and generic long - option completion (Alioth: #311398). + cpio, iptables, make, mc, mii-diag, mii-tool, mkinitrd, postgresql, + quota, samba, smartctl, and generic long option completion + (Alioth: #311398). * Add chown --from and --reference value completions. * Add chgrp --reference value completion. * Do not assume all --foo= options take filenames in generic long option @@ -49,6 +50,11 @@ bash-completion (1.x) * Fix leaking $prev from cpio, dsniff, freeciv, gkrellm, mkinitrd, and tcpdump completions. * Split ant completion to contrib/ant, improve the built in one. + * Improve postfix completion. + * Improve samba completion. + * Split lilo completion to contrib/lilo. + * Split reportbug and querybts completions to contrib/reportbug. + * Remove debug output noise from quotaon completion. [ Todd Zullinger ] * Make yum complete on filenames after install, deplist, update and upgrade diff --git a/Makefile.am b/Makefile.am index 6cf11d22..0644d7a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,6 +42,7 @@ bashcomp_DATA = contrib/ant \ contrib/larch \ contrib/ldapvi \ contrib/lftp \ + contrib/lilo \ contrib/lilypond \ contrib/links \ contrib/lisp \ @@ -78,6 +79,7 @@ bashcomp_DATA = contrib/ant \ contrib/quota-tools \ contrib/rdesktop \ contrib/repomanage \ + contrib/reportbug \ contrib/ri \ contrib/rcs \ contrib/rpcdebug \ diff --git a/bash_completion b/bash_completion index cc67fae6..28cb85fd 100644 --- a/bash_completion +++ b/bash_completion @@ -1008,7 +1008,7 @@ complete -F _insmod $filenames insmod modprobe modinfo -o $UNAME = OpenBSD ] && _man() { - local cur prev sect manpath manext mansect UNAME + local cur prev sect manpath manext mansect uname manext="@([0-9lnp]|[0-9][px]|man)?(.@(gz|bz2|lzma))" mansect="@([0-9lnp]|[0-9][px])" @@ -1030,11 +1030,8 @@ _man() return 0 fi - UNAME=$( uname -s ) - # strip OS type and version under Cygwin - UNAME=${UNAME/CYGWIN_*/Cygwin} - if [ $USERLAND = GNU -o $UNAME = FreeBSD \ - -o $UNAME = Cygwin ]; then + uname=$( uname -s ) + if [[ $uname == @(Linux|GNU|GNU/*|FreeBSD|Cygwin|CYGWIN_*) ]]; then manpath=$( manpath 2>/dev/null || command man --path ) else manpath=$MANPATH @@ -3376,181 +3373,6 @@ _configure_func() } complete -F _configure_func $default configure -# Debian reportbug(1) completion -# -have reportbug && -_reportbug() -{ - local cur prev - - COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} - - case "$prev" in - -f|--filename|-i|--include|--mta|-o|--output) - _filedir - return 0 - ;; - -B|--bts) - COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \ - $cur )) - return 0 - ;; - -e|--editor|--mua) - COMP_WORDS=(COMP_WORDS[0] $cur) - COMP_CWORD=1 - _command - return 0 - ;; - --mode) - COMPREPLY=( $( compgen -W "novice standard expert" -- $cur ) ) - return 0 - ;; - -S|--severity) - COMPREPLY=( $( compgen -W "grave serious important normal \ - minor wishlist" -- $cur ) ) - return 0 - ;; - -u|--ui|--interface) - COMPREPLY=( $( compgen -W "newt text gnome" -- $cur ) ) - return 0 - ;; - -t|--type) - COMPREPLY=( $( compgen -W "gnats debbugs" -- $cur ) ) - return 0 - ;; - -T|--tags) - COMPREPLY=( $( compgen -W "none \ - woody potato sarge sarge-ignore etch etch-ignore \ - lenny lenny-ignore sid experimental confirmed \ - d-i fixed fixed-in-experimental fixed-upstream \ - help l10n moreinfo patch pending security \ - unreproducible upstream wontfix ipv6 lfs" -- $cur )) - return 0 - ;; - *) - ;; - esac - - COMPREPLY=($( compgen -W '-h --help -v --version -a --af -b \ - --no-query-bts --query-bts -B --bts -c --configure \ - --no-config-files --check-available -d --debug \ - --no-check-available -e --editor --email -f \ - --filename -g --gnupg -H --header -i --include -j \ - --justification -l --ldap --no-ldap -L --list-cc -m \ - --maintonly --mode --mua --mta --mutt -n --mh --nmh \ - -o --output -p --print -P --pgp --proxy --http_proxy\ - -q --quiet -Q --query-only --realname --report-quiet \ - --reply-to --replyto -s --subject -S --severity \ - --smtphost -t --type -T --tags --template -V -x \ - --no-cc --package-version -z --no-compress \ - --ui --interface -u \ - wnpp boot-floppies kernel bugs.debian.org \ - cdimage.debian.org general installation-reports \ - listarchives lists.debian.org mirrors nm.debian.org \ - press project qa.debian.org release-notes \ - security.debian.org tech-ctte upgrade-reports \ - www.debian.org' -- $cur ) \ - $( apt-cache pkgnames -- $cur 2> /dev/null) ) - _filedir - return 0 -} && -complete -F _reportbug $filenames reportbug - -# Debian querybts(1) completion -# -have querybts && -_querybts() -{ - local cur prev - - COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} - - case "$prev" in - -B|--bts) - COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \ - $cur )) - return 0 - ;; - -u|--ui|--interface) - COMPREPLY=($( compgen -W "newt text gnome" -- $cur )) - return 0 - ;; - *) - ;; - esac - - COMPREPLY=($( compgen -W '-h --help -v --version -A --archive \ - -B --bts -l --ldap --no-ldap --proxy= --http_proxy= \ - -s --source -w --web -u --ui --interface \ - wnpp boot-floppies kernel bugs.debian.org \ - cdimage.debian.org general installation-reports \ - listarchives lists.debian.org mirrors nm.debian.org \ - press project qa.debian.org release-notes \ - security.debian.org tech-ctte upgrade-reports \ - www.debian.org' -- $cur ) \ - $( apt-cache pkgnames -- $cur 2> /dev/null) ) -} && -complete -F _querybts $filenames querybts - -# lilo(8) completion -# -have lilo && { -_lilo_labels() -{ - COMPREPLY=( $( awk -F'=' '/label/ {print $2}' \ - /etc/lilo.conf | sed -e 's/"//g' | grep "^$cur" ) ) -} - -_lilo() -{ - local cur prev - - COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} - - case $prev in - -@(C|i|m|s|S)) - _filedir - return 0 - ;; - -r) - _filedir -d - return 0 - ;; - -@(I|D|R)) - # label completion - _lilo_labels - return 0 - ;; - -@(A|b|M|u|U)) - # device completion - cur=${cur:=/dev/} - _filedir - return 0 - ;; - -T) - # topic completion - COMPREPLY=( $( compgen -W 'help ChRul EBDA geom geom= \ - table= video' -- $cur ) ) - return 0 - ;; - esac - - if [[ "$cur" == -* ]]; then - # relevant options completion - COMPREPLY=( $( compgen -W '-A -b -c -C -d -f -g -i -I -l -L -m \ - -M -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- \ - $cur ) ) - fi -} -complete -F _lilo lilo -} - [ $UNAME = FreeBSD ] && { # FreeBSD package management tool completion # @@ -4032,7 +3854,7 @@ unset i [ $BASH_COMPLETION != ~/.bash_completion -a -r ~/.bash_completion ] \ && . ~/.bash_completion unset -f have -unset UNAME default dirnames filenames have nospace bashdefault plusdirs +unset UNAME USERLAND default dirnames filenames have nospace bashdefault plusdirs set $BASH_COMPLETION_ORIGINAL_V_VALUE unset BASH_COMPLETION_ORIGINAL_V_VALUE diff --git a/contrib/cpio b/contrib/cpio index 84bebcf3..9bab21b0 100644 --- a/contrib/cpio +++ b/contrib/cpio @@ -11,51 +11,35 @@ _cpio_format() _cpio() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + # --name value style option case $prev in - -H) + -H|--format) _cpio_format return 0 ;; - -@(E|F|I)) + -@(E|F|I|-?(pattern-)file)) _filedir return 0 ;; - -R) + -R|--owner) _usergroup return 0 ;; + --rsh-command) + COMPREPLY=( $( compgen -c -- $cur ) ) + return 0 + ;; esac - # --name=value style option - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --format) - _cpio_format - return 0 - ;; - --@(file|pattern-file)) - _filedir - return 0 - ;; - --owner) - _usergroup - return 0 - ;; - --rsh-command) - COMPREPLY=( $( compgen -c -- $cur ) ) - return 0 - ;; - esac - fi + $split && return 0 if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through' -- $cur) ) @@ -64,11 +48,11 @@ _cpio() -@(o|-create)) if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-0 -a -c -v -A -B\ - -L -V -C -H -M -O -F --file= --format=\ - --message= --null --reset-access-time\ - --verbose --dot --append --block-size=\ - --dereference --io-size= --quiet\ - --force-local --rsh-command= --help\ + -L -V -C -H -M -O -F --file --format\ + --message --null --reset-access-time\ + --verbose --dot --append --block-size\ + --dereference --io-size --quiet\ + --force-local --rsh-command --help\ --version' -- $cur ) ) fi ;; @@ -76,18 +60,18 @@ _cpio() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-b -c -d -f -m -n -r\ -t -s -u -v -B -S -V -C -E -H -M -R -I\ - -F --file= --make-directories\ + -F --file --make-directories\ --nonmatching\ --preserve-modification-time\ --numeric-uid-gid --rename -t --list\ --swap-bytes --swap --dot\ - --unconditional --verbose --block-size=\ - --swap-halfwords --io-size=\ - --pattern-file= --format= --owner=\ - --no-preserve-owner --message=\ + --unconditional --verbose --block-size\ + --swap-halfwords --io-size\ + --pattern-file --format --owner\ + --no-preserve-owner --message\ --force-local --no-absolute-filenames\ --sparse --only-verify-crc --quiet\ - --rsh-command= --help\ + --rsh-command --help\ --version' -- $cur ) ) fi ;; @@ -98,7 +82,7 @@ _cpio() --make-directories --link --quiet\ --preserve-modification-time\ --unconditional --verbose --dot\ - --dereference --owner=\ + --dereference --owner\ --no-preserve-owner --sparse --help\ --version' -- $cur ) ) else diff --git a/contrib/lilo b/contrib/lilo new file mode 100644 index 00000000..dc8b0c34 --- /dev/null +++ b/contrib/lilo @@ -0,0 +1,57 @@ +# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*- +# ex: ts=8 sw=8 noet filetype=sh +# +# bash completion for lilo(8) + +have lilo && { +_lilo_labels() +{ + COMPREPLY=( $( compgen -W "$( awk -F'=' '/label/ {print $2}' \ + /etc/lilo.conf | sed -e 's/\"//g' )" -- $cur ) ) +} + +_lilo() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case $prev in + -@(C|i|m|s|S)) + _filedir + return 0 + ;; + -r) + _filedir -d + return 0 + ;; + -@(I|D|R)) + # label completion + _lilo_labels + return 0 + ;; + -@(A|b|M|u|U)) + # device completion + cur=${cur:=/dev/} + _filedir + return 0 + ;; + -T) + # topic completion + COMPREPLY=( $( compgen -W 'help ChRul EBDA geom geom= \ + table= video' -- $cur ) ) + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + # relevant options completion + COMPREPLY=( $( compgen -W '-A -b -c -C -d -f -g -i -I -l -L -m \ + -M -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- \ + $cur ) ) + fi +} +complete -F _lilo lilo +} diff --git a/contrib/mc b/contrib/mc index 4c9fc2d2..96de7fbf 100644 --- a/contrib/mc +++ b/contrib/mc @@ -6,38 +6,38 @@ have mc && _mc() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} - # -name value style option + _split_longopt && split=true + case "$prev" in - -@(e|v|l|P)) + -e|--edit|-v|--view|-l|--ftplog|-P|--printwd) _filedir return 0 ;; + -C|--colors|-D|--debuglevel) + # argument required but no completions available + return 0 + ;; + -h|--help|-V|--version) + # all other arguments are noop with these + return 0 + ;; esac - # --name=value style option - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case "$prev" in - --@(edit|view|ftplog|printwd)) - _filedir - return 0 - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-a --stickchars -b --nocolor -c \ - --color -C --colors= -d --nomouse -e --edit= -f \ - --datadir -k --resetsoft -l --ftplog= -P --printwd= \ + --color -C --colors -d --nomouse -e --edit -f \ + --datadir -k --resetsoft -l --ftplog -P --printwd \ -s --slow -t --termcap -u --nosubshell -U --subshell \ - -v --view= -V --version -x --xterm -h --help' -- $cur ) ) + -v --view -V --version -x --xterm -D --debuglevel -h \ + --help' -- $cur ) ) else _filedir -d fi diff --git a/contrib/postfix b/contrib/postfix index b12bdece..be0d5ab2 100644 --- a/contrib/postfix +++ b/contrib/postfix @@ -10,25 +10,30 @@ _postfix() { local cur prev + COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} - if [[ $cur == '-' ]]; then - COMPREPLY=(-c -D -v) + case $prev in + -c) + _filedir -d + return 0 + ;; + -D) + COMPREPLY=( $( compgen -W 'start' -- $cur ) ) + return 0 + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '-c -D -v' -- $cur ) ) return 0 fi - if [[ $prev == '-c' ]]; then - _filedir -d - return 0 - fi - if [[ $prev == '-D' ]]; then - COMPREPLY=( $( compgen -W 'start' -- "`_get_cword`" ) ) - return 0 - fi - COMPREPLY=( $( compgen -W 'start stop reload abort flush check' -- \ - "`_get_cword`" ) ) + + COMPREPLY=( $( compgen -W 'check start stop abort flush reload status \ + set-permissions upgrade-configuration' -- $cur ) ) } -complete -F _postfix postfix +complete -F _postfix $filenames postfix # postalias(1) and postmap(1) # @@ -36,18 +41,23 @@ _postmap() { local cur prev len idx + COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} - if [[ $cur == '-' ]]; then - COMPREPLY=(-N -f -i -n -o -p -r -v -w -c -d -q) - return 0 - fi - if [[ $prev == '-c' ]]; then - _filedir -d - return 0 - fi - if [[ $prev == -[dq] ]]; then + case $prev in + -c) + _filedir -d + return 0 + ;; + -[dq]) + return 0 + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '-N -f -i -n -o -p -r -v -w -c -d -q'\ + -- $cur ) ) return 0 fi @@ -68,7 +78,7 @@ _postmap() fi return 0 } -complete -F _postmap postmap postalias +complete -F _postmap $filenames postmap postalias # postcat(1) # @@ -76,15 +86,19 @@ _postcat() { local cur prev pval len idx qfile + COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} - if [[ $cur == '-' ]]; then - COMPREPLY=(-c -q -v) - return 0 - fi - if [[ $prev == '-c' ]]; then - _filedir -d + case $prev in + -c) + _filedir -d + return 0 + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '-c -q -v' -- $cur ) ) return 0 fi @@ -95,7 +109,7 @@ _postcat() if [[ $qfile == 1 ]]; then len=${#cur} idx=0 - for pval in $( mailq | \ + for pval in $( mailq 2>/dev/null | \ sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do if [[ "$cur" == "${pval:0:$len}" ]]; then COMPREPLY[$idx]=$pval @@ -108,7 +122,7 @@ _postcat() return 0 fi } -complete -F _postcat postcat +complete -F _postcat $filenames postcat # postconf(1) # @@ -116,23 +130,34 @@ _postconf() { local cur prev pval len idx eqext + COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} - if [[ $cur == '-' ]]; then - COMPREPLY=(-c -d -e -h -m -l -n -v) + + case $prev in + -b|-t) + _filedir + return 0 + ;; + -c) + _filedir -d + return 0 + ;; + -e) + cur=${cur#[\"\']} + eqext='=' + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '-A -a -b -c -d -e -h -m -l -n -t -v'\ + -- $cur ) ) return 0 fi - if [[ $prev == '-c' ]]; then - _filedir -d - return 0 - fi - if [[ $prev == '-e' ]]; then - cur=${cur#[\"\']} - eqext='=' - fi + len=${#cur} idx=0 - for pval in $( /usr/sbin/postconf | cut -d ' ' -f 1 ); do + for pval in $( /usr/sbin/postconf 2>/dev/null | cut -d ' ' -f 1 ); do if [[ "$cur" == "${pval:0:$len}" ]]; then COMPREPLY[$idx]="$pval$eqext" idx=$(($idx+1)) @@ -140,7 +165,7 @@ _postconf() done return 0 } -complete -F _postconf postconf +complete -F _postconf $filenames postconf # postsuper(1) # @@ -148,53 +173,59 @@ _postsuper() { local cur prev pval len idx + COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} - if [[ $cur == '-' ]]; then - COMPREPLY=(-c -d -h -H -p -r -s -v) + case $prev in + -c) + _filedir -d + return 0 + ;; + -[dr]) + len=${#cur} + idx=0 + for pval in $( echo ALL; mailq 2>/dev/null | \ + sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do + if [[ "$cur" == "${pval:0:$len}" ]]; then + COMPREPLY[$idx]=$pval + idx=$(($idx+1)) + fi + done + return 0 + ;; + -h) + len=${#cur} + idx=0 + for pval in $( echo 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 + idx=$(($idx+1)) + fi + done + return 0 + ;; + -H) + len=${#cur} + idx=0 + for pval in $( echo 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 + idx=$(($idx+1)) + fi + done + return 0 + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '-c -d -h -H -p -r -s -v' -- $cur ) ) return 0 fi - case $prev in - -[dr]) - len=${#cur} - idx=0 - for pval in $( echo ALL; mailq | \ - sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do - if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY[$idx]=$pval - idx=$(($idx+1)) - fi - done - return 0 - ;; - -h) - len=${#cur} - idx=0 - for pval in $( echo ALL; mailq | \ - sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//; /!$/d' ); do - if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY[$idx]=$pval - idx=$(($idx+1)) - fi - done - return 0 - ;; - -H) - len=${#cur} - idx=0 - for pval in $( echo ALL; mailq | \ - sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do - if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY[$idx]=$pval - idx=$(($idx+1)) - fi - done - return 0 - ;; - esac + COMPREPLY=( $( compgen -W 'hold incoming active deferred' -- $cur ) ) - return 0 } -complete -F _postsuper postsuper +complete -F _postsuper $filenames postsuper } diff --git a/contrib/postgresql b/contrib/postgresql index d0b974eb..cdd3ca14 100644 --- a/contrib/postgresql +++ b/contrib/postgresql @@ -24,27 +24,40 @@ _pg_users() # _createdb() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case "$prev" in - -@(h|-host=)) - _known_hosts - return 0 - ;; - -@(U|-username=)) - _pg_users - return 0 - ;; + -h|--host) + _known_hosts + return 0 + ;; + -U|--username|-O|--owner) + _pg_users + return 0 + ;; + -p|--port|-D|--tablespace|-E|--encoding|-T|--template) + # argument required but no completions available + return 0 + ;; + --help|--version) + # all other arguments are noop with these + return 0 + ;; esac + $split && return 0 + if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-D -T -E -h -p -U -W -e -q \ - --location= --template= --encoding= --host= --port= \ - --username= --password --echo --quiet --help' -- $cur )) + --tablespace --template --encoding --host --port \ + --username --password --echo --quiet --help --version' \ + -- $cur )) else _pg_databases fi @@ -55,27 +68,35 @@ complete -F _createdb $default createdb # _dropdb() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case "$prev" in - -@(h|-host=)) - _known_hosts - return 0 - ;; - -@(U|-username=)) - _pg_users - return 0 - ;; + -h|--host) + _known_hosts + return 0 + ;; + -U|--username) + _pg_users + return 0 + ;; + --help|--version) + # all other arguments are noop with these + return 0 + ;; esac + $split && return 0 + if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-h -p -U -W -e -q \ - --host= --port= --username= --password \ - --interactive --echo --quiet --help' -- $cur ) ) + COMPREPLY=( $( compgen -W '-h -p -U -W -i -e -q \ + --host --port --username --password --interactive \ + --echo --quiet --help --version' -- $cur ) ) else _pg_databases fi @@ -86,46 +107,60 @@ complete -F _dropdb $default dropdb # _psql() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case "$prev" in - -h|--host) - _known_hosts - return 0 - ;; - -U|--username) - _pg_users - return 0 - ;; - -d|--dbname) - _pg_databases - return 0 - ;; - -@(o|f)|--output|--file) - _filedir - return 0 - ;; + -h|--host) + _known_hosts + return 0 + ;; + -U|--username) + _pg_users + return 0 + ;; + -d|--dbname) + _pg_databases + return 0 + ;; + -o|--output|-f|--file|-L|--log-file) + _filedir + return 0 + ;; + -c|--command|-F|--field-separator|-p|--port|-P|--pset|\ + -R|--record-separator|-T|--table-attr|-v|--set|--variable) + # argument required but no completions available + return 0 + ;; + -\?|--help|-V|--version) + # all other arguments are noop with these + return 0 + ;; esac + $split && return 0 + if [[ "$cur" == -* ]]; then # return list of available options COMPREPLY=( $( compgen -W '-a --echo-all -A --no-align \ -c --command -d --dbname -e --echo-queries \ - -E --echo-hidden -f --file -F --filed-separator \ - -h --host -H --html -l --list -n -o --output \ - -p --port -P --pset -q -R --record-separator \ - -s --single-step -S --single-line -t --tuples-only \ - -T --table-attr -U --username -v --variable \ - -V --version -W --password -x --expanded -X --nopsqlrc \ - -? --help ' -- $cur ) ) + -E --echo-hidden -f --file -F --field-separator \ + -h --host -H --html -l --list -L --log-file -n \ + -o --output -p --port -P --pset -q --quiet \ + -R --record-separator -s --single-step \ + -S --single-line -t --tuples-only -T --table-attr \ + -U --username -v --set --variable -V --version \ + -W --password -x --expanded -X --no-psqlrc \ + -1 --single-transaction -? --help' -- $cur ) ) else # return list of available databases _pg_databases fi } -complete -F _psql $default psql +complete -F _psql $filenames psql } diff --git a/contrib/quota-tools b/contrib/quota-tools index f77d1c35..d3eb273c 100644 --- a/contrib/quota-tools +++ b/contrib/quota-tools @@ -35,32 +35,25 @@ _filesystems() _quota() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in - -F) + -F|--format) _quota_formats return 0 ;; esac - - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --format) - _quota_formats - return 0 - ;; - esac - fi + + $split && return 0 if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-F --format= -g --group -u --user -v --verbose \ + COMPREPLY=( $( compgen -W '-F --format -g --group -u --user -v --verbose \ -s --human-readable -p --raw-grace -i --no-autofs -l --local-only \ -A --all-nfs -m --no-mixed-pathnames -q --quiet -Q --quiet-refuse \ -w --no-wrap' -- $cur ) ) @@ -72,33 +65,26 @@ complete -F _quota $default quota _setquota() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in - -F) + -F|--format) _quota_formats return 0 ;; esac - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --format) - _quota_formats - return 0 - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \ - -F --format= -g --group -u --user -p --prototype= -b --batch \ + -F --format -g --group -u --user -p --prototype -b --batch \ -c --continue-batch -t --edit-period -T --edit-times -a --all' -- $cur ) ) else _count_args @@ -118,14 +104,16 @@ complete -F _setquota $default setquota _edquota() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in - -F) + -F|--format) _quota_formats return 0 ;; @@ -135,20 +123,11 @@ _edquota() ;; esac - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --format) - _quota_formats - return 0 - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \ - -g --group -u --user -p --prototype= -F --format= -f --filesystem \ + -g --group -u --user -p --prototype -F --format -f --filesystem \ -t --edit-period -T --edit-times' -- $cur ) ) else _user_or_group @@ -158,35 +137,28 @@ complete -F _edquota $default edquota _quotacheck() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in - -F) + -F|--format) _quota_formats return 0 ;; esac - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --format) - _quota_formats - return 0 - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-b --backup -v --verbose -d --debug \ -g --group -u --user -c --create-files -f --force -i \ --interactive -n --use-first-dquot -M --try-remount -m \ - --no-remount -R --exclude-root -F --format= -a --all' \ + --no-remount -R --exclude-root -F --format -a --all' \ -- $cur ) ) else _filesystems @@ -196,35 +168,28 @@ complete -F _quotacheck $default quotacheck _repquota() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in - -F) + -F|--format) _quota_formats return 0 ;; esac - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --format) - _quota_formats - return 0 - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-a --all -v --verbose -s --human-readable \ -c --batch-translation -C --no-batch-translation -t \ --truncate-names -n --no-names -p --raw-grace -i --no-autofs \ - -u --user -g --group -F --format=' -- $cur ) ) + -u --user -g --group -F --format' -- $cur ) ) else _filesystems fi @@ -233,34 +198,26 @@ complete -F _repquota $default repquota _quotaon() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} - echo --$cmd-- + _split_longopt && split=true + case $prev in - -F) + -F|--format) _quota_formats return 0 ;; esac - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --format) - _quota_formats - return 0 - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \ - -g --group -f --off -p --print-state -F --format=' -- $cur ) ) + -g --group -f --off -p --print-state -F --format' -- $cur ) ) else _filesystems fi @@ -269,14 +226,16 @@ complete -F _quotaon $default quotaon _quotaoff() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in - -F) + -F|--format) _quota_formats return 0 ;; @@ -286,20 +245,11 @@ _quotaoff() ;; esac - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --format) - _quota_formats - return 0 - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \ - -g --group -p --print-state -x --xfs-command -F --format=' \ + -g --group -p --print-state -x --xfs-command -F --format' \ -- $cur ) ) else _filesystems diff --git a/contrib/reportbug b/contrib/reportbug new file mode 100644 index 00000000..bee1ece9 --- /dev/null +++ b/contrib/reportbug @@ -0,0 +1,120 @@ +# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*- +# ex: ts=8 sw=8 noet filetype=sh +# +# bash completion for (Debian) reportbug package + +have reportbug && +_reportbug() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -f|--filename|-i|--include|--mta|-o|--output) + _filedir + return 0 + ;; + -B|--bts) + COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \ + $cur )) + return 0 + ;; + -e|--editor|--mua) + COMP_WORDS=(COMP_WORDS[0] $cur) + COMP_CWORD=1 + _command + return 0 + ;; + --mode) + COMPREPLY=( $( compgen -W "novice standard expert" -- $cur ) ) + return 0 + ;; + -S|--severity) + COMPREPLY=( $( compgen -W "grave serious important normal \ + minor wishlist" -- $cur ) ) + return 0 + ;; + -u|--ui|--interface) + COMPREPLY=( $( compgen -W "newt text gnome" -- $cur ) ) + return 0 + ;; + -t|--type) + COMPREPLY=( $( compgen -W "gnats debbugs" -- $cur ) ) + return 0 + ;; + -T|--tags) + COMPREPLY=( $( compgen -W "none \ + woody potato sarge sarge-ignore etch etch-ignore \ + lenny lenny-ignore sid experimental confirmed \ + d-i fixed fixed-in-experimental fixed-upstream \ + help l10n moreinfo patch pending security \ + unreproducible upstream wontfix ipv6 lfs" -- $cur )) + return 0 + ;; + *) + ;; + esac + + COMPREPLY=($( compgen -W '-h --help -v --version -a --af -b \ + --no-query-bts --query-bts -B --bts -c --configure \ + --no-config-files --check-available -d --debug \ + --no-check-available -e --editor --email -f \ + --filename -g --gnupg -H --header -i --include -j \ + --justification -l --ldap --no-ldap -L --list-cc -m \ + --maintonly --mode --mua --mta --mutt -n --mh --nmh \ + -o --output -p --print -P --pgp --proxy --http_proxy\ + -q --quiet -Q --query-only --realname --report-quiet \ + --reply-to --replyto -s --subject -S --severity \ + --smtphost -t --type -T --tags --template -V -x \ + --no-cc --package-version -z --no-compress \ + --ui --interface -u \ + wnpp boot-floppies kernel bugs.debian.org \ + cdimage.debian.org general installation-reports \ + listarchives lists.debian.org mirrors nm.debian.org \ + press project qa.debian.org release-notes \ + security.debian.org tech-ctte upgrade-reports \ + www.debian.org' -- $cur ) \ + $( apt-cache pkgnames -- $cur 2> /dev/null) ) + _filedir + return 0 +} && +complete -F _reportbug $filenames reportbug + +have querybts && +_querybts() +{ + local cur prev + + COMPREPLY=() + cur=`_get_cword` + prev=${COMP_WORDS[COMP_CWORD-1]} + + case "$prev" in + -B|--bts) + COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \ + $cur )) + return 0 + ;; + -u|--ui|--interface) + COMPREPLY=($( compgen -W "newt text gnome" -- $cur )) + return 0 + ;; + *) + ;; + esac + + COMPREPLY=($( compgen -W '-h --help -v --version -A --archive \ + -B --bts -l --ldap --no-ldap --proxy= --http_proxy= \ + -s --source -w --web -u --ui --interface \ + wnpp boot-floppies kernel bugs.debian.org \ + cdimage.debian.org general installation-reports \ + listarchives lists.debian.org mirrors nm.debian.org \ + press project qa.debian.org release-notes \ + security.debian.org tech-ctte upgrade-reports \ + www.debian.org' -- $cur ) \ + $( apt-cache pkgnames -- $cur 2> /dev/null) ) +} && +complete -F _querybts $filenames querybts diff --git a/contrib/samba b/contrib/samba index 27e9dcd9..714019a7 100644 --- a/contrib/samba +++ b/contrib/samba @@ -12,25 +12,34 @@ _samba_resolve_order() _samba_domains() { if [ -n "${COMP_SAMBA_SCAN:-}" ]; then - COMPREPLY=( $( smbtree -D | grep "^$cur" ) ) + COMPREPLY=( $( compgen -W '$( smbtree -N -D )' -- $cur ) ) fi } _samba_hosts() { if [ -n "${COMP_SAMBA_SCAN:-}" ]; then - COMPREPLY=( $( smbtree -S | grep "^$cur" ) ) + COMPREPLY=( $( compgen -W "$( smbtree -N -S | \ + sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' \ + )" -- $cur ) ) fi } +_samba_debuglevel() +{ + COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9 10' -- $cur ) ) +} + _smbclient() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in -R) _samba_resolve_order @@ -41,11 +50,11 @@ _smbclient() HEX CAP' -- $cur ) ) return 0; ;; - -@(s|A)) + -s|-A|--authentication-file) _filedir return 0; ;; - -l) + -l|--log-basename|-D) _filedir -d return 0; ;; @@ -61,59 +70,61 @@ _smbclient() $cur ) ) return 0; ;; - -W) + -W|--workgroup) _samba_domains return 0; ;; + -d|--debuglevel) + _samba_debuglevel + return 0 + ;; + -p|--port|-M|-I|-b|-U|--user|-n|-i|-T|-c) + # argument required but no completions available + return 0 + ;; + -\?|--help|-V|--version) + # all other arguments are noop with these + return 0 + ;; esac - # --name=value style option - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --logfile) - _filedir -d - return 0; - ;; - --authentication-file) - _filedir - return 0; - ;; - --workgroup) - _samba_domains - return 0; - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-b -d -L -U -I -M -m -A -N -i -O \ - -p -R -s -k -P -c -D -W -l -E --debuglevel= --logfile= \ - --workgroup=' -- $cur ) ) + -p -R -s -k -P -c -D -W -l -E --debuglevel \ + --log-basename --workgroup' -- $cur ) ) fi } complete -F _smbclient smbclient _smbget() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in -@(o|f|-outputfile|-rcfile)) _filedir return 0; ;; + -d|--debuglevel) + _samba_debuglevel + return 0 + ;; esac + $split && return 0 + if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-a --guest -r --resume -R \ - --recursive -u --username= -p --password= -w \ - --workgroup= -n --nonprompt -d --debuglevel= -D --dots \ + --recursive -u --username -p --password -w \ + --workgroup -n --nonprompt -d --debuglevel -D --dots \ -P --keep-permissions -o --outputfile -f --rcfile -q \ --quiet -v --verbose -b --blocksize -? --help --usage' \ -- $cur ) ) @@ -123,38 +134,34 @@ complete -F _smbget smbget _smbcacls() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in -s) _filedir return 0; ;; - -l) + -l|--log-basename) _filedir -d return 0; ;; + -d|--debuglevel) + _samba_debuglevel + return 0 + ;; esac - # --name=value style option - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --logfile) - _filedir -d - return 0; - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-a -M -D -S -U -C -G --numeric -t \ - -h --help -V -s -d --debuglevel= -l --logfile=' -- \ + -h --help -V -s -d --debuglevel -l --log-basename' -- \ $cur ) ) fi } @@ -162,43 +169,35 @@ complete -F _smbcacls smbcacls _smbcquotas() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in - -@(s|A)) + -s|-A|--authentication-file) _filedir return 0; ;; - -l) + -l|--log-basename) _filedir -d return 0; ;; + -d|--debuglevel) + _samba_debuglevel + return 0 + ;; esac - # --name=value style option - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --logfile) - _filedir -d - return 0; - ;; - --authentication-file) - _filedir - return 0; - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-u -L -F -S -n -t -v -h --help -V \ - -s -d --debuglevel= -l --logfile= -N -k -A \ - --authentication-file= -U --user=' -- $cur ) ) + -s -d --debuglevel -l --log-basename -N -k -A \ + --authentication-file -U --user' -- $cur ) ) fi } complete -F _smbcquotas smbcquotas @@ -224,6 +223,10 @@ _smbpasswd() _filedir return 0; ;; + -D) + _samba_debuglevel + return 0 + ;; esac if [[ "$cur" == -* ]]; then @@ -250,6 +253,10 @@ _smbtar() _samba_hosts return 0; ;; + -l) + _samba_debuglevel + return 0 + ;; esac if [[ "$cur" == -* ]]; then @@ -261,42 +268,34 @@ complete -F _smbtar smbtar _smbtree() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + _split_longopt && split=true + case $prev in - -@(s|A)) + -s|-A|--authentication-file) _filedir return 0; ;; - -l) + -l|--log-basename) _filedir -d return 0; ;; + -d|--debuglevel) + _samba_debuglevel + return 0 + ;; esac - # --name=value style option - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case $prev in - --logfile) - _filedir -d - return 0; - ;; - --authentication-file) - _filedir - return 0; - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-b -D -S -V -s -d --debuglevel= -l \ - --logfile= -N -k -A --authentication-file= -U --user= \ + COMPREPLY=( $( compgen -W '-b -D -S -V -s -d --debuglevel -l \ + --log-basename -N -k -A --authentication-file -U --user\ -h --help' -- $cur ) ) fi } diff --git a/contrib/yum b/contrib/yum index b4ee3aad..0cf06d80 100644 --- a/contrib/yum +++ b/contrib/yum @@ -23,7 +23,7 @@ _yum_repolist() { # -d 0 causes repolist to output nothing as of yum 3.2.22: # http://yum.baseurl.org/ticket/83 - # Drop first ("repo id repo name") axnd last ("repolist: ...") rows + # Drop first ("repo id repo name") and last ("repolist: ...") rows yum --noplugins -C repolist $1 2>/dev/null | \ sed -ne '/^repo\(\s\+id\|list:\)/d' -e 's/[[:space:]].*//p' }