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

This commit is contained in:
Guillaume Rousse 2009-09-14 21:36:44 +02:00
commit c4b81f782d
1090 changed files with 6972 additions and 7502 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.tar* *.tar*
*.swp
Makefile Makefile
Makefile.in Makefile.in
aclocal.m4 aclocal.m4

38
CHANGES
View File

@ -34,11 +34,13 @@ bash-completion (1.x)
* Added avahi-discovered hosts to _known_hosts_real() (Debian: #518561) * Added avahi-discovered hosts to _known_hosts_real() (Debian: #518561)
[ Ville Skyttä ] [ Ville Skyttä ]
* Split yum and yum-arch completion into contrib/yum. * Split yum completion to contrib/_yum (no longer installed by default, the
* Install yum-arch completion only if yum-arch is installed. intent is to move it to yum upstream soon).
* Split yum-arch completion into contrib/yum-arch, load completion only if
yum-arch is installed.
* Update list of yum commands and options. * Update list of yum commands and options.
* Add yum repolist, --enable/disablerepo, --disableexcludes, -d, -e, and * Add yum repolist, --enable/disablerepo, --disableexcludes, -d, -e, --color,
--color completions. and --enable/disableplugin completions.
* Add chkconfig --override and resetpriorities completions. * Add chkconfig --override and resetpriorities completions.
* Split mplayer and friends completions to contrib/mplayer. * Split mplayer and friends completions to contrib/mplayer.
* Parse top level mplayer and friends option completions from -list-options. * Parse top level mplayer and friends option completions from -list-options.
@ -71,8 +73,8 @@ bash-completion (1.x)
completion, assume only that --*file*= does, and that --*dir*= takes dirs. completion, assume only that --*file*= does, and that --*dir*= takes dirs.
* Add make --old/new-file, --assume-old/new, --what-if value completions. * Add make --old/new-file, --assume-old/new, --what-if value completions.
* Add smartctl -n/--nocheck completion, add more other value completions. * Add smartctl -n/--nocheck completion, add more other value completions.
* Fix leaking $prev from cpio, dsniff, freeciv, gkrellm, mkinitrd, and * Fix leaking $prev from cpio, dsniff, freeciv, gkrellm, mkinitrd, service,
tcpdump completions. and tcpdump completions.
* Split ant completion to contrib/ant, improve the built in one. * Split ant completion to contrib/ant, improve the built in one.
* Improve postfix completion. * Improve postfix completion.
* Improve samba completion. * Improve samba completion.
@ -92,6 +94,21 @@ bash-completion (1.x)
to get various completions instead of simply "mplayer" or "mencoder". to get various completions instead of simply "mplayer" or "mencoder".
* Associate OOXML/MS Office 2007 extensions with OpenOffice applications. * Associate OOXML/MS Office 2007 extensions with OpenOffice applications.
* Associate .tsv with oocalc. * Associate .tsv with oocalc.
* Add xmlwf completion.
* Associate *.po with poedit, gtranslator, kbabel, and lokalize.
* Add xz, xzcat, xzdec, and unxz completion.
* Add lzcat, lz*grep, lzless, lzmore, and unlzma completion.
* Load "modules" completion if /etc/profile.d/modules.sh exists even if
the "module" alias has not been defined (yet).
* Add *.ogv to xine-based players (Debian: #540033).
* Add $compopt (":" i.e. no-op with bash < 4, "compopt" with >= 4).
* Complete bzcat and zcat only on compressed files.
* Do not require a dot in bzcmp, bzdiff, bz*grep, zcmp, zdiff, z*grep, zless,
and zmore filename completions.
* Add xz and compress support and more tarball filename extensions to
rpmbuild -t*/--tarbuild completion.
* Don't hardcode path to lsmod.
* Fix sbcl file/dirname completion (Debian: #545743).
[ Todd Zullinger ] [ Todd Zullinger ]
* Make yum complete on filenames after install, deplist, update and upgrade * Make yum complete on filenames after install, deplist, update and upgrade
@ -135,6 +152,13 @@ bash-completion (1.x)
[ Freddy Vulto ] [ Freddy Vulto ]
* Patched _known_hosts() to support multiple {Global,User}KnownHosts in SSH * Patched _known_hosts() to support multiple {Global,User}KnownHosts in SSH
config files, thanks to Thomas Nilsson (Alioth: #311595) (Debian: #524190) config files, thanks to Thomas Nilsson (Alioth: #311595) (Debian: #524190)
* Fix leaking $i from info, man and python completions.
* Added setting COMP_KNOWN_HOSTS_WITH_HOSTFILE. _known_hosts_real() will add
hosts from HOSTFILE, unless COMP_KNOWN_HOSTS_WITH_HOSTFILE is set to an
empty value (Alioth: #311821)
* Fix _known_hosts_real() to not glob awk script - thanks to Eric Blake
(Alioth #311614)
* Fix leaking $muttcmd from mutt completion
-- David Paleino <d.paleino@gmail.com> Thu, 18 Jun 2009 13:12:36 +0200 -- David Paleino <d.paleino@gmail.com> Thu, 18 Jun 2009 13:12:36 +0200
@ -345,7 +369,7 @@ bash-completion (20080617.4) experimental; urgency=low
- _known_hosts(): use files from UserKnownHostsFile options in - _known_hosts(): use files from UserKnownHostsFile options in
addition to standard ones. addition to standard ones.
- fixed _command() to correctly prune the command line - fixed _command() to correctly prune the command line
- disabled completion of PostgreSQL users and databases - disabled completion of PostgreSQL users and databases (Ubuntu: #164772)
- fixed _java_packages() - fixed _java_packages()
- fixed _muttquery() - fixed _muttquery()
- added flv/FLV completion to mplayer - added flv/FLV completion to mplayer

View File

@ -137,9 +137,11 @@ bashcomp_DATA = contrib/ant \
contrib/xhost \ contrib/xhost \
contrib/xm \ contrib/xm \
contrib/xmllint \ contrib/xmllint \
contrib/xmlwf \
contrib/xmms \ contrib/xmms \
contrib/xrandr \ contrib/xrandr \
contrib/xz \
contrib/yp-tools \ contrib/yp-tools \
contrib/yum contrib/yum-arch
EXTRA_DIST = $(sysconf_DATA) $(bashcomp_DATA) contrib/_subversion EXTRA_DIST = $(sysconf_DATA) $(bashcomp_DATA) contrib/_subversion contrib/_yum

View File

@ -65,6 +65,7 @@ if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} > 04 ]] ||
default="-o default" default="-o default"
dirnames="-o dirnames" dirnames="-o dirnames"
filenames="-o filenames" filenames="-o filenames"
compopt=:
fi fi
# features supported by bash 2.05b and higher # features supported by bash 2.05b and higher
if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] || if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] ||
@ -81,6 +82,7 @@ fi
# features supported by bash 4.0 and higher # features supported by bash 4.0 and higher
if [ ${BASH_VERSINFO[0]} -gt 3 ]; then if [ ${BASH_VERSINFO[0]} -gt 3 ]; then
declare -r bash4=$BASH_VERSION 2>/dev/null || : declare -r bash4=$BASH_VERSION 2>/dev/null || :
compopt=compopt
fi fi
# Turn on extended globbing and programmable completion # Turn on extended globbing and programmable completion
@ -96,17 +98,16 @@ complete -d pushd
# Do NOT break these over multiple lines. # Do NOT break these over multiple lines.
# #
# START exclude -- do NOT remove this line # START exclude -- do NOT remove this line
complete -f -X '!*.?(t)bz?(2)' bunzip2 # bzcmp, bzdiff, bz*grep, bzless, bzmore intentionally not here, see Debian: #455510
# TODO: see #455510 complete -f -X '!*.?(t)bz?(2)' bunzip2 bzcat
#complete -f -X '!*.?(t)bz?(2)' bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
complete -f -X '!*.*' bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo|xpi|sxw|ott|od[fgpst]|epub)' unzip zipinfo complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo|xpi|sxw|ott|od[fgpst]|epub)' unzip zipinfo
complete -f -X '*.Z' compress znew complete -f -X '*.Z' compress znew
complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip # zcmp, zdiff, z*grep, zless, zmore intentionally not here, see Debian: #455510
# TODO: see #455510 complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip zcat
#complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
complete -f -X '!*.*' zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
complete -f -X '!*.Z' uncompress complete -f -X '!*.Z' uncompress
# lzcmp, lzdiff intentionally not here, see Debian: #455510
complete -f -X '!*.lzma' lzcat lzegrep lzfgrep lzgrep lzless lzmore unlzma
complete -f -X '!*.@(xz|lzma)' unxz xzcat
complete -f -X '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX)' ee complete -f -X '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX)' ee
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|X[BP]M|RLE|RGB|PCX|FITS|PM)' xv qiv complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|X[BP]M|RLE|RGB|PCX|FITS|PM)' xv qiv
complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview
@ -120,7 +121,7 @@ complete -f -X '!*.@(?(e)ps|?(E)PS|pdf|PDF)' ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 p
complete -f -X '!*.texi*' makeinfo texi2html complete -f -X '!*.texi*' makeinfo texi2html
complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
complete -f -X '!*.@(mp3|MP3)' mpg123 mpg321 madplay complete -f -X '!*.@(mp3|MP3)' mpg123 mpg321 madplay
complete -f -X '!*@(.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|ogg|OGG|ogm|OGM|wav|WAV|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))' xine aaxine fbxine kaffeine complete -f -X '!*@(.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|og[gmv]|OG[GMV]|wav|WAV|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))' xine aaxine fbxine kaffeine
complete -f -X '!*.@(avi|asf|wmv)' aviplay complete -f -X '!*.@(avi|asf|wmv)' aviplay
complete -f -X '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay complete -f -X '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay
complete -f -X '!*.@(mpg|mpeg|avi|mov|qt)' xanim complete -f -X '!*.@(mpg|mpeg|avi|mov|qt)' xanim
@ -144,6 +145,7 @@ complete -f -X '!*.odb' oobase
complete -f -X '!*.rpm' rpm2cpio complete -f -X '!*.rpm' rpm2cpio
complete -f -X '!*.sqlite' sqlite3 complete -f -X '!*.sqlite' sqlite3
complete -f -X '!*.aux' bibtex complete -f -X '!*.aux' bibtex
complete -f -X '!*.po' poedit gtranslator kbabel lokalize
# FINISH exclude -- do not remove this line # FINISH exclude -- do not remove this line
# start of section containing compspecs that can be handled within bash # start of section containing compspecs that can be handled within bash
@ -211,7 +213,7 @@ quote()
echo \'${1//\'/\'\\\'\'}\' #'# Help vim syntax highlighting echo \'${1//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
} }
# This function quotes the argument in a way so that readline dequoting # This function quotes the argument in a way so that readline dequoting
# results in the original argument # results in the original argument
quote_readline() quote_readline()
{ {
@ -244,33 +246,29 @@ dequote()
# for things like scp where we want to return host:path and not only path. # for things like scp where we want to return host:path and not only path.
_get_cword() _get_cword()
{ {
if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then local i
printf "%s" "${COMP_WORDS[COMP_CWORD]}" local LC_CTYPE=C
else local WORDBREAKS=${COMP_WORDBREAKS}
local i if [ -n $1 ]; then
local cur="$COMP_LINE" for (( i=0; i<${#1}; ++i )); do
local index="$COMP_POINT" local char=${1:$i:1}
for (( i = 0; i <= COMP_CWORD; ++i )); do WORDBREAKS=${WORDBREAKS//$char/}
while [[ "${#cur}" -ge ${#COMP_WORDS[i]} ]] && [[ "${cur:0:${#COMP_WORDS[i]}}" != "${COMP_WORDS[i]}" ]]; do
cur="${cur:1}"
index="$(( index - 1 ))"
done
if [[ "$i" -lt "$COMP_CWORD" ]]; then
local old_size="${#cur}"
cur="${cur#${COMP_WORDS[i]}}"
local new_size="${#cur}"
index="$(( index - old_size + new_size ))"
fi
done done
if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then
# We messed up! At least return the whole word so things
# keep working
printf "%s" "${COMP_WORDS[COMP_CWORD]}"
else
printf "%s" "${cur:0:$index}"
fi
fi fi
local cur=${COMP_LINE:0:$COMP_POINT}
local tmp="${cur}"
local word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
while [ "$word_start" -ge 2 ]; do
local char=${cur:$(( $word_start - 2 )):1}
if [ "$char" != "\\" ]; then
break
fi
tmp=${COMP_LINE:0:$(( $word_start - 2 ))}
word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
done
cur=${cur:$word_start}
printf "%s" "$cur"
} }
# This function performs file and directory completion. It's better than # This function performs file and directory completion. It's better than
@ -286,16 +284,16 @@ _filedir()
local -a toks local -a toks
local tmp local tmp
# TODO: I've removed a "[ -n $tmp ] &&" before `echo $tmp', # TODO: I've removed a "[ -n $tmp ] &&" before `echo $tmp',
# and everything works again. If this bug # and everything works again. If this bug
# suddenly appears again (i.e. "cd /b<TAB>" # suddenly appears again (i.e. "cd /b<TAB>"
# becomes "cd /"), remember to check for # becomes "cd /"), remember to check for
# other similar conditionals (here and # other similar conditionals (here and
# _filedir_xspec()). --David # _filedir_xspec()). --David
# NOTE: The comment above has been moved outside of the subshell below, # NOTE: The comment above has been moved outside of the subshell below,
# because quotes-in-comments-in-a-subshell cause errors on # because quotes-in-comments-in-a-subshell cause errors on
# bash-3.1. See also: # bash-3.1. See also:
# http://www.mail-archive.com/bug-bash@gnu.org/msg01667.html # http://www.mail-archive.com/bug-bash@gnu.org/msg01667.html
toks=( ${toks[@]-} $( toks=( ${toks[@]-} $(
compgen -d -- "$(quote_readline "$cur")" | { compgen -d -- "$(quote_readline "$cur")" | {
@ -304,7 +302,7 @@ _filedir()
done done
} }
)) ))
if [[ "$1" != -d ]]; then if [[ "$1" != -d ]]; then
xspec=${1:+"!*.$1"} xspec=${1:+"!*.$1"}
toks=( ${toks[@]-} $( toks=( ${toks[@]-} $(
@ -549,7 +547,7 @@ _modules()
# #
_installed_modules() _installed_modules()
{ {
COMPREPLY=( $( compgen -W "$( /sbin/lsmod | \ COMPREPLY=( $( compgen -W "$( PATH="$PATH:/sbin" lsmod | \
awk '{if (NR != 1) print $1}' )" -- $1 ) ) awk '{if (NR != 1) print $1}' )" -- $1 ) )
} }
@ -637,7 +635,7 @@ _usb_ids()
{ have service || [ -d /etc/init.d/ ]; } && { have service || [ -d /etc/init.d/ ]; } &&
_service() _service()
{ {
local cur sysvdir local cur prev sysvdir
COMPREPLY=() COMPREPLY=()
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
@ -729,7 +727,7 @@ _chgrp()
fi fi
$split && return 0 $split && return 0
# options completion # options completion
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \ COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \
@ -1045,19 +1043,24 @@ _user_at_host() {
} }
shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
# NOTE: Using this function as a helper function is deprecated. Use # NOTE: Using this function as a helper function is deprecated. Use
# `_known_hosts_real' instead. # `_known_hosts_real' instead.
_known_hosts() _known_hosts()
{ {
local options
COMPREPLY=() COMPREPLY=()
# NOTE: Passing "$@" is deprecated. See NOTE above. # NOTE: Using `_known_hosts' as a helper function and passing options
_known_hosts_real "$@" "$(_get_cword)" # to `_known_hosts' is deprecated: Use `_known_hosts_real' instead.
[ "$1" = -a ] || [ "$2" = -a ] && options=-a
[ "$1" = -c ] || [ "$2" = -c ] && options="$options -c"
_known_hosts_real $options "$(_get_cword)"
} }
# Helper function for completing _known_hosts. # Helper function for completing _known_hosts.
# This function performs host completion based on ssh's known_hosts files, # This function performs host completion based on ssh's known_hosts files.
# defaulting to standard host completion if they don't exist. # 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 # Usage: _known_hosts_real [OPTIONS] CWORD
# Options: -a Use aliases # Options: -a Use aliases
# -c Use `:' suffix # -c Use `:' suffix
@ -1069,7 +1072,6 @@ _known_hosts_real()
local configfile flag prefix local configfile flag prefix
local cur curd awkcur user suffix aliases global_kh user_kh hosts i host local cur curd awkcur user suffix aliases global_kh user_kh hosts i host
local -a kh khd config local -a kh khd config
local IFS=$'\n'
local OPTIND=1 local OPTIND=1
while getopts "acF:p:" flag "$@"; do while getopts "acF:p:" flag "$@"; do
@ -1102,16 +1104,18 @@ _known_hosts_real()
fi fi
if [ ${#config[@]} -gt 0 ]; then if [ ${#config[@]} -gt 0 ]; then
local OIFS=$IFS IFS=$'\n'
# expand path (if present) to global known hosts file # expand path (if present) to global known hosts file
global_kh=($( sed -ne 's/^[ \t]*[Gg][Ll][Oo][Bb][Aa][Ll][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" )) global_kh=($( sed -ne 's/^[ \t]*[Gg][Ll][Oo][Bb][Aa][Ll][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/"\1"/p' "${config[@]}" ))
for (( i=0; i < ${#global_kh[@]}; i++ )); do for (( i=0; i < ${#global_kh[@]}; i++ )); do
global_kh[i]=$(echo "${global_kh[i]//\"/}") global_kh[i]=$(echo "${global_kh[i]//\"/}")
done done
# expand path (if present) to user known hosts file # expand path (if present) to user known hosts file
user_kh=($( sed -ne 's/^[ \t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" )) user_kh=($( sed -ne 's/^[ \t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/"\1"/p' "${config[@]}" ))
for (( i=0; i < ${#user_kh[@]}; i++ )); do for (( i=0; i < ${#user_kh[@]}; i++ )); do
user_kh[i]=$(echo "${user_kh[i]//\"/}") user_kh[i]=$(echo "${user_kh[i]//\"/}")
done done
IFS=$OIFS
fi fi
# Global known_hosts files # Global known_hosts files
@ -1144,79 +1148,78 @@ _known_hosts_real()
# If we have known_hosts files to use # If we have known_hosts files to use
if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 -o -n "$configfile" ]; then if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 -o -n "$configfile" ]; then
# Escape slashes and dots in paths for awk # Escape slashes and dots in paths for awk
awkcur=${cur//\//\\\/} awkcur=${cur//\//\\\/}
awkcur=${awkcur//\./\\\.} awkcur=${awkcur//\./\\\.}
curd=$awkcur curd=$awkcur
if [[ "$awkcur" == [0-9]*.* ]]; then if [[ "$awkcur" == [0-9]*.* ]]; then
# Digits followed by a dot - just search for that # Digits followed by a dot - just search for that
awkcur="^$awkcur.*" awkcur="^$awkcur.*"
elif [[ "$awkcur" == [0-9]* ]]; then elif [[ "$awkcur" == [0-9]* ]]; then
# Digits followed by no dot - search for digits followed # Digits followed by no dot - search for digits followed
# by a dot # by a dot
awkcur="^$awkcur.*\." awkcur="^$awkcur.*\."
elif [ -z "$awkcur" ]; then elif [ -z "$awkcur" ]; then
# A blank - search for a dot or an alpha character # A blank - search for a dot or an alpha character
awkcur="[a-z.]" awkcur="[a-z.]"
else else
awkcur="^$awkcur" awkcur="^$awkcur"
fi fi
if [ ${#kh[@]} -gt 0 ]; then if [ ${#kh[@]} -gt 0 ]; then
# FS needs to look for a comma separated list
# FS needs to look for a comma separated list COMPREPLY=( $( awk 'BEGIN {FS=","}
COMPREPLY=( $( awk 'BEGIN {FS=","}
/^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \ /^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \
gsub(" .*$", "", $i); \ gsub(" .*$", "", $i); \
if ($i ~ /'$awkcur'/) {print $i} \ if ($i ~ /'"$awkcur"'/) {print $i} \
}}' "${kh[@]}" 2>/dev/null ) ) }}' "${kh[@]}" 2>/dev/null ) )
fi fi
if [ ${#khd[@]} -gt 0 ]; then if [ ${#khd[@]} -gt 0 ]; then
# Needs to look for files called # Needs to look for files called
# .../.ssh2/key_22_<hostname>.pub # .../.ssh2/key_22_<hostname>.pub
# dont fork any processes, because in a cluster environment, # dont fork any processes, because in a cluster environment,
# there can be hundreds of hostkeys # there can be hundreds of hostkeys
for i in "${khd[@]}" ; do for i in "${khd[@]}" ; do
if [[ "$i" == *key_22_$awkcurd*.pub ]] && [ -r "$i" ] ; then if [[ "$i" == *key_22_$awkcurd*.pub ]] && [ -r "$i" ] ; then
host=${i/#*key_22_/} host=${i/#*key_22_/}
host=${host/%.pub/} host=${host/%.pub/}
COMPREPLY=( "${COMPREPLY[@]}" $host ) COMPREPLY=( "${COMPREPLY[@]}" $host )
fi fi
done
fi
# append any available aliases from config files
if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
local host_aliases=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^#*?]*\)\(#.*\)\?$/\2/p' "${config[@]}" )
hosts=$( compgen -W "$host_aliases" -- $cur )
COMPREPLY=( "${COMPREPLY[@]}" $hosts )
fi
# Add hosts reported by avahi, if it's available
# and if the daemon is started.
# 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
if [ -n "$(pidof avahi-daemon)" ]; then
COMPREPLY=( "${COMPREPLY[@]}" $(
compgen -W "$( avahi-browse -cpr _workstation._tcp | \
grep ^= | cut -d\; -f7 | sort -u )" -- $cur ) )
fi
fi
# apply suffix and prefix
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=$prefix$user${COMPREPLY[i]}$suffix
done done
fi fi
# append any available aliases from config files
if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
local host_aliases=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^#*?]*\)\(#.*\)\?$/\2/p' "${config[@]}" )
hosts=$( compgen -W "$host_aliases" -- $cur )
COMPREPLY=( "${COMPREPLY[@]}" $hosts )
fi
# Add hosts reported by avahi, if it's available # Add results of normal hostname completion, unless `COMP_KNOWN_HOSTS_WITH_HOSTFILE'
# and if the daemon is started. # is set to an empty value.
# The original call to avahi-browse also had "-k", to avoid if [ -n "${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1}" ]; then
# lookups into avahi's services DB. We don't need the name COMPREPLY=( "${COMPREPLY[@]}" $( compgen -A hostname -P "$prefix$user" -S "$suffix" -- $cur ) )
# 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
if [ -n "$(pidof avahi-daemon)" ]; then
COMPREPLY=( "${COMPREPLY[@]}" $(
compgen -W "$( avahi-browse -cpr _workstation._tcp | \
grep ^= | cut -d\; -f7 | sort -u )" -- $cur ) )
fi
fi
# Now add results of normal hostname completion
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -A hostname -- $cur ) )
# apply suffix and prefix
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=$prefix$user${COMPREPLY[i]}$suffix
done
elif [ -z "$configfile" ]; then
# Just do normal hostname completion
COMPREPLY=( $( compgen -A hostname -S "$suffix" -- $cur ) )
fi fi
return 0 return 0
@ -1346,7 +1349,7 @@ _command_offset()
# get function name # get function name
func=${cspec#*-F } func=${cspec#*-F }
func=${func%% *} func=${func%% *}
if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
$func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}" $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}"
else else
@ -1490,7 +1493,7 @@ _filedir_xspec()
done done
} }
)) ))
toks=( ${toks[@]-} $( toks=( ${toks[@]-} $(
eval compgen -f -X "$xspec" -- "\$(quote_readline "\$cur")" | { eval compgen -f -X "$xspec" -- "\$(quote_readline "\$cur")" | {
while read -r tmp; do while read -r tmp; do
@ -1498,7 +1501,7 @@ _filedir_xspec()
done done
} }
)) ))
COMPREPLY=( "${toks[@]}" ) COMPREPLY=( "${toks[@]}" )
} }
list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' \ list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' \
@ -1530,7 +1533,7 @@ if [ -d $BASH_COMPLETION_COMPAT_DIR -a -r $BASH_COMPLETION_COMPAT_DIR -a \
-x $BASH_COMPLETION_COMPAT_DIR ]; then -x $BASH_COMPLETION_COMPAT_DIR ]; then
for i in $BASH_COMPLETION_COMPAT_DIR/*; do for i in $BASH_COMPLETION_COMPAT_DIR/*; do
[[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)) ]] && [[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)) ]] &&
[ \( -f $i -o -h $i \) -a -r $i ] && . $i [ \( -f $i -o -h $i \) -a -r $i ] && . $i
done done
fi fi
if [ -d $BASH_COMPLETION_DIR -a -r $BASH_COMPLETION_DIR -a \ if [ -d $BASH_COMPLETION_DIR -a -r $BASH_COMPLETION_DIR -a \
@ -1547,7 +1550,8 @@ unset i
[ $BASH_COMPLETION != ~/.bash_completion -a -r ~/.bash_completion ] \ [ $BASH_COMPLETION != ~/.bash_completion -a -r ~/.bash_completion ] \
&& . ~/.bash_completion && . ~/.bash_completion
unset -f have unset -f have
unset UNAME USERLAND default dirnames filenames have nospace bashdefault plusdirs unset UNAME USERLAND default dirnames filenames have nospace bashdefault \
plusdirs compopt
set $BASH_COMPLETION_ORIGINAL_V_VALUE set $BASH_COMPLETION_ORIGINAL_V_VALUE
unset BASH_COMPLETION_ORIGINAL_V_VALUE unset BASH_COMPLETION_ORIGINAL_V_VALUE

180
contrib/_yum Normal file
View File

@ -0,0 +1,180 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
# yum(8) completion
#
have yum && {
_yum_list()
{
if [[ "$1" == all ]] ; then
# Try to strip in between headings like "Available Packages"
# This will obviously only work for English :P
COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \
sed -ne '/^\(Available\|Installed\|Updated\) /d' \
-e 's/[[:space:]].*//p' ) )
else
# Drop first line (e.g. "Updated Packages")
COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \
sed -ne 1d -e 's/[[:space:]].*//p' ) )
fi
}
_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") and last ("repolist: ...") rows
yum --noplugins -C repolist $1 2>/dev/null | \
sed -ne '/^repo\(\s\+id\|list:\)/d' -e 's/[[:space:]].*//p'
}
_yum_plugins()
{
command ls /usr/lib/yum-plugins/*.py{,c,o} 2>/dev/null \
| sed -ne 's|.*/\([^./]*\)\.py[co]\?$|\1|p' | sort -u
}
_yum()
{
local cur prev special split=false
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
if [[ ${COMP_WORDS[i]} == @(install|update|upgrade|remove|erase|deplist|info) ]]; then
special=${COMP_WORDS[i]}
fi
done
if [ -n "$special" ]; then
# TODO: install|update|upgrade should not match *src.rpm
if [[ "$cur" == */* && "$special" == @(deplist|install|update|upgrade) ]]; then
_filedir rpm
return 0
fi
case $special in
install)
_yum_list available
return 0
;;
deplist|info)
_yum_list all
return 0
;;
upgrade|update)
_yum_list updates
return 0
;;
remove|erase)
# _rpm_installed_packages is not arch-qualified
_yum_list installed
return 0
;;
esac
fi
_split_longopt && split=true
case $prev in
list)
COMPREPLY=( $( compgen -W 'all available updates \
installed extras obsoletes recent' -- $cur ) )
;;
clean)
COMPREPLY=( $( compgen -W 'packages headers metadata \
cache dbcache all' -- $cur ) )
;;
repolist)
COMPREPLY=( $( compgen -W 'all enabled disabled' \
-- $cur ) )
;;
localinstall|localupdate)
# TODO: should not match *src.rpm
_filedir rpm
;;
-d|-e)
COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9 10' \
-- $cur ) )
;;
-c)
_filedir
;;
--installroot)
_filedir -d
;;
--enablerepo)
COMPREPLY=( $( compgen -W '$( _yum_repolist \
disabled )' -- $cur ) )
;;
--disablerepo)
COMPREPLY=( $( compgen -W '$( _yum_repolist \
enabled )' -- $cur ) )
;;
--disableexcludes)
COMPREPLY=( $( compgen -W '$( _yum_repolist all ) \
all main' -- $cur ) )
;;
--enableplugin|--disableplugin)
COMPREPLY=( $( compgen -W '$( _yum_plugins )' -- $cur ))
;;
--color)
COMPREPLY=( $( compgen -W 'always auto never' -- $cur ))
;;
-R|-x|--exclude)
# argument required but no completions available
return 0
;;
-h|--help|--version)
# no other options useful with these
return 0
;;
*)
COMPREPLY=( $( compgen -W 'install update \
check-update upgrade remove erase list info \
provides whatprovides clean makecache \
groupinstall groupupdate grouplist \
groupremove groupinfo search shell resolvedep \
localinstall localupdate deplist repolist \
help' -- $cur ) )
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-h --help -t --tolerant -C -c -R \
-d --showduplicates -e -q --quiet -v --verbose -y \
--version --installroot --enablerepo --disablerepo -x \
--exclude --disableexcludes --obsoletes --noplugins \
--nogpgcheck --disableplugin --enableplugin \
--skip-broken --color' -- $cur ) )
return 0
fi
}
} &&
complete -F _yum $filenames yum
# yum-arch(8) completion
#
have yum-arch &&
_yum_arch()
{
local cur
COMPREPLY=()
cur=`_get_cword`
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l \
-q' -- $cur ) )
;;
*)
_filedir -d
;;
esac
return 0
} &&
complete -F _yum_arch $filenames yum-arch

View File

@ -6,12 +6,12 @@
have apache2ctl && { have apache2ctl && {
_apache2ctl() { _apache2ctl() {
local APWORDS local APWORDS
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
APWORDS=$(apache2ctl 2>&1 >/dev/null | head -n1 | cut -f3 -d" " | tr "|" " ") APWORDS=$(apache2ctl 2>&1 >/dev/null | head -n1 | cut -f3 -d" " | tr "|" " ")
COMPREPLY=( $( compgen -W "$APWORDS" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$APWORDS" -- "$cur" ) )
} }
complete -F _apache2ctl apache2ctl complete -F _apache2ctl apache2ctl

View File

@ -116,7 +116,7 @@ _apt_cache()
uniq | cut -f2 -d" " ) ) uniq | cut -f2 -d" " ) )
return 0 return 0
;; ;;
*) *)
COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) ) COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
return 0 return 0

View File

@ -31,7 +31,7 @@ _bluetooth_packet_types()
$cur ) ) $cur ) )
} }
_get_command() _get_command()
{ {
local i local i
@ -163,7 +163,7 @@ _sdptool()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--bdaddr \ COMPREPLY=( $( compgen -W '--bdaddr \
--tree --raw --xml' -- $cur ) ) --tree --raw --xml' -- $cur ) )
else else
_bluetooth_services _bluetooth_services
fi fi
;; ;;
@ -171,7 +171,7 @@ _sdptool()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--tree \ COMPREPLY=( $( compgen -W '--tree \
--raw --xml' -- $cur ) ) --raw --xml' -- $cur ) )
else else
_bluetooth_adresses _bluetooth_adresses
fi fi
;; ;;
@ -352,7 +352,7 @@ _hciconfig()
voice iac inqmode inqdata inqtype inqparams \ voice iac inqmode inqdata inqtype inqparams \
pageparms pageto afhmode aclmtu scomtu putkey \ pageparms pageto afhmode aclmtu scomtu putkey \
delkey commands features version revision lm' \ delkey commands features version revision lm' \
-- $cur ) ) -- $cur ) )
fi fi
else else
case $command in case $command in

View File

@ -8,12 +8,12 @@ _cksfv()
{ {
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
if [ $COMP_CWORD -eq 1 ]; then if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W '-C -f -i -q -v' -- $cur ) ) COMPREPLY=( $( compgen -W '-C -f -i -q -v' -- $cur ) )
return 0 return 0
fi fi
case "${COMP_WORDS[$COMP_CWORD-1]}" in case "${COMP_WORDS[$COMP_CWORD-1]}" in
-C) -C)
_filedir -d _filedir -d
@ -24,7 +24,7 @@ _cksfv()
return 0 return 0
;; ;;
esac esac
_filedir _filedir
return 0 return 0
} && } &&

View File

@ -39,7 +39,7 @@ _cpan2dist()
done done
COMPREPLY=( $( zgrep "^${cur//-/::}" \ COMPREPLY=( $( zgrep "^${cur//-/::}" \
$packagelist 2>/dev/null \ $packagelist 2>/dev/null \
| awk '{print $1}' | sed -e 's/::/-/g' ) ) | awk '{print $1}' | sed -e 's/::/-/g' ) )
fi fi
} && } &&
complete -F _cpan2dist $default cpan2dist complete -F _cpan2dist $default cpan2dist

View File

@ -32,7 +32,7 @@ _gdb()
elif [ $COMP_CWORD -eq 2 ]; then elif [ $COMP_CWORD -eq 2 ]; then
prev=${prev##*/} prev=${prev##*/}
COMPREPLY=( $( compgen -fW "$( command ps axo comm,pid | \ COMPREPLY=( $( compgen -fW "$( command ps axo comm,pid | \
awk '{if ($1 ~ /^'"$prev"'/) print $2}' ) )" \ awk '{if ($1 ~ /^'"$prev"'/) print $2}' )" \
-- "$cur" ) ) -- "$cur" ) )
fi fi
} && } &&

View File

@ -27,7 +27,7 @@ _gnatmake()
else else
# source file completion # source file completion
_filedir '@(adb|ads)' _filedir '@(adb|ads)'
fi fi
} && } &&
complete -F _gnatmake $filenames gnatmake complete -F _gnatmake $filenames gnatmake

View File

@ -7,11 +7,11 @@ have gpg2 && {
_gpg2 () _gpg2 ()
{ {
local cur prev local cur prev
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in case "$prev" in
--homedir) --homedir)
_filedir -d _filedir -d
@ -34,7 +34,7 @@ _gpg2 ()
return 0 return 0
;; ;;
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-s -b -e -c -d -k -K -a -r -u -z -o -v \ COMPREPLY=( $( compgen -W '-s -b -e -c -d -k -K -a -r -u -z -o -v \
-n -N -i -h -R -t $(gpg2 --dump-options)' -- $cur ) ) -n -N -i -h -R -t $(gpg2 --dump-options)' -- $cur ) )

View File

@ -522,7 +522,7 @@ _stream()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-authenticate -channel -colorspace \ COMPREPLY=( $( compgen -W '-authenticate -channel -colorspace \
-compress -debug -define -density -depth -extract \ -compress -debug -define -density -depth -extract \
-help -identify -interlace -interpolate -limit -list \ -help -identify -interlace -interpolate -limit -list \
-log -map -monitor -quantize -quiet -regard-warnings \ -log -map -monitor -quantize -quiet -regard-warnings \
-respect-parenthesis -sampling-factor -seed -set \ -respect-parenthesis -sampling-factor -seed -set \

View File

@ -6,7 +6,7 @@
have info && have info &&
_info() _info()
{ {
local cur infopath local cur i infopath
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`

View File

@ -8,7 +8,7 @@ _isql()
{ {
local cur local cur
cur=`_get_cword` cur=`_get_cword`
[ -f "$ODBCINI" ] && COMPREPLY=( $( grep \\[$cur "$ODBCINI" | tr -d \\[\\] ) ) [ -f "$ODBCINI" ] && COMPREPLY=( $( grep \\[$cur "$ODBCINI" | tr -d \\[\\] ) )
} && } &&
complete -F _isql isql complete -F _isql isql

View File

@ -75,12 +75,12 @@ _java_classes()
elif [ -d $i ]; then elif [ -d $i ]; then
i=${i%/} i=${i%/}
# See Debian bug #496828 # See Debian bug #496828
COMPREPLY=( "${COMPREPLY[@]}" $( find "$i" -type f \ COMPREPLY=( "${COMPREPLY[@]}" $( find "$i" -type f \
-maxdepth 1 -path "$i/$cur*.class" 2>/dev/null | \ -maxdepth 1 -path "$i/$cur*.class" 2>/dev/null | \
grep -v "\\$" | sed -e "s|^$i/||" ) ) grep -v "\\$" | sed -e "s|^$i/||" ) )
# FIXME: if we have foo.class and foo/, the completion # FIXME: if we have foo.class and foo/, the completion
# returns "foo/"... how to give precedence to files # returns "foo/"... how to give precedence to files
# over directories? # over directories?

View File

@ -424,7 +424,7 @@ _arch()
1) 1)
_mailman_lists _mailman_lists
;; ;;
2) 2)
_filedir _filedir
;; ;;
esac esac

View File

@ -63,7 +63,7 @@ _make()
[ -n "$makef" ] && makef="-f ${makef}" [ -n "$makef" ] && makef="-f ${makef}"
[ -n "$makef_dir" ] && makef_dir="-C ${makef_dir}" [ -n "$makef_dir" ] && makef_dir="-C ${makef_dir}"
COMPREPLY=( $( compgen -W "$( make -qp $makef $makef_dir 2>/dev/null | \ COMPREPLY=( $( compgen -W "$( make -qp $makef $makef_dir 2>/dev/null | \
awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \ awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \
{split($1,A,/ /);for(i in A)print A[i]}' )" \ {split($1,A,/ /);for(i in A)print A[i]}' )" \

View File

@ -8,7 +8,7 @@
-o $UNAME = OpenBSD ] && -o $UNAME = OpenBSD ] &&
_man() _man()
{ {
local cur prev sect manpath manext mansect uname local cur i prev sect manpath manext mansect uname
manext="@([0-9lnp]|[0-9][px]|man|3pm)?(.@(gz|bz2|lzma))" manext="@([0-9lnp]|[0-9][px]|man|3pm)?(.@(gz|bz2|lzma))"
mansect="@([0-9lnp]|[0-9][px]|3pm)" mansect="@([0-9lnp]|[0-9][px]|3pm)"
@ -16,7 +16,7 @@ _man()
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$prev" == -l ]]; then if [[ "$prev" == -l ]]; then
_filedir $manext _filedir $manext
return 0 return 0

View File

@ -17,7 +17,9 @@
# module command is an alias, and the `module avail' command returns # module command is an alias, and the `module avail' command returns
# its output as stderr. # its output as stderr.
type module &>/dev/null && { # Test for existence of /etc/profile.d/modules.sh too because we may end up
# being sourced before it and thus before the `module' alias has been defined.
have module || [ -f /etc/profile.d/modules.sh ] && {
_module_list () _module_list ()
{ {
@ -80,5 +82,5 @@ _module () {
fi fi
return 0 return 0
} }
complete -o default -F _module module complete -F _module $default module
} }

View File

@ -8,7 +8,7 @@ _monodevelop()
{ {
local cur local cur
cur=`_get_cword` cur=`_get_cword`
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-? -help \ COMPREPLY=( $( compgen -W '-? -help \
-help2 \ -help2 \
@ -33,7 +33,7 @@ _mdtool()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
if [[ ${COMP_WORDS[i]} == @(build|generate-makefiles|setup) ]]; then if [[ ${COMP_WORDS[i]} == @(build|generate-makefiles|setup) ]]; then
command=${COMP_WORDS[i]} command=${COMP_WORDS[i]}
@ -87,11 +87,11 @@ _mdtool()
;; ;;
esac esac
fi fi
COMPREPLY=( $( compgen -W 'gsetup build dbgen project-export \ COMPREPLY=( $( compgen -W 'gsetup build dbgen project-export \
generate-makefiles gettext-update \ generate-makefiles gettext-update \
setup -q' -- "$cur" ) ) setup -q' -- "$cur" ) )
return 0 return 0
} && } &&
complete -F _mdtool $filenames mdtool complete -F _mdtool $filenames mdtool

View File

@ -7,7 +7,7 @@ have mtx &&
_mtx() _mtx()
{ {
local cur prev options tapes drives local cur prev options tapes drives
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
@ -25,9 +25,9 @@ _mtx()
drives=${drives//:Empty} drives=${drives//:Empty}
if [ $COMP_CWORD -gt 1 ]; then if [ $COMP_CWORD -gt 1 ]; then
case $prev in case $prev in
load) load)
COMPREPLY=( $( compgen -W "$tapes" -- $cur ) ) COMPREPLY=( $( compgen -W "$tapes" -- $cur ) )
;; ;;
unload|first|last|next) unload|first|last|next)
COMPREPLY=( $( compgen -W "$drives" -- $cur ) ) COMPREPLY=( $( compgen -W "$drives" -- $cur ) )

View File

@ -39,7 +39,7 @@ _muttconffiles()
_muttaliases() _muttaliases()
{ {
local cur muttrc local cur muttrc muttcmd=${COMP_WORDS[0]}
local -a conffiles aliases local -a conffiles aliases
cur=`_get_cword =` cur=`_get_cword =`
@ -57,7 +57,7 @@ _muttaliases()
_muttquery() _muttquery()
{ {
local cur querycmd local cur querycmd muttcmd=${COMP_WORDS[0]}
local -a queryresults local -a queryresults
cur=`_get_cword` cur=`_get_cword`
@ -77,7 +77,7 @@ _muttquery()
_muttfiledir() _muttfiledir()
{ {
local cur folder spoolfile local cur folder spoolfile muttcmd=${COMP_WORDS[0]}
cur=`_get_cword` cur=`_get_cword`
# This is currently not working so well. Perhaps this function should # This is currently not working so well. Perhaps this function should
@ -108,8 +108,6 @@ _mutt()
COMPREPLY=() COMPREPLY=()
[ ${COMP_WORDS[0]} == muttng ] && muttcmd="muttng" || muttcmd="mutt"
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W '-A -a -b -c -e -f -F -H -i -m -n \ COMPREPLY=( $( compgen -W '-A -a -b -c -e -f -F -H -i -m -n \

View File

@ -209,7 +209,7 @@ _openssl()
-no_tls1 -bugs -cipher \ -no_tls1 -bugs -cipher \
-starttls -engine -tlsextdebug \ -starttls -engine -tlsextdebug \
-no_ticket -sess_out -sess_in \ -no_ticket -sess_out -sess_in \
-rand' -rand'
;; ;;
s_server) s_server)
options='-accept -context -verify \ options='-accept -context -verify \
@ -217,7 +217,7 @@ _openssl()
-crl_check_all -cert -certform \ -crl_check_all -cert -certform \
-key -keyform -pass -dcert \ -key -keyform -pass -dcert \
-dcertform -dkey -dkeyform \ -dcertform -dkey -dkeyform \
-dpass -dhparam -nbio -dpass -dhparam -nbio \
-nbio_test -crlf -debug -msg \ -nbio_test -crlf -debug -msg \
-state -CApath -CAfile -nocert \ -state -CApath -CAfile -nocert \
-cipher -quiet -no_tmp_rsa \ -cipher -quiet -no_tmp_rsa \

View File

@ -6,7 +6,7 @@
have psql && { have psql && {
_pg_databases() _pg_databases()
{ {
return # intentionally disabled in 7ebed6af (TODO: why?) return # See https://launchpad.net/bugs/164772
COMPREPLY=( $( compgen -W "$( psql -l 2>/dev/null | \ COMPREPLY=( $( compgen -W "$( psql -l 2>/dev/null | \
sed -e '1,/^-/d' -e '/^(/,$d' | \ sed -e '1,/^-/d' -e '/^(/,$d' | \
awk '{print $1}' )" -- $cur ) ) awk '{print $1}' )" -- $cur ) )
@ -14,6 +14,7 @@ _pg_databases()
_pg_users() _pg_users()
{ {
# See https://launchpad.net/bugs/164772
#COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \ #COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
# grep "^ $cur" ) ) # grep "^ $cur" ) )
#[ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- $cur ) ) #[ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- $cur ) )

View File

@ -6,55 +6,55 @@
have povray || have xpovray || have spovray && have povray || have xpovray || have spovray &&
_povray() _povray()
{ {
local cur prev povcur pfx oext defoext local cur prev povcur pfx oext defoext
defoext=png # default output extension, if cannot be determined FIXME defoext=png # default output extension, if cannot be determined FIXME
COMPREPLY=() COMPREPLY=()
povcur=`_get_cword` povcur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_expand || return 0 _expand || return 0
case $povcur in case $povcur in
[-+]I*) [-+]I*)
cur="${povcur#[-+]I}" # to confuse _filedir cur="${povcur#[-+]I}" # to confuse _filedir
pfx="${povcur%"$cur"}" pfx="${povcur%"$cur"}"
_filedir pov _filedir pov
COMPREPLY=( ${COMPREPLY[@]/#/$pfx} ) COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
return 0 return 0
;; ;;
[-+]O*) [-+]O*)
# guess what output file type user may want # guess what output file type user may want
case $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]F' ) ) in case $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]F' ) ) in
[-+]FN) oext=png ;; [-+]FN) oext=png ;;
[-+]FP) oext=ppm ;; [-+]FP) oext=ppm ;;
[-+]F[CT]) oext=tga ;; [-+]F[CT]) oext=tga ;;
*) oext=$defoext ;; *) oext=$defoext ;;
esac esac
# complete filename corresponding to previously specified +I # complete filename corresponding to previously specified +I
COMPREPLY=( $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]I' ) ) ) COMPREPLY=( $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]I' ) ) )
COMPREPLY=( ${COMPREPLY[@]#[-+]I} ) COMPREPLY=( ${COMPREPLY[@]#[-+]I} )
COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} ) COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} )
cur="${povcur#[-+]O}" # to confuse _filedir cur="${povcur#[-+]O}" # to confuse _filedir
pfx="${povcur%"$cur"}" pfx="${povcur%"$cur"}"
_filedir $oext _filedir $oext
COMPREPLY=( ${COMPREPLY[@]/#/$pfx} ) COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
return 0 return 0
;; ;;
*.ini\[|*.ini\[*[^]]) # sections in .ini files *.ini\[|*.ini\[*[^]]) # sections in .ini files
cur="${povcur#*\[}" cur="${povcur#*\[}"
pfx="${povcur%\["$cur"}" # prefix == filename pfx="${povcur%\["$cur"}" # prefix == filename
[ -r "$pfx" ] || return 0 [ -r "$pfx" ] || return 0
COMPREPLY=( $(sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' -e 't' -e 'd' -- "$pfx") ) COMPREPLY=( $(sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' -e 't' -e 'd' -- "$pfx") )
# to prevent [bar] expand to nothing. can be done more easily? # to prevent [bar] expand to nothing. can be done more easily?
COMPREPLY=( "${COMPREPLY[@]/#/$pfx[}" ) COMPREPLY=( "${COMPREPLY[@]/#/$pfx[}" )
return 0 return 0
;; ;;
*) *)
cur="$povcur" cur="$povcur"
_filedir '?(ini|pov)' _filedir '?(ini|pov)'
return 0 return 0
;; ;;
esac esac
} && } &&
complete -F _povray $filenames povray xpovray spovray complete -F _povray $filenames povray xpovray spovray

View File

@ -6,7 +6,7 @@
have python && have python &&
_python() _python()
{ {
local prev cur local prev cur i
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`

View File

@ -7,7 +7,7 @@ have qdbus &&
_qdbus() _qdbus()
{ {
local cur compstr local cur compstr
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
if [ -z "$cur" ]; then if [ -z "$cur" ]; then

View File

@ -59,7 +59,7 @@ _ri()
method=${cur#*$separator} method=${cur#*$separator}
classes=( $class ) classes=( $class )
prefix="-P $class$separator" prefix="-P $class$separator"
ri_get_methods ri_get_methods
return 0 return 0
fi fi

View File

@ -33,7 +33,7 @@ _rpm_nodigsig()
{ {
if [ -z "$nodig" -a -z "$nosig" ]; then if [ -z "$nodig" -a -z "$nosig" ]; then
local rpmver local rpmver
rpmver=$(rpm --version) rpmver=$(rpm --version)
rpmver=${rpmver##* } rpmver=${rpmver##* }
@ -255,7 +255,7 @@ _rpm()
elif [[ ${COMP_WORDS[1]} == -b* ]]; then elif [[ ${COMP_WORDS[1]} == -b* ]]; then
_filedir 'spec' _filedir 'spec'
else else
_filedir '@(tgz|tar.@(gz|bz2|lzma))' _filedir '@(t?(ar.)@([gx]z|bz?(2))|tar.@(lzma|Z))'
fi fi
;; ;;
--re@(build|compile)) --re@(build|compile))
@ -267,7 +267,7 @@ _rpm()
fi fi
;; ;;
--tarbuild) --tarbuild)
_filedir '@(tgz|tar.@(gz|bz2|lzma))' _filedir '@(t?(ar.)@([gx]z|bz?(2))|tar.@(lzma|Z))'
;; ;;
--@(re|add)sign) --@(re|add)sign)
_filedir 'rpm' _filedir 'rpm'

View File

@ -23,4 +23,4 @@ _sbcl()
return 0 return 0
} && } &&
complete -F _sbcl $default sbcl sbcl-mt complete -F _sbcl $filenames sbcl sbcl-mt

View File

@ -52,7 +52,7 @@ _screen()
COMPREPLY=( $( grep ^${cur:-[^#]} /etc/shells ) ) COMPREPLY=( $( grep ^${cur:-[^#]} /etc/shells ) )
;; ;;
-c) -c)
_filedirs _filedir
return 0 return 0
;; ;;
esac esac

View File

@ -29,8 +29,7 @@ _ssh_options() {
_ssh() _ssh()
{ {
local cur prev local cur prev configfile
local optconfigfile
local -a config local -a config
COMPREPLY=() COMPREPLY=()
@ -75,26 +74,32 @@ _ssh()
;; ;;
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -F* ]]; then
cur=${cur#-F}
_filedir
# Prefix completions with '-F'
COMPREPLY=( "${COMPREPLY[@]/#/-F}" )
cur=-F$cur # Restore cur
elif [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-1 -2 -4 -6 -A -a -C -f -g -K -k -M \ COMPREPLY=( $( compgen -W '-1 -2 -4 -6 -A -a -C -f -g -K -k -M \
-N -n -q -s -T -t -V -v -X -v -Y -y -b -b -c -D -e -F \ -N -n -q -s -T -t -V -v -X -v -Y -y -b -b -c -D -e -F \
-i -L -l -m -O -o -p -R -S -w' -- $cur ) ) -i -L -l -m -O -o -p -R -S -w' -- $cur ) )
else else
# Search COMP_WORDS for '-F configfile' argument # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
set -- "${COMP_WORDS[@]}" set -- "${COMP_WORDS[@]}"
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
if [ "${1:0:2}" = -F ]; then if [ "${1:0:2}" = -F ]; then
if [ ${#1} -gt 2 ]; then if [ ${#1} -gt 2 ]; then
optconfigfile="$(dequote "$1")" configfile="$(dequote "${1:2}")"
else else
shift shift
[ "$1" ] && optconfigfile="$(dequote "-F$1")" [ "$1" ] && configfile="$(dequote "$1")"
fi fi
break break
fi fi
shift shift
done done
_known_hosts_real -a $optconfigfile "$cur" _known_hosts_real -a -F "$configfile" "$cur"
if [ $COMP_CWORD -ne 1 ]; then if [ $COMP_CWORD -ne 1 ]; then
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) ) COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
fi fi
@ -108,8 +113,7 @@ shopt -u hostcomplete && complete -F _ssh ssh slogin autossh
# #
_sftp() _sftp()
{ {
local cur prev local cur prev configfile
local optconfigfile
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
@ -117,7 +121,7 @@ _sftp()
case "$prev" in case "$prev" in
-@(b|F|P)) -@(b|F|P))
_filedirs _filedir
return 0 return 0
;; ;;
-o) -o)
@ -126,7 +130,13 @@ _sftp()
;; ;;
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -F* ]]; then
cur=${cur#-F}
_filedir
# Prefix completions with '-F'
COMPREPLY=( "${COMPREPLY[@]/#/-F}" )
cur=-F$cur # Restore cur
elif [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-1 -C -v -B -b -F -o -P -R -S -s' \ COMPREPLY=( $( compgen -W '-1 -C -v -B -b -F -o -P -R -S -s' \
-- $cur ) ) -- $cur ) )
else else
@ -135,16 +145,16 @@ _sftp()
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
if [ "${1:0:2}" = -F ]; then if [ "${1:0:2}" = -F ]; then
if [ ${#1} -gt 2 ]; then if [ ${#1} -gt 2 ]; then
optconfigfile="$(dequote "$1")" configfile="$(dequote "${1:2}")"
else else
shift shift
[ "$1" ] && optconfigfile="$(dequote "-F$1")" [ "$1" ] && configfile="$(dequote "$1")"
fi fi
break break
fi fi
shift shift
done done
_known_hosts_real -a $optconfigfile "$cur" _known_hosts_real -a -F "$configfile" "$cur"
fi fi
return 0 return 0
@ -156,8 +166,7 @@ shopt -u hostcomplete && complete -F _sftp sftp
# #
_scp() _scp()
{ {
local cur userhost path local configfile cur userhost path prefix
local optconfigfile
COMPREPLY=() COMPREPLY=()
cur=`_get_cword ":"` cur=`_get_cword ":"`
@ -185,30 +194,34 @@ _scp()
return 0 return 0
fi fi
# Search COMP_WORDS for '-F configfile' argument if [[ "$cur" = -F* ]]; then
set -- "${COMP_WORDS[@]}" cur=${cur#-F}
while [ $# -gt 0 ]; do prefix=-F
if [ "${1:0:2}" = -F ]; then else
if [ ${#1} -gt 2 ]; then # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
optconfigfile="$(dequote "$1")" set -- "${COMP_WORDS[@]}"
else while [ $# -gt 0 ]; do
shift if [ "${1:0:2}" = -F ]; then
[ "$1" ] && optconfigfile="$(dequote "-F$1")" if [ ${#1} -gt 2 ]; then
configfile="$(dequote "${1:2}")"
else
shift
[ "$1" ] && configfile="$(dequote "$1")"
fi
break
fi fi
break shift
fi done
shift
done
[[ "$cur" == */* ]] || _known_hosts_real -c -a $optconfigfile "$cur"
[[ "$cur" == */* ]] || _known_hosts_real -c -a -F "$configfile" "$cur"
fi
# This approach is used instead of _filedir to get a space appended # This approach is used instead of _filedir to get a space appended
# after local file/dir completions, and $nospace retained for others. # after local file/dir completions, and $nospace retained for others.
local IFS=$'\t\n' local IFS=$'\t\n'
COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \ COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \
2>/dev/null | sed \ 2>/dev/null | sed \
-e "s/[][(){}<>\",:;^&\!$=?\`|\\ ']/\\\\&/g" \ -e "s/[][(){}<>\",:;^&\!$=?\`|\\ ']/\\\\&/g" \
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) ) -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' -e "s/^/$prefix/") )
return 0 return 0
} }

View File

@ -3,7 +3,7 @@
# #
# bash completion for strace # bash completion for strace
have strace && have strace &&
_strace() _strace()
{ {
local cur prev offset i syscalls arch unistd local cur prev offset i syscalls arch unistd
@ -38,7 +38,7 @@ _strace()
if [[ "$cur" == *=* ]]; then if [[ "$cur" == *=* ]]; then
prev=${cur/=*/} prev=${cur/=*/}
cur=${cur/*=/} cur=${cur/*=/}
# Import arch-specific syscalls -- not foolproof IMHO # Import arch-specific syscalls -- not foolproof IMHO
#+ --David Paleino #+ --David Paleino
arch=$(command uname -m) arch=$(command uname -m)

View File

@ -4,7 +4,7 @@
# unace(1) completion by Guillaume Rousse <rousse@ccr.jussieu.fr> # unace(1) completion by Guillaume Rousse <rousse@ccr.jussieu.fr>
have unace && have unace &&
_unace() _unace()
{ {
local cur local cur
@ -23,7 +23,7 @@ _unace()
fi fi
;; ;;
esac esac
return 0 return 0
} && } &&

View File

@ -4,7 +4,7 @@
# unrar(1) completion by Guillaume Rousse <rousse@ccr.jussieu.fr> # unrar(1) completion by Guillaume Rousse <rousse@ccr.jussieu.fr>
have unrar && have unrar &&
_unrar() _unrar()
{ {
local cur local cur
@ -25,7 +25,7 @@ _unrar()
fi fi
;; ;;
esac esac
return 0 return 0
} && } &&
complete -F _unrar $filenames unrar complete -F _unrar $filenames unrar

View File

@ -7,7 +7,7 @@ have vncviewer &&
_vncviewer_bootstrap() { _vncviewer_bootstrap() {
local fname local fname
case "$(_realcommand vncviewer)" in case "$(_realcommand vncviewer)" in
# If `vncviewer' not installed, default file-dir completion # If `vncviewer' not installed, default file-dir completion
'') _filedir `_get_cword` ;; '') _filedir `_get_cword` ;;
*xvnc4viewer) fname=_xvnc4viewer ;; *xvnc4viewer) fname=_xvnc4viewer ;;
*tightvncviewer|*) fname=_tightvncviewer ;; *tightvncviewer|*) fname=_tightvncviewer ;;
@ -117,7 +117,7 @@ _xvnc4viewer()
# Variable 'nocasematch' isn't available; # Variable 'nocasematch' isn't available;
# Convert completions to lowercase # Convert completions to lowercase
COMPREPLY=( $( compgen -W "$( COMPREPLY=( $( compgen -W "$(
echo ${options[@]/#/$dash} | tr [:upper:] [:lower:] echo ${options[@]/#/$dash} | tr [:upper:] [:lower:]
)" -- "$(echo "$cur" | tr [:upper:] [:lower:])" ) ) )" -- "$(echo "$cur" | tr [:upper:] [:lower:])" ) )
fi fi
else else

View File

@ -19,7 +19,7 @@ _vpnc()
return 0 return 0
;; ;;
--pfs) --pfs)
COMPREPLY=( $( compgen -W 'dh1 dh2 dh5' -- $cur ) ) COMPREPLY=( $( compgen -W 'dh1 dh2 dh5' -- $cur ) )
return 0 return 0
;; ;;
--@(pid-file|script)) --@(pid-file|script))

View File

@ -32,7 +32,7 @@ _xm()
vtpm-list vnet-list vnet-create vnet-delete labels addlabel \ vtpm-list vnet-list vnet-create vnet-delete labels addlabel \
rmlabel getlabel dry-run resources makepolicy loadpolicy \ rmlabel getlabel dry-run resources makepolicy loadpolicy \
cfgbootpolicy dumppolicy help' cfgbootpolicy dumppolicy help'
if [[ $COMP_CWORD -eq 1 ]] ; then if [[ $COMP_CWORD -eq 1 ]] ; then
COMPREPLY=( $( compgen -W "$commands" -- $cur ) ) COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
else else

View File

@ -17,8 +17,24 @@ _xmllint()
_filedir _filedir
return 0 return 0
;; ;;
--path|--dtdvalid|--dtdvalidfpi|--maxmem|--encode|--pattern|\ --path|--dtdvalidfpi|--maxmem|--encode|--pattern)
--relaxng|--schema|--schematron) # argument required but no completions available
return 0
;;
--dtdvalid)
_filedir dtd
return 0
;;
--relaxng)
_filedir rng
return 0
;;
--schema)
_filedir xsd
return 0
;;
--schematron)
_filedir sch
return 0 return 0
;; ;;
esac esac

35
contrib/xmlwf Normal file
View File

@ -0,0 +1,35 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for xmlwf(1)
have xmlwf &&
_xmlwf()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-d)
_filedir -d
return 0
;;
-e)
COMPREPLY=( $( compgen -W 'US-ASCII UTF-8 UTF-16 \
ISO-8859-1' -- $cur ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-c -d -e -m -n -p -r -s -t -v -w \
-x' -- $cur ) )
return 0
fi
_filedir '@(*ml|htm|svg)'
} &&
complete -F _xmlwf $filenames xmlwf

99
contrib/xz Normal file
View File

@ -0,0 +1,99 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
# xz(1) completion
#
have xz &&
_xz()
{
COMPREPLY=()
local cur=`_get_cword`
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-z --compress -d --decompress \
-t --test -l --list -k --keep -f --force -c --stdout \
-S --suffix --files --files0 -F --format -C --check \
-0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -M --memory --lzma1 \
--lzma2 --x86 --powerpc --ia64 --arm --armthumb \
--sparc --delta -q --quiet -v --verbose -h --help \
-H --long-help -V --version' -- $cur ) )
return 0
fi
local split=false
_split_longopt && split=true
local xspec="*.@(xz|lzma)"
case "$prev" in
-@(!(-*)[dlt]*|-decompress|-list|-test))
xspec="!"$xspec
;;
--files|--files0)
_filedir
return 0
;;
-C|--check)
COMPREPLY=( $( compgen -W 'crc32 crc64 sha256' \
-- $cur ) )
return 0
;;
-F|--format)
COMPREPLY=( $( compgen -W 'auto xz lzma raw' -- $cur ) )
return 0
;;
-M|--memory|-S|--suffix|--delta|--lzma1|--lzma2)
# argument required but no completions available
return 0
;;
-h|--help|-H|--long-help|-V|--version)
# all other arguments are noop with these
return 0
;;
esac
$split && return 0
_expand || return 0
local IFS=$'\t\n'
COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
$( compgen -d -- $cur ) )
} &&
complete -F _xz $filenames xz
# xzdec(1) completion
#
have xzdec &&
_xzdec()
{
COMPREPLY=()
local cur=`_get_cword`
local prev=${COMP_WORDS[COMP_CWORD-1]}
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-M --memory -h --help -V --version' \
-- $cur ) )
return 0
fi
local split=false
_split_longopt && split=true
case "$prev" in
-M|--memory)
# argument required but no completions available
return 0
;;
-h|--help|-V|--version)
# all other arguments are noop with these
return 0
;;
esac
$split && return 0
_filedir xz # no lzma support here as of xz 4.999.8beta
} &&
complete -F _xzdec $filenames xzdec

View File

@ -1,171 +0,0 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
# yum(8) completion
#
have yum && {
_yum_list()
{
if [[ "$1" == all ]] ; then
# Try to strip in between headings like "Available Packages"
# This will obviously only work for English :P
COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \
sed -ne '/^\(Available\|Installed\|Updated\) /d' \
-e 's/[[:space:]].*//p' ) )
else
# Drop first line (e.g. "Updated Packages")
COMPREPLY=( $( yum -d 0 -C list $1 "$cur*" 2>/dev/null | \
sed -ne 1d -e 's/[[:space:]].*//p' ) )
fi
}
_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") and last ("repolist: ...") rows
yum --noplugins -C repolist $1 2>/dev/null | \
sed -ne '/^repo\(\s\+id\|list:\)/d' -e 's/[[:space:]].*//p'
}
_yum()
{
local cur prev special split=false
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
if [[ ${COMP_WORDS[i]} == @(install|update|upgrade|remove|erase|deplist|info) ]]; then
special=${COMP_WORDS[i]}
fi
done
if [ -n "$special" ]; then
# TODO: install|update|upgrade should not match *src.rpm
if [[ "$cur" == */* && "$special" == @(deplist|install|update|upgrade) ]]; then
_filedir rpm
return 0
fi
case $special in
install)
_yum_list available
return 0
;;
deplist|info)
_yum_list all
return 0
;;
upgrade|update)
_yum_list updates
return 0
;;
remove|erase)
# _rpm_installed_packages is not arch-qualified
_yum_list installed
return 0
;;
esac
fi
_split_longopt && split=true
case $prev in
list)
COMPREPLY=( $( compgen -W 'all available updates \
installed extras obsoletes recent' -- $cur ) )
;;
clean)
COMPREPLY=( $( compgen -W 'packages headers metadata \
cache dbcache all' -- $cur ) )
;;
repolist)
COMPREPLY=( $( compgen -W 'all enabled disabled' \
-- $cur ) )
;;
localinstall|localupdate)
# TODO: should not match *src.rpm
_filedir rpm
;;
-d|-e)
COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9 10' \
-- $cur ) )
;;
-c)
_filedir
;;
--installroot)
_filedir -d
;;
--enablerepo)
COMPREPLY=( $( compgen -W '$( _yum_repolist \
disabled )' -- $cur ) )
;;
--disablerepo)
COMPREPLY=( $( compgen -W '$( _yum_repolist \
enabled )' -- $cur ) )
;;
--disableexcludes)
COMPREPLY=( $( compgen -W '$( _yum_repolist all ) \
all main' -- $cur ) )
;;
--color)
COMPREPLY=( $( compgen -W 'always auto never' -- $cur ))
;;
-R|-x|--exclude)
# argument required but no completions available
return 0
;;
-h|--help|--version)
# no other options useful with these
return 0
;;
*)
COMPREPLY=( $( compgen -W 'install update \
check-update upgrade remove erase list info \
provides whatprovides clean makecache \
groupinstall groupupdate grouplist \
groupremove groupinfo search shell resolvedep \
localinstall localupdate deplist repolist \
help' -- $cur ) )
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-h --help -t --tolerant -C -c -R \
-d --showduplicates -e -q --quiet -v --verbose -y \
--version --installroot --enablerepo --disablerepo -x \
--exclude --disableexcludes --obsoletes --noplugins \
--nogpgcheck --disableplugin --enableplugin \
--skip-broken --color' -- $cur ) )
return 0
fi
}
} &&
complete -F _yum $filenames yum
# yum-arch(8) completion
#
have yum-arch &&
_yum_arch()
{
local cur
COMPREPLY=()
cur=`_get_cword`
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l \
-q' -- $cur ) )
;;
*)
_filedir -d
;;
esac
return 0
} &&
complete -F _yum_arch $filenames yum-arch

25
contrib/yum-arch Normal file
View File

@ -0,0 +1,25 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
# yum-arch(8) completion
#
have yum-arch &&
_yum_arch()
{
local cur
COMPREPLY=()
cur=`_get_cword`
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l \
-q' -- $cur ) )
;;
*)
_filedir -d
;;
esac
return 0
} &&
complete -F _yum_arch $filenames yum-arch

34
doc/bash_completion.txt Normal file
View File

@ -0,0 +1,34 @@
Bash completion
===============
Environment variables
---------------------
*COMP_CONFIGURE_HINTS*::
If set and not null, `configure` completion will return the entire option
string (e.g. `--this-option=DESCRIPTION`) so one can see what kind of data
is required and then simply delete the descriptive text and add one's own
data. If unset or null (default), `configure` completion will strip
everything after the '=' when returning completions.
*COMP_CVS_REMOTE*::
If set and not null, `cvs commit` completion will try to complete on
remotely checked-out files. This requires passwordless access to the
remote repository. Default is unset.
*COMP_KNOWN_HOSTS_WITH_HOSTFILE*::
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
hostnames from HOSTFILE is useful if HOSTFILE contains many entries for
local web development or ad-blocking.
*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,
`tar' completion will do correct completion for paths to tar files. See
also README.

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@ common Linux/UNIX commands, reducing the amount of typing sysadmins
and programmers need to do on a daily basis. and programmers need to do on a daily basis.
// include::intro.txt[] // include::intro.txt[]
// include::bash_completion.txt[] include::bash_completion.txt[]
include::styleguide.txt[] include::styleguide.txt[]
include::testing.txt[] include::testing.txt[]

View File

@ -1,4 +1,4 @@
#!/bin/bash -eu #!/bin/bash -eu
[ -d html~ ] || mkdir html~ [ -d html~ ] || mkdir html~
a2x -D html~ -d book -f xhtml main.txt a2x -D html~ -d book -f xhtml --asciidoc-opts="--unsafe" main.txt

View File

@ -10,10 +10,10 @@ The bash-completion test suite is written on top of the http://www.gnu.org/softw
Installing DejaGnu Installing dependencies
------------------ -----------------------
Installing DejaGnu should be easy using your local package manager. Installing dependencies should be easy using your local package manager.
Debian/Ubuntu Debian/Ubuntu
@ -25,6 +25,14 @@ sudo apt-get install dejagnu
------------- -------------
This should also install the necessary `expect` and `tcl` packages. This should also install the necessary `expect` and `tcl` packages.
Fedora/RHEL/CentOS
~~~~~~~~~~~~~~~~~~
On Fedora and RHEL/CentOS (with EPEL) you can use `yum`:
-------------
sudo yum install dejagnu tcllib
-------------
This should also install the necessary `expect` and `tcl` packages.
@ -72,7 +80,7 @@ Maintenance
Adding a completion test Adding a completion test
~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
You can add script/generate to add a test. You can run `cd test && ./generate` to add a test.
Fixing a completion test Fixing a completion test

View File

@ -1 +0,0 @@
source "lib/completions/enscript.exp"

View File

@ -1 +0,0 @@
source "lib/completions/env.exp"

View File

@ -1,12 +0,0 @@
set test "Completion via _filedir_xspec() should be installed"
set cmd "complete -p evince"
send "$cmd\r"
set expected "^$cmd\r\ncomplete -o filenames -F _filedir_xspec evince\r\n/@$"
expect {
-re $expected { pass "$test" }
-re /@ { fail "$test at prompt" }
}; # expect
source "lib/completions/evince.exp"

View File

@ -1 +0,0 @@
source "lib/completions/expand.exp"

View File

@ -1 +0,0 @@
source "lib/completions/filesnarf.exp"

View File

@ -1 +0,0 @@
source "lib/completions/find.exp"

View File

@ -1 +0,0 @@
source "lib/completions/find_member.exp"

View File

@ -1 +0,0 @@
source "lib/completions/fmt.exp"

View File

@ -1 +0,0 @@
source "lib/completions/fold.exp"

View File

@ -1 +0,0 @@
source "lib/completions/g++.exp"

View File

@ -1 +0,0 @@
source "lib/completions/g4.exp"

View File

@ -1 +0,0 @@
source "lib/completions/g77.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gcc.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gcj.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gcl.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gdb.exp"

View File

@ -1 +0,0 @@
source "lib/completions/genaliases.exp"

View File

@ -1 +0,0 @@
source "lib/completions/getent.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gkrellm.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gmplayer.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gnatmake.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gpc.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gperf.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gpg.exp"

View File

@ -1 +0,0 @@
source "lib/completions/gprof.exp"

View File

@ -1 +0,0 @@
source "lib/completions/grep.exp"

View File

@ -1 +0,0 @@
source "lib/completions/grub.exp"

View File

@ -1 +0,0 @@
source "lib/completions/head.exp"

View File

@ -1 +0,0 @@
source "lib/completions/hg.exp"

View File

@ -1 +0,0 @@
source "lib/completions/iconv.exp"

View File

@ -1 +0,0 @@
source "lib/completions/id.exp"

View File

@ -1 +0,0 @@
source "lib/completions/identify.exp"

View File

@ -1 +0,0 @@
source "lib/completions/ifdown.exp"

View File

@ -1 +0,0 @@
source "lib/completions/ifup.exp"

View File

@ -1 +0,0 @@
source "lib/completions/indent.exp"

View File

@ -1 +0,0 @@
source "lib/completions/info.exp"

View File

@ -1 +0,0 @@
source "lib/completions/inject.exp"

View File

@ -1 +0,0 @@
source "lib/completions/insmod.exp"

View File

@ -1 +0,0 @@
source "lib/completions/invoke-rc.d.exp"

View File

@ -1 +0,0 @@
source "lib/completions/irb.exp"

View File

@ -1 +0,0 @@
source "lib/completions/isql.exp"

View File

@ -1 +0,0 @@
source "lib/completions/javac.exp"

View File

@ -1 +0,0 @@
source "lib/completions/javadoc.exp"

View File

@ -1 +0,0 @@
source "lib/completions/killall.exp"

View File

@ -1 +0,0 @@
source "lib/completions/kldload.exp"

View File

@ -1 +0,0 @@
source "lib/completions/kldunload.exp"

View File

@ -1 +0,0 @@
source "lib/completions/kplayer.exp"

View File

@ -1 +0,0 @@
source "lib/completions/larch.exp"

View File

@ -1 +0,0 @@
source "lib/completions/ld.exp"

View File

@ -1 +0,0 @@
source "lib/completions/ldd.exp"

Some files were not shown because too many files have changed in this diff Show More