components/bash/Solaris/etc.bash.bash_completion
changeset 110 77641682ba6f
equal deleted inserted replaced
109:07cc6a1a08ad 110:77641682ba6f
       
     1 #
       
     2 # This file contains an example set of shell completions that can be used with
       
     3 # bash(1).  These completions allow a user to complete filenames, commands
       
     4 # name, command line options, and command line arguments using the [tab] key.
       
     5 # The completions defined here are specific to the GNU command set, as a result
       
     6 # they will provide the choice of GNU command line options in response to the
       
     7 # [tab] key.  For the completed options to match the command implementation,
       
     8 # you may have to have /usr/gnu/bin at the head of your PATH.
       
     9 #
       
    10 # These completions are not included in the default bash(1) environment.  To
       
    11 # include them in the default environment, it is recommended that this file be
       
    12 # copied to /etc/bash/bash_completion and be sourced from either a system wide
       
    13 # bashrc in /etc/bash/bashrc or individual bashrcs in ~/.bashrc via
       
    14 #	[ -f /etc/bash/bash_completion ] && . /etc/bash/bash_completion
       
    15 #
       
    16 
       
    17 #   bash_completion - programmable completion functions for bash 3.x
       
    18 #		      (backwards compatible with bash 2.05b)
       
    19 #
       
    20 #   $Id: bash_completion,v 1.872 2006/03/01 16:20:18 ianmacd Exp $
       
    21 #
       
    22 #   Copyright (C) Ian Macdonald <[email protected]>
       
    23 #
       
    24 #   This program is free software; you can redistribute it and/or modify
       
    25 #   it under the terms of the GNU General Public License as published by
       
    26 #   the Free Software Foundation; either version 2, or (at your option)
       
    27 #   any later version.
       
    28 #
       
    29 #   This program is distributed in the hope that it will be useful,
       
    30 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    31 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    32 #   GNU General Public License for more details.
       
    33 #
       
    34 #   You should have received a copy of the GNU General Public License
       
    35 #   along with this program; if not, write to the Free Software Foundation,
       
    36 #   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
       
    37 #
       
    38 #   The latest version of this software can be obtained here:
       
    39 #
       
    40 #   http://www.caliban.org/bash/index.shtml#completion
       
    41 #
       
    42 #   RELEASE: 20060301
       
    43 
       
    44 if [[ $- == *v* ]]; then
       
    45 	BASH_COMPLETION_ORIGINAL_V_VALUE="-v"
       
    46 else
       
    47 	BASH_COMPLETION_ORIGINAL_V_VALUE="+v"
       
    48 fi
       
    49 
       
    50 if [[ -n $BASH_COMPLETION_DEBUG ]]; then
       
    51 	set -v
       
    52 else
       
    53 	set +v
       
    54 fi
       
    55 
       
    56 # Alter the following to reflect the location of this file.
       
    57 #
       
    58 [ -n "$BASH_COMPLETION" ] || BASH_COMPLETION=/etc/bash/bash_completion
       
    59 [ -n "$BASH_COMPLETION_DIR" ] || BASH_COMPLETION_DIR=/etc/bash/bash_completion.d
       
    60 readonly BASH_COMPLETION BASH_COMPLETION_DIR
       
    61 
       
    62 # Set a couple of useful vars
       
    63 #
       
    64 UNAME=$( uname -s )
       
    65 # strip OS type and version under Cygwin (e.g. CYGWIN_NT-5.1 => Cygwin)
       
    66 UNAME=${UNAME/CYGWIN_*/Cygwin}
       
    67 RELEASE=$( uname -r )
       
    68 
       
    69 # features supported by bash 2.05 and higher
       
    70 if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} > 04 ]] ||
       
    71    [ ${BASH_VERSINFO[0]} -gt 2 ]; then
       
    72 	declare -r bash205=$BASH_VERSION 2>/dev/null || :
       
    73 	default="-o default"
       
    74 	dirnames="-o dirnames"
       
    75 	filenames="-o filenames"
       
    76 fi
       
    77 # features supported by bash 2.05b and higher
       
    78 if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] ||
       
    79    [ ${BASH_VERSINFO[0]} -gt 2 ]; then
       
    80 	declare -r bash205b=$BASH_VERSION 2>/dev/null || :
       
    81 	nospace="-o nospace"
       
    82 fi
       
    83 # features supported by bash 3.0 and higher
       
    84 if [ ${BASH_VERSINFO[0]} -gt 2 ]; then
       
    85 	declare -r bash3=$BASH_VERSION 2>/dev/null || :
       
    86 	bashdefault="-o bashdefault"
       
    87 	plusdirs="-o plusdirs"
       
    88 fi
       
    89 
       
    90 # Turn on extended globbing and programmable completion
       
    91 shopt -s extglob progcomp
       
    92 
       
    93 # A lot of the following one-liners were taken directly from the
       
    94 # completion examples provided with the bash 2.04 source distribution
       
    95 
       
    96 # Make directory commands see only directories
       
    97 complete -d pushd
       
    98 
       
    99 # The following section lists completions that are redefined later
       
   100 # Do NOT break these over multiple lines.
       
   101 #
       
   102 # START exclude -- do NOT remove this line
       
   103 complete -f -X '!*.?(t)bz?(2)' bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
       
   104 complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo|xpi|sxw|ott)' unzip zipinfo
       
   105 complete -f -X '*.Z' compress znew
       
   106 complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
       
   107 complete -f -X '!*.Z' uncompress
       
   108 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 display
       
   109 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
       
   110 complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview
       
   111 complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi
       
   112 complete -f -X '!*.@(dvi|DVI)?(.@(gz|bz2))' kdvi
       
   113 complete -f -X '!*.@(dvi|DVI)' dvips dviselect dvitype dvipdf advi dvipdfm dvipdfmx
       
   114 complete -f -X '!*.@(pdf|PDF)' acroread gpdf xpdf
       
   115 complete -f -X '!*.@(?(e)ps|?(E)PS|pdf|PDF)' kpdf
       
   116 complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ)|cb(r|z)|CB(R|Z)|djv?(u)|DJV?(U)||dvi|DVI|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)' evince
       
   117 complete -f -X '!*.@(?(e)ps|?(E)PS)' ps2pdf
       
   118 complete -f -X '!*.texi*' makeinfo texi2html
       
   119 complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
       
   120 complete -f -X '!*.@(mp3|MP3)' mpg123 mpg321 madplay
       
   121 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|mp3|MP3|m4v|M4V|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV|asx|ASX|mng|MNG|srt)' xine aaxine fbxine kaffeine
       
   122 complete -f -X '!*.@(avi|asf|wmv)' aviplay
       
   123 complete -f -X '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay
       
   124 complete -f -X '!*.@(mpg|mpeg|avi|mov|qt)' xanim
       
   125 complete -f -X '!*.@(ogg|OGG|m3u|flac|spx)' ogg123
       
   126 complete -f -X '!*.@(mp3|MP3|ogg|OGG|pls|m3u)' gqmpeg freeamp
       
   127 complete -f -X '!*.fig' xfig
       
   128 complete -f -X '!*.@(mid?(i)|MID?(I))' playmidi
       
   129 complete -f -X '!*.@(mid?(i)|MID?(I)|rmi|RMI|rcp|RCP|[gr]36|[GR]36|g18|G18|mod|MOD|xm|XM|it|IT|x3m|X3M)' timidity
       
   130 complete -f -X '*.@(o|so|so.!(conf)|a|rpm|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' vi vim gvim rvim view rview rgvim rgview gview
       
   131 complete -f -X '*.@(o|so|so.!(conf)|a|rpm|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' emacs
       
   132 complete -f -X '!*.@(exe|EXE|com|COM|scr|SCR|exe.so)' wine
       
   133 complete -f -X '!*.@(zip|ZIP|z|Z|gz|GZ|tgz|TGZ)' bzme
       
   134 complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera galeon curl dillo elinks amaya
       
   135 complete -f -X '!*.@(sxw|stw|sxg|sgl|doc|dot|rtf|txt|htm|html|odt|ott|odm)' oowriter
       
   136 complete -f -X '!*.@(sxi|sti|pps|ppt|pot|odp|otp)' ooimpress
       
   137 complete -f -X '!*.@(sxc|stc|xls|xlw|xlt|csv|ods|ots)' oocalc
       
   138 complete -f -X '!*.@(sxd|std|sda|sdd|odg|otg)' oodraw
       
   139 complete -f -X '!*.@(sxm|smf|mml|odf)' oomath
       
   140 complete -f -X '!*.odb' oobase
       
   141 complete -f -X '!*.rpm' rpm2cpio
       
   142 # FINISH exclude -- do not remove this line
       
   143 
       
   144 # start of section containing compspecs that can be handled within bash
       
   145 
       
   146 # user commands see only users
       
   147 complete -u su usermod userdel passwd chage write chfn groups slay w sux
       
   148 
       
   149 # group commands see only groups
       
   150 [ -n "$bash205" ] && complete -g groupmod groupdel newgrp 2>/dev/null
       
   151 
       
   152 # bg completes with stopped jobs
       
   153 complete -A stopped -P '%' bg
       
   154 
       
   155 # other job commands
       
   156 complete -j -P '%' fg jobs disown
       
   157 
       
   158 # readonly and unset complete with shell variables
       
   159 complete -v readonly unset
       
   160 
       
   161 # set completes with set options
       
   162 complete -A setopt set
       
   163 
       
   164 # shopt completes with shopt options
       
   165 complete -A shopt shopt
       
   166 
       
   167 # helptopics
       
   168 complete -A helptopic help
       
   169 
       
   170 # unalias completes with aliases
       
   171 complete -a unalias
       
   172 
       
   173 # bind completes with readline bindings (make this more intelligent)
       
   174 complete -A binding bind
       
   175 
       
   176 # type and which complete on commands
       
   177 complete -c command type which
       
   178 
       
   179 # builtin completes on builtins
       
   180 complete -b builtin
       
   181 
       
   182 # start of section containing completion functions called by other functions
       
   183 
       
   184 # This function checks whether we have a given program on the system.
       
   185 # No need for bulky functions in memory if we don't.
       
   186 #
       
   187 have()
       
   188 {
       
   189     unset -v have
       
   190     PATH=/usr/gnu/bin:$PATH:/sbin:/usr/sbin type $1 &>/dev/null &&
       
   191     have="yes"
       
   192 }
       
   193 
       
   194 # use GNU sed if we have it, since its extensions are still used in our code
       
   195 #
       
   196 [ $UNAME != Linux ] && have gsed && alias sed=gsed
       
   197 
       
   198 # This function checks whether a given readline variable
       
   199 # is `on'.
       
   200 #
       
   201 _rl_enabled() 
       
   202 {
       
   203     [[ "$( bind -v )" = *$1+([[:space:]])on* ]]
       
   204 }
       
   205 
       
   206 # This function shell-quotes the argument
       
   207 quote()
       
   208 {
       
   209 	echo \'${1//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
       
   210 }
       
   211 
       
   212 # This function quotes the argument in a way so that readline dequoting
       
   213 # results in the original argument
       
   214 quote_readline()
       
   215 {
       
   216 	local t="${1//\\/\\\\}"
       
   217 	echo \'${t//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
       
   218 }
       
   219 
       
   220 # This function shell-dequotes the argument
       
   221 dequote()
       
   222 {
       
   223 	eval echo "$1"
       
   224 }
       
   225 
       
   226 
       
   227 # Get the word to complete
       
   228 # This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases
       
   229 # where the user is completing in the middle of a word.
       
   230 # (For example, if the line is "ls foobar",
       
   231 # and the cursor is here -------->   ^
       
   232 # it will complete just "foo", not "foobar", which is what the user wants.)
       
   233 _get_cword()
       
   234 {
       
   235 	if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then
       
   236 		echo "${COMP_WORDS[COMP_CWORD]}"
       
   237 	else
       
   238 		local i
       
   239 		local cur="$COMP_LINE"
       
   240 		local index="$COMP_POINT"
       
   241 		for (( i = 0; i <= COMP_CWORD; ++i )); do
       
   242 			while [[ "${#cur}" -ge ${#COMP_WORDS[i]} ]] && [[ "${cur:0:${#COMP_WORDS[i]}}" != "${COMP_WORDS[i]}" ]]; do
       
   243 				cur="${cur:1}"
       
   244 				index="$(( index - 1 ))"
       
   245 			done
       
   246 			if [[ "$i" -lt "$COMP_CWORD" ]]; then
       
   247 				local old_size="${#cur}"
       
   248 				cur="${cur#${COMP_WORDS[i]}}"
       
   249 				local new_size="${#cur}"
       
   250 				index="$(( index - old_size + new_size ))"
       
   251 			fi
       
   252 		done
       
   253 
       
   254 		if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then
       
   255 			# We messed up! At least return the whole word so things keep working
       
   256 			echo "${COMP_WORDS[COMP_CWORD]}"
       
   257 		else
       
   258 			echo "${cur:0:$index}"
       
   259 		fi
       
   260 	fi
       
   261 }
       
   262 
       
   263 
       
   264 # This function performs file and directory completion. It's better than
       
   265 # simply using 'compgen -f', because it honours spaces in filenames.
       
   266 # If passed -d, it completes only on directories. If passed anything else,
       
   267 # it's assumed to be a file glob to complete on.
       
   268 #
       
   269 _filedir()
       
   270 {
       
   271 	local IFS=$'\t\n' xspec
       
   272 
       
   273 	_expand || return 0
       
   274 
       
   275 	local toks=( ) tmp
       
   276 	while read -r tmp; do
       
   277 		[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
       
   278 	done < <( compgen -d -- "$(quote_readline "$cur")" )
       
   279 
       
   280 	if [[ "$1" != -d ]]; then
       
   281 		xspec=${1:+"!*.$1"}
       
   282 		while read -r tmp; do
       
   283 			[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
       
   284 		done < <( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" )
       
   285 	fi
       
   286 
       
   287 	COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
       
   288 }
       
   289 
       
   290 # This function completes on signal names
       
   291 #
       
   292 _signals()
       
   293 {
       
   294 	local i
       
   295 
       
   296 	# standard signal completion is rather braindead, so we need
       
   297 	# to hack around to get what we want here, which is to
       
   298 	# complete on a dash, followed by the signal name minus
       
   299 	# the SIG prefix
       
   300 	COMPREPLY=( $( compgen -A signal SIG${cur#-} ))
       
   301 	for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
       
   302 		COMPREPLY[i]=-${COMPREPLY[i]#SIG}
       
   303 	done
       
   304 }
       
   305 
       
   306 # This function completes on configured network interfaces
       
   307 #
       
   308 _configured_interfaces()
       
   309 {
       
   310 	if [ -f /etc/debian_version ]; then
       
   311 		# Debian system
       
   312 		COMPREPLY=( $( sed -ne 's|^iface \([^ ]\+\).*$|\1|p' \
       
   313 			       /etc/network/interfaces ) )
       
   314 	elif [ -f /etc/SuSE-release ]; then
       
   315 		# SuSE system
       
   316 		COMPREPLY=( $( command ls \
       
   317 			/etc/sysconfig/network/ifcfg-* | \
       
   318 			sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
       
   319 	elif [ -f /etc/pld-release ]; then
       
   320 		# PLD Linux
       
   321 		COMPREPLY=( $( command ls -B \
       
   322 			/etc/sysconfig/interfaces | \
       
   323 			sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
       
   324 	else
       
   325 		# Assume Red Hat
       
   326 		COMPREPLY=( $( command ls \
       
   327 			/etc/sysconfig/network-scripts/ifcfg-* | \
       
   328 			sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
       
   329 	fi
       
   330 }
       
   331 
       
   332 # This function completes on all available network interfaces
       
   333 # -a: restrict to active interfaces only
       
   334 # -w: restrict to wireless interfaces only
       
   335 #
       
   336 _available_interfaces()
       
   337 {
       
   338 	local cmd
       
   339 
       
   340 	if [ "${1:-}" = -w ]; then
       
   341 		cmd="iwconfig"
       
   342 	elif [ "${1:-}" = -a ]; then
       
   343 		cmd="ifconfig"
       
   344 	else
       
   345 		cmd="ifconfig -a"
       
   346 	fi
       
   347 
       
   348 	COMPREPLY=( $( eval $cmd 2>/dev/null | \
       
   349 		sed -ne 's|^\('$cur'[^[:space:][:punct:]]\{1,\}\).*$|\1|p') )
       
   350 }
       
   351 
       
   352 # This function expands tildes in pathnames
       
   353 #
       
   354 _expand()
       
   355 {
       
   356 	# FIXME: Why was this here?
       
   357 	# [ "$cur" != "${cur%\\}" ] && cur="$cur\\"
       
   358 
       
   359 	# expand ~username type directory specifications
       
   360 	if [[ "$cur" == \~*/* ]]; then
       
   361 		eval cur=$cur
       
   362 	elif [[ "$cur" == \~* ]]; then
       
   363 		cur=${cur#\~}
       
   364 		COMPREPLY=( $( compgen -P '~' -u $cur ) )
       
   365 		return ${#COMPREPLY[@]}
       
   366 	fi
       
   367 }
       
   368 
       
   369 # This function completes on process IDs.
       
   370 # AIX and Solaris ps prefers X/Open syntax.
       
   371 [ $UNAME = SunOS -o $UNAME = AIX ] &&
       
   372 _pids()
       
   373 {
       
   374 	COMPREPLY=( $( compgen -W '$( command ps -efo pid | sed 1d )' -- $cur ))
       
   375 } ||
       
   376 _pids()
       
   377 {
       
   378 	COMPREPLY=( $( compgen -W '$( command ps axo pid | sed 1d )' -- $cur ) )
       
   379 }
       
   380 
       
   381 # This function completes on process group IDs.
       
   382 # AIX and SunOS prefer X/Open, all else should be BSD.
       
   383 [ $UNAME = SunOS -o $UNAME = AIX ] &&
       
   384 _pgids()
       
   385 {
       
   386 	COMPREPLY=( $( compgen -W '$( command ps -efo pgid | sed 1d )' -- $cur ))
       
   387 } ||
       
   388 _pgids()
       
   389 {
       
   390 	COMPREPLY=( $( compgen -W '$( command ps axo pgid | sed 1d )' -- $cur ))
       
   391 }
       
   392 
       
   393 # This function completes on user IDs
       
   394 #
       
   395 _uids()
       
   396 {
       
   397 	if type getent &>/dev/null; then
       
   398 	    COMPREPLY=( $( getent passwd | \
       
   399 			    awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) )
       
   400 	elif type perl &>/dev/null; then
       
   401 	    COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- $cur ) )
       
   402 	else
       
   403 	    # make do with /etc/passwd
       
   404 	    COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\
       
   405 			    /etc/passwd ) )
       
   406 	fi
       
   407 }
       
   408 
       
   409 # This function completes on group IDs
       
   410 #
       
   411 _gids()
       
   412 {
       
   413 	if type getent &>/dev/null; then
       
   414 	    COMPREPLY=( $( getent group | \
       
   415 			    awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) )
       
   416 	elif type perl &>/dev/null; then
       
   417 	    COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- $cur ) )
       
   418 	else
       
   419 	    # make do with /etc/group
       
   420 	    COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\
       
   421 			    /etc/group ) )
       
   422 	fi
       
   423 }
       
   424 
       
   425 # This function completes on services
       
   426 #
       
   427 _services()
       
   428 {
       
   429 	local sysvdir famdir
       
   430 	[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
       
   431 	famdir=/etc/xinetd.d
       
   432 	COMPREPLY=( $( builtin echo $sysvdir/!(*.rpmsave|*.rpmorig|*~|functions)) )
       
   433 
       
   434 	if [ -d $famdir ]; then
       
   435 		COMPREPLY=( "${COMPREPLY[@]}" $( builtin echo $famdir/!(*.rpmsave|*.rpmorig|*~)) )
       
   436 	fi
       
   437 
       
   438 	COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- $cur ) )
       
   439 }
       
   440 
       
   441 # This function complete on modules
       
   442 #
       
   443 _modules()
       
   444 {
       
   445 	local modpath
       
   446 	modpath=/lib/modules/$1
       
   447 	COMPREPLY=( $( command ls -R $modpath | \
       
   448 			sed -ne 's/^\('$cur'.*\)\.k\?o\(\|.gz\)$/\1/p') )
       
   449 }
       
   450 
       
   451 # this function complete on user:group format
       
   452 #
       
   453 _usergroup()
       
   454 {
       
   455 	local IFS=$'\n'
       
   456 	cur=${cur//\\\\ / }
       
   457 	if [[ $cur = *@(\\:|.)* ]] && [ -n "$bash205" ]; then
       
   458 		user=${cur%%*([^:.])}
       
   459 		COMPREPLY=( $(compgen -P ${user/\\\\} -g -- ${cur##*[.:]}) )
       
   460 	elif [[ $cur = *:* ]] && [ -n "$bash205" ]; then
       
   461 		COMPREPLY=( $( compgen -g -- ${cur##*[.:]} ) )
       
   462 	else
       
   463 		COMPREPLY=( $( compgen -S : -u -- $cur ) )
       
   464 	fi
       
   465 }
       
   466 
       
   467 # this function count the number of mandatory args
       
   468 #
       
   469 _count_args()
       
   470 {
       
   471 	args=1
       
   472 	for (( i=1; i < COMP_CWORD; i++ )); do
       
   473 		if [[ "${COMP_WORDS[i]}" != -* ]]; then
       
   474 			args=$(($args+1))
       
   475 		fi
       
   476 	done
       
   477 }
       
   478 
       
   479 # start of section containing completion functions for bash built-ins
       
   480 
       
   481 # bash alias completion
       
   482 #
       
   483 _alias()
       
   484 {
       
   485 	local cur
       
   486 
       
   487 	COMPREPLY=()
       
   488 	cur=${COMP_WORDS[$COMP_CWORD]}
       
   489 
       
   490 	case "$COMP_LINE" in
       
   491 	*[^=])
       
   492 		COMPREPLY=( $( compgen -A alias -S '=' -- $cur ) )
       
   493 		;;
       
   494 	*=)
       
   495 		COMPREPLY=( "$( alias ${cur%=} 2>/dev/null | \
       
   496 			     sed -e 's|^alias '$cur'\(.*\)$|\1|' )" )
       
   497 		;;
       
   498 	esac
       
   499 }
       
   500 complete -F _alias $nospace alias
       
   501 
       
   502 # bash export completion
       
   503 #
       
   504 _export()
       
   505 {
       
   506 	local cur
       
   507 
       
   508 	COMPREPLY=()
       
   509 	cur=${COMP_WORDS[$COMP_CWORD]}
       
   510 
       
   511 	case "$COMP_LINE" in
       
   512 	*=\$*)
       
   513 		COMPREPLY=( $( compgen -v -P '$' -- ${cur#*=\$} ) )
       
   514 		;;
       
   515 	*[^=])
       
   516 		COMPREPLY=( $( compgen -v -S '=' -- $cur ) )
       
   517 		;;
       
   518 	*=)
       
   519 		COMPREPLY=( "$( eval echo -n \"$`echo ${cur%=}`\" |
       
   520 			( echo -n \'
       
   521 			  sed -e 's/'\''/'\''\\\'\'''\''/g'
       
   522 			  echo -n \' ) )" )
       
   523 		;;
       
   524 	esac
       
   525 }
       
   526 complete -F _export $default $nospace export
       
   527 
       
   528 # bash shell function completion
       
   529 #
       
   530 _function()
       
   531 {
       
   532 	local cur prev
       
   533 
       
   534 	COMPREPLY=()
       
   535 	cur=`_get_cword`
       
   536 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
   537 
       
   538 	if [[ $1 == @(declare|typeset) ]]; then
       
   539 		if [ "$prev" = -f ]; then
       
   540 			COMPREPLY=( $( compgen -A function -- $cur ) )
       
   541 		elif [[ "$cur" == -* ]]; then
       
   542 			COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- \
       
   543 				       $cur ) )
       
   544 		fi
       
   545 	elif [ $COMP_CWORD -eq 1 ]; then
       
   546 		COMPREPLY=( $( compgen -A function -- $cur ) )
       
   547 	else
       
   548 		COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" )
       
   549 	fi
       
   550 }
       
   551 complete -F _function function declare typeset
       
   552 
       
   553 # bash complete completion
       
   554 #
       
   555 _complete()
       
   556 {
       
   557 	local cur prev options
       
   558 
       
   559 	COMPREPLY=()
       
   560 	cur=`_get_cword`
       
   561 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
   562 
       
   563 	case $prev in
       
   564 		-o)
       
   565 			options="default dirnames filenames"
       
   566 			[ -n "$bash205b" ] && options="$options nospace"
       
   567 			[ -n "$bash3" ] && options="$options bashdefault plusdirs"
       
   568 			COMPREPLY=( $( compgen -W "$options" -- $cur ) )
       
   569 			return 0
       
   570 			;;
       
   571 
       
   572 		-A)
       
   573 			COMPREPLY=( $( compgen -W 'alias arrayvar binding \
       
   574 				builtin command directory disabled enabled \
       
   575 				export file function group helptopic hostname \
       
   576 				job keyword running service setopt shopt \
       
   577 				signal stopped user variable' -- $cur ) )
       
   578 			return 0
       
   579 			;;
       
   580 
       
   581 		-C)
       
   582 			COMPREPLY=( $( compgen -A command -- $cur ) )
       
   583 			return 0
       
   584 			;;
       
   585 		-F)
       
   586 			COMPREPLY=( $( compgen -A function -- $cur ) )
       
   587 			return 0
       
   588 			;;
       
   589 		-@(p|r))
       
   590 			COMPREPLY=( $( complete -p | sed -e 's|.* ||' | \
       
   591 					grep "^$cur" ) )
       
   592 			return 0
       
   593 			;;
       
   594 
       
   595 	esac
       
   596 
       
   597 	if [[ "$cur" == -* ]]; then
       
   598 		# relevant options completion
       
   599 		options="-a -b -c -d -e -f -g -j -k -s -v -u -A -G -W -P -S -X -F -C"
       
   600 		[ -n "$bash205" ] && options="$options -o"
       
   601 		COMPREPLY=( $( compgen -W "$options" -- $cur ) )
       
   602 	else
       
   603 		COMPREPLY=( $( compgen -A command -- $cur ) )
       
   604 	fi
       
   605 }
       
   606 complete -F _complete complete
       
   607 
       
   608 # start of section containing completion functions for external programs
       
   609 
       
   610 # a little help for FreeBSD ports users
       
   611 [ $UNAME = FreeBSD ] && complete -W 'index search fetch fetch-list \
       
   612 	extract patch configure build install reinstall \
       
   613 	deinstall clean clean-depends kernel buildworld' make
       
   614 
       
   615 # This completes on a list of all available service scripts for the
       
   616 # 'service' command and/or the SysV init.d directory, followed by
       
   617 # that script's available commands
       
   618 #
       
   619 { have service || [ -d /etc/init.d/ ]; } &&
       
   620 _service()
       
   621 {
       
   622 	local cur sysvdir
       
   623 
       
   624 	COMPREPLY=()
       
   625 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
   626 	cur=`_get_cword`
       
   627 
       
   628 	# don't complete for things like killall, ssh and mysql if it's
       
   629 	# the standalone command, rather than the init script
       
   630 	[[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|service) ]] && return 0
       
   631 
       
   632 	# don't complete past 2nd token
       
   633 	[ $COMP_CWORD -gt 2 ] && return 0
       
   634 
       
   635 	[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
       
   636 				|| sysvdir=/etc/init.d
       
   637 
       
   638 	if [[ $COMP_CWORD -eq 1 ]] && [[ $prev == "service" ]]; then
       
   639 		_services
       
   640 	else
       
   641 		COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
       
   642 				s/^.*Usage.*{\(.*\)}.*$/\1/p" \
       
   643 				$sysvdir/${prev##*/} 2>/dev/null`' -- $cur ) )
       
   644 	fi
       
   645 
       
   646 	return 0
       
   647 } &&
       
   648 complete -F _service service
       
   649 [ -d /etc/init.d/ ] && complete -F _service $default \
       
   650 	$(for i in /etc/init.d/*; do echo ${i##*/}; done)
       
   651 
       
   652 # chown(1) completion
       
   653 #
       
   654 _chown()
       
   655 {
       
   656 	local cur
       
   657 	cur=`_get_cword`
       
   658 
       
   659 	# options completion
       
   660 	if [[ "$cur" == -* ]]; then
       
   661 		COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \
       
   662 		--dereference --no-dereference --from= --silent --quiet \
       
   663 		--reference= --recursive --verbose --help --version' -- $cur ) )
       
   664 	else
       
   665 		_count_args
       
   666 
       
   667 		case $args in
       
   668 			1)
       
   669 				_usergroup
       
   670 				;;
       
   671 			*)
       
   672 				_filedir
       
   673 				;;
       
   674 		esac
       
   675 	fi
       
   676 }
       
   677 complete -F _chown $filenames chown
       
   678 
       
   679 # chgrp(1) completion
       
   680 #
       
   681 _chgrp()
       
   682 {
       
   683 	local cur prev
       
   684 
       
   685 	COMPREPLY=()
       
   686 	cur=`_get_cword`
       
   687 	cur=${cur//\\\\/}
       
   688 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
   689 
       
   690 	# options completion
       
   691 	if [[ "$cur" == -* ]]; then
       
   692 		COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \
       
   693 		--dereference --no-dereference --silent --quiet \
       
   694 		--reference= --recursive --verbose --help --version' -- $cur ) )
       
   695 		return 0
       
   696 	fi
       
   697 
       
   698 	# first parameter on line or first since an option?
       
   699 	if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || \
       
   700 	   [[ "$prev" == -* ]] && [ -n "$bash205" ]; then
       
   701 		local IFS=$'\n'
       
   702 		COMPREPLY=( $( compgen -g $cur 2>/dev/null ) )
       
   703 	else
       
   704 		_filedir || return 0
       
   705 	fi
       
   706 
       
   707 	return 0
       
   708 }
       
   709 complete -F _chgrp $filenames chgrp
       
   710 
       
   711 # umount(8) completion. This relies on the mount point being the third
       
   712 # space-delimited field in the output of mount(8)
       
   713 #
       
   714 _umount()
       
   715 {
       
   716 	local cur
       
   717 
       
   718 	COMPREPLY=()
       
   719 	cur=`_get_cword`
       
   720 
       
   721 	OLDIFS="$IFS"
       
   722 	IFS="\n"
       
   723 	COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- $cur ) )
       
   724 	IFS="$OLDIFS"
       
   725 
       
   726 	return 0
       
   727 }
       
   728 complete -F _umount $dirnames umount
       
   729 
       
   730 # mount(8) completion. This will pull a list of possible mounts out of
       
   731 # /etc/{,v}fstab, unless the word being completed contains a ':', which
       
   732 # would indicate the specification of an NFS server. In that case, we
       
   733 # query the server for a list of all available exports and complete on
       
   734 # that instead.
       
   735 #
       
   736 _mount()
       
   737 {       local cur i sm host
       
   738 
       
   739 	COMPREPLY=()
       
   740 	cur=`_get_cword`
       
   741 	[[ "$cur" == \\ ]] && cur="/"
       
   742 
       
   743 	for i in {,/usr}/{,s}bin/showmount; do [ -x $i ] && sm=$i && break; done
       
   744 
       
   745 	if [ -n "$sm" ] && [[ "$cur" == *:* ]]; then
       
   746 		COMPREPLY=( $( $sm -e ${cur%%:*} | sed 1d | \
       
   747 			       grep ^${cur#*:} | awk '{print $1}' ) )
       
   748 	elif [[ "$cur" == //* ]]; then
       
   749 		host=${cur#//}
       
   750 		host=${host%%/*}
       
   751 		if [ -n "$host" ]; then
       
   752 			COMPREPLY=( $( compgen -W "$( echo $( smbclient -d 0 -NL $host 2>/dev/null|
       
   753 			sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' |
       
   754 			sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|//'$host'/\1|p' ) )" -- "$cur" ) )
       
   755 		fi
       
   756 	elif [ -r /etc/vfstab ]; then
       
   757 		# Solaris
       
   758 		COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \
       
   759 				/etc/vfstab | grep "^$cur" ) )
       
   760 	elif [ ! -e /etc/fstab ]; then
       
   761 		# probably Cygwin
       
   762 		COMPREPLY=( $( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \
       
   763 				 | grep "^$cur" ) )
       
   764 	else
       
   765 		# probably Linux
       
   766 		COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' \
       
   767 				/etc/fstab | grep "^$cur" ) )
       
   768 	fi
       
   769 
       
   770 	return 0
       
   771 }
       
   772 complete -F _mount $default $filenames mount
       
   773 
       
   774 # Linux rmmod(8) completion. This completes on a list of all currently
       
   775 # installed kernel modules.
       
   776 #
       
   777 have rmmod && {
       
   778 _rmmod()
       
   779 {
       
   780 	local cur
       
   781 
       
   782 	COMPREPLY=()
       
   783 	cur=`_get_cword`
       
   784 
       
   785 	COMPREPLY=( $( /sbin/lsmod | \
       
   786 		  awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' 2>/dev/null ))
       
   787 	return 0
       
   788 }
       
   789 complete -F _rmmod rmmod
       
   790 
       
   791 # Linux insmod(8), modprobe(8) and modinfo(8) completion. This completes on a
       
   792 # list of all available modules for the version of the kernel currently
       
   793 # running.
       
   794 #
       
   795 _insmod()
       
   796 {
       
   797 	local cur prev modpath
       
   798 
       
   799 	COMPREPLY=()
       
   800 	cur=`_get_cword`
       
   801 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
   802 
       
   803 	# behave like lsmod for modprobe -r
       
   804 	if [ $1 = "modprobe" ] &&
       
   805 	   [ "${COMP_WORDS[1]}" = "-r" ]; then
       
   806 		COMPREPLY=( $( /sbin/lsmod | \
       
   807 				awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' ) )
       
   808 		return 0
       
   809 	fi
       
   810 
       
   811 	# do filename completion if we're giving a path to a module
       
   812 	if [[ "$cur" == */* ]]; then
       
   813 		_filedir '@(?(k)o?(.gz))'
       
   814 		return 0
       
   815 	fi
       
   816 
       
   817 	if [ $COMP_CWORD -gt 1 ] && 
       
   818 	   [[ "${COMP_WORDS[COMP_CWORD-1]}" != -* ]]; then
       
   819 		# do module parameter completion
       
   820 		COMPREPLY=( $( /sbin/modinfo -p ${COMP_WORDS[1]} 2>/dev/null | \
       
   821 		       awk '{if ($1 ~ /^parm:/ && $2 ~ /^'$cur'/) { print $2 } \
       
   822 			else if ($1 !~ /:/ && $1 ~ /^'$cur'/) { print $1 }}' ) )
       
   823 	else
       
   824 		_modules $(uname -r)
       
   825 	fi
       
   826 
       
   827 	return 0
       
   828 }
       
   829 complete -F _insmod $filenames insmod modprobe modinfo
       
   830 }
       
   831 
       
   832 # man(1) completion
       
   833 #
       
   834 [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
       
   835   -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
       
   836   -o $UNAME = OpenBSD ] &&
       
   837 _man()
       
   838 {
       
   839 	local cur prev sect manpath UNAME
       
   840 
       
   841 	COMPREPLY=()
       
   842 	cur=`_get_cword`
       
   843 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
   844 
       
   845 	_expand || return 0
       
   846 
       
   847 	# default completion if parameter contains /
       
   848 	if [[ "$cur" == */* ]]; then
       
   849 		_filedir
       
   850 		return 0
       
   851 	fi
       
   852 
       
   853 	UNAME=$( uname -s )
       
   854 	# strip OS type and version under Cygwin
       
   855 	UNAME=${UNAME/CYGWIN_*/Cygwin}
       
   856 	if [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = FreeBSD \
       
   857 	     -o $UNAME = Cygwin ]; then
       
   858 		manpath=$( manpath 2>/dev/null || command man --path )
       
   859 	else
       
   860 		manpath=$MANPATH
       
   861 	fi
       
   862 
       
   863 	if [ -z "$manpath" ]; then
       
   864 		COMPREPLY=( $( compgen -c -- $cur ) )
       
   865 		return 0
       
   866 	fi
       
   867 
       
   868 	# determine manual section to search
       
   869 	[[ "$prev" == [0-9ln] ]] && sect=$prev || sect='*'
       
   870 
       
   871 	manpath=$manpath:
       
   872 	if [ -n "$cur" ]; then
       
   873 		manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }"
       
   874 	else
       
   875 		manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"
       
   876 	fi
       
   877 		
       
   878 	# redirect stderr for when path doesn't exist
       
   879 	COMPREPLY=( $( eval command ls "$manpath" 2>/dev/null ) )
       
   880 	# weed out directory path names and paths to man pages
       
   881 	COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
       
   882 	# strip suffix from man pages
       
   883 	COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2)} )
       
   884 	COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
       
   885 
       
   886 	[[ "$prev" != [0-9ln] ]] && _filedir '[0-9ln]'
       
   887 
       
   888 	return 0
       
   889 }
       
   890 [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
       
   891   -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
       
   892   -o $UNAME = OpenBSD ] && \
       
   893 complete -F _man $filenames man apropos whatis
       
   894 
       
   895 # renice(8) completion
       
   896 #
       
   897 _renice()
       
   898 {
       
   899 	local command cur curopt i
       
   900 
       
   901 	COMPREPLY=()
       
   902 	cur=`_get_cword`
       
   903 	command=$1
       
   904 
       
   905 	i=0
       
   906 	# walk back through command line and find last option
       
   907 	while [ $i -le $COMP_CWORD -a ${#COMPREPLY[@]} -eq 0 ]; do
       
   908 		curopt=${COMP_WORDS[COMP_CWORD-$i]}
       
   909 		case "$curopt" in
       
   910 		-u)
       
   911 			COMPREPLY=( $( compgen -u -- $cur ) )
       
   912 			;;
       
   913 		-g)
       
   914 			_pgids
       
   915 			;;
       
   916 		-p|$command)
       
   917 			_pids
       
   918 			;;
       
   919 		esac
       
   920 		i=$(( ++i ))
       
   921 	done
       
   922 }
       
   923 complete -F _renice renice
       
   924 
       
   925 # kill(1) completion
       
   926 #
       
   927 _kill()
       
   928 {
       
   929 	local cur
       
   930 
       
   931 	COMPREPLY=()
       
   932 	cur=`_get_cword`
       
   933 
       
   934 	if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
       
   935 		# return list of available signals
       
   936 		_signals
       
   937 	else
       
   938 		# return list of available PIDs
       
   939 		_pids
       
   940 	fi
       
   941 }
       
   942 complete -F _kill kill
       
   943 
       
   944 # Linux and FreeBSD killall(1) completion.
       
   945 #
       
   946 [ $UNAME = Linux -o $UNAME = FreeBSD ] &&
       
   947 _killall()
       
   948 {
       
   949 	local cur
       
   950 
       
   951 	COMPREPLY=()
       
   952 	cur=`_get_cword`
       
   953 
       
   954 	if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
       
   955 		_signals
       
   956 	else
       
   957 		COMPREPLY=( $( compgen -W '$( command ps axo command | \
       
   958 			      sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \
       
   959 			      sed -e "s/.*\///" )' -- $cur ) )
       
   960 	fi
       
   961 
       
   962 	return 0
       
   963 }
       
   964 [ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _killall killall pkill
       
   965 
       
   966 # Linux and FreeBSD pgrep(1) completion.
       
   967 #
       
   968 [ $UNAME = Linux -o $UNAME = FreeBSD ] &&
       
   969 _pgrep()
       
   970 {
       
   971 	local cur
       
   972 
       
   973 	COMPREPLY=()
       
   974 	cur=`_get_cword`
       
   975 
       
   976 	COMPREPLY=( $( compgen -W '$( command ps axo command | \
       
   977 		      sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \
       
   978 		      sed -e "s/.*\///" )' -- $cur ) )
       
   979 
       
   980 	return 0
       
   981 }
       
   982 [ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _pgrep pgrep
       
   983 # Linux pidof(8) completion.
       
   984 [ $UNAME = Linux ] && complete -F _pgrep pidof
       
   985 
       
   986 # GNU find(1) completion. This makes heavy use of ksh style extended
       
   987 # globs and contains Linux specific code for completing the parameter
       
   988 # to the -fstype option.
       
   989 #
       
   990 _find()
       
   991 {
       
   992 	local cur prev i exprfound onlyonce
       
   993 
       
   994 	COMPREPLY=()
       
   995 	cur=`_get_cword`
       
   996 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
   997 
       
   998 	case "$prev" in
       
   999 	-@(max|min)depth)
       
  1000 		COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- $cur ) )
       
  1001 		return 0
       
  1002 		;;
       
  1003 	-?(a|c)newer|-fls|-fprint?(0|f)|-?(i)?(l)name|-?(i)wholename)
       
  1004 		_filedir
       
  1005 		return 0
       
  1006 		;;
       
  1007 	-fstype)
       
  1008 		# this is highly non-portable
       
  1009 		[ -e /proc/filesystems ] &&
       
  1010 		COMPREPLY=( $( cut -d$'\t' -f 2 /proc/filesystems | \
       
  1011 				grep "^$cur" ) )
       
  1012 		return 0
       
  1013 		;;
       
  1014 	-gid)
       
  1015 		_gids
       
  1016 		return 0
       
  1017 		;;
       
  1018 	-group)
       
  1019 		if [ -n "$bash205" ]; then
       
  1020 			COMPREPLY=( $( compgen -g -- $cur 2>/dev/null) )
       
  1021 		fi
       
  1022 		return 0
       
  1023 		;;
       
  1024 	-?(x)type)
       
  1025 		COMPREPLY=( $( compgen -W 'b c d p f l s' -- $cur ) )
       
  1026 		return 0
       
  1027 		;;
       
  1028 	-uid)
       
  1029 		_uids
       
  1030 		return 0
       
  1031 		;;
       
  1032 	-user)
       
  1033 		COMPREPLY=( $( compgen -u -- $cur ) )
       
  1034 		return 0
       
  1035 		;;
       
  1036 	-exec|-ok)
       
  1037 		COMP_WORDS=(COMP_WORDS[0] $cur)
       
  1038 		COMP_CWORD=1
       
  1039 		_command
       
  1040 		return 0
       
  1041 		;;
       
  1042 	-[acm]min|-[acm]time|-?(i)?(l)name|-inum|-?(i)path|-?(i)regex| \
       
  1043 	-links|-perm|-size|-used|-printf)
       
  1044 		# do nothing, just wait for a parameter to be given
       
  1045 		return 0
       
  1046 		;;
       
  1047 	esac
       
  1048 
       
  1049 	_expand || return 0
       
  1050 
       
  1051 	# set exprfound to 1 if there is already an expression present
       
  1052 	for i in ${COMP_WORDS[@]}; do
       
  1053 		[[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break
       
  1054 	done
       
  1055 
       
  1056 	# handle case where first parameter is not a dash option
       
  1057 	if [ "$exprfound" != 1 ] && [[ "$cur" != [-\(\),\!]* ]]; then
       
  1058 		_filedir -d
       
  1059 		return 0
       
  1060 	fi
       
  1061 
       
  1062 	# complete using basic options
       
  1063 	COMPREPLY=( $( compgen -W '-daystart -depth -follow -help -maxdepth \
       
  1064 			-mindepth -mount -noleaf -version -xdev -amin -anewer \
       
  1065 			-atime -cmin -cnewer -ctime -empty -false -fstype \
       
  1066 			-gid -group -ilname -iname -inum -ipath -iregex \
       
  1067 			-wholename \
       
  1068 			-links -lname -mmin -mtime -name -newer -nouser \
       
  1069 			-nogroup -perm -regex -size -true -type -uid -used \
       
  1070 			-user -xtype -exec -fls -fprint -fprint0 -fprintf -ok \
       
  1071 			-print -print0 -printf -prune -ls' -- $cur ) )
       
  1072 
       
  1073 	# this removes any options from the list of completions that have
       
  1074 	# already been specified somewhere on the command line, as long as
       
  1075 	# these options can only be used once (in a word, "options", in
       
  1076 	# opposition to "tests" and "actions", as in the find(1) manpage).
       
  1077 	onlyonce=' -daystart -depth -follow -help -maxdepth -mindepth -mount \
       
  1078 		   -noleaf -version -xdev '
       
  1079 	COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \
       
  1080 		       (while read -d ' ' i; do
       
  1081 			    [ "$i" == "" ] ||
       
  1082 			    [ "${onlyonce/ ${i%% *} / }" == "$onlyonce" ] &&
       
  1083 			    continue
       
  1084 			    # flatten array with spaces on either side,
       
  1085 			    # otherwise we cannot grep on word boundaries of
       
  1086 			    # first and last word
       
  1087 			    COMPREPLY=" ${COMPREPLY[@]} "
       
  1088 			    # remove word from list of completions
       
  1089 			    COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
       
  1090 			done
       
  1091 			echo "${COMPREPLY[@]}")
       
  1092 		  ) )
       
  1093 	
       
  1094 	_filedir
       
  1095 	
       
  1096 	return 0
       
  1097 }
       
  1098 complete -F _find $filenames find
       
  1099 
       
  1100 # Linux iwconfig(8) completion
       
  1101 #
       
  1102 [ $UNAME = Linux ] && have iwconfig &&
       
  1103 _iwconfig()
       
  1104 {
       
  1105 	local cur prev
       
  1106 
       
  1107 	COMPREPLY=()
       
  1108 	cur=`_get_cword`
       
  1109 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  1110 	
       
  1111 	case $prev in
       
  1112 		mode)
       
  1113 			COMPREPLY=( $( compgen -W 'managed ad-hoc master \
       
  1114 				repeater secondary monitor' -- $cur ) )
       
  1115 			return 0
       
  1116 			;;
       
  1117 		essid)
       
  1118 			COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
       
  1119 			if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
       
  1120 				COMPREPLY=( "${COMPREPLY[@]}" \
       
  1121 					$( iwlist ${COMP_WORDS[1]} scan | \
       
  1122 					awk -F '"' '/ESSID/ {print $2}' | \
       
  1123 					grep "^$cur" ))
       
  1124 			fi
       
  1125 			return 0
       
  1126 			;;
       
  1127 		nwid)
       
  1128 			COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
       
  1129 			return 0
       
  1130 			;;
       
  1131 		channel)
       
  1132 			COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \
       
  1133 				awk '/^[[:space:]]*Channel/ {print $2}' | \
       
  1134 				grep "^$cur" ) )
       
  1135 			return 0
       
  1136 			;;
       
  1137 
       
  1138 		freq)
       
  1139 			COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \
       
  1140 				awk '/^[[:space:]]*Channel/ {print $4"G"}' | \
       
  1141 				grep "^$cur" ) )
       
  1142 			return 0
       
  1143 			;;
       
  1144 		ap)
       
  1145 			COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
       
  1146 			if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
       
  1147 				COMPREPLY=( "${COMPREPLY[@]}" \
       
  1148 					$( iwlist ${COMP_WORDS[1]} scan | \
       
  1149 					awk -F ': ' '/Address/ {print $2}' | \
       
  1150 					grep "^$cur" ) )
       
  1151 			fi
       
  1152 			return 0
       
  1153 			;;
       
  1154 		rate)
       
  1155 			COMPREPLY=( $( compgen -W 'auto fixed' -- $cur ) )
       
  1156 			COMPREPLY=( "${COMPREPLY[@]}" \
       
  1157 				$( iwlist ${COMP_WORDS[1]} rate | \
       
  1158 				awk '/^[[:space:]]*[0-9]/ {print $1"M"}' | \
       
  1159 				grep "^$cur" ) )
       
  1160 			return 0
       
  1161 			;;
       
  1162 		rts)
       
  1163 			COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) )
       
  1164 			return 0
       
  1165 			;;
       
  1166 		frag)
       
  1167 			COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) )
       
  1168 			return 0
       
  1169 			;;
       
  1170 		key)
       
  1171 			COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) )
       
  1172 			return 0
       
  1173 			;;
       
  1174 		enc)
       
  1175 			COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) )
       
  1176 			return 0
       
  1177 			;;
       
  1178 		power)
       
  1179 			COMPREPLY=( $( compgen -W 'period timeout off on' -- $cur ) )
       
  1180 			return 0
       
  1181 			;;
       
  1182 		txpower)
       
  1183 			COMPREPLY=( $( compgen -W 'off on auto' -- $cur ) )
       
  1184 			return 0
       
  1185 			;;
       
  1186 		retry)
       
  1187 			COMPREPLY=( $( compgen -W 'limit lifetime' -- $cur ) )
       
  1188 			return 0
       
  1189 			;;
       
  1190 	esac
       
  1191 
       
  1192 	if [ $COMP_CWORD -eq 1 ]; then
       
  1193 		if [[ "$cur" == -* ]]; then
       
  1194 			COMPREPLY=( $( compgen -W '--help --version' -- $cur ) ) 
       
  1195 		else
       
  1196 			_available_interfaces -w
       
  1197 		fi
       
  1198 	else
       
  1199 		COMPREPLY=( $( compgen -W 'essid nwid mode freq channel sens mode \
       
  1200 			ap nick rate rts frag enc key power txpower commit' -- $cur ) ) 
       
  1201 	fi
       
  1202 
       
  1203 } &&
       
  1204 complete -F _iwconfig iwconfig
       
  1205 
       
  1206 # Linux iwlist(8) completion
       
  1207 #
       
  1208 [ $UNAME = Linux ] && have iwlist &&
       
  1209 _iwlist()
       
  1210 {
       
  1211 	local cur prev
       
  1212 
       
  1213 	COMPREPLY=()
       
  1214 	cur=`_get_cword`
       
  1215 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  1216 	
       
  1217 	if [ $COMP_CWORD -eq 1 ]; then
       
  1218 		if [[ "$cur" == -* ]]; then
       
  1219 			COMPREPLY=( $( compgen -W '--help --version' -- $cur ) ) 
       
  1220 		else
       
  1221 			_available_interfaces -w
       
  1222 		fi
       
  1223 	else
       
  1224 		COMPREPLY=( $( compgen -W 'scan scanning freq frequency \
       
  1225 			channel rate bit bitrate key enc encryption power \
       
  1226 			txpower retry ap accesspoint peers event' -- $cur ) ) 
       
  1227 	fi
       
  1228 } &&
       
  1229 complete -F _iwlist iwlist
       
  1230 
       
  1231 # Linux iwspy(8) completion
       
  1232 #
       
  1233 [ $UNAME = Linux ] && have iwspy &&
       
  1234 _iwspy()
       
  1235 {
       
  1236 	local cur
       
  1237 
       
  1238 	COMPREPLY=()
       
  1239 	cur=`_get_cword`
       
  1240 
       
  1241 	if [ $COMP_CWORD -eq 1 ]; then
       
  1242 		if [[ "$cur" == -* ]]; then
       
  1243 			COMPREPLY=( $( compgen -W '--help --version' -- $cur ) ) 
       
  1244 		else
       
  1245 			_available_interfaces -w
       
  1246 		fi
       
  1247 	else
       
  1248 		COMPREPLY=( $( compgen -W 'setthr getthr off' -- $cur ) ) 
       
  1249 	fi
       
  1250 } &&
       
  1251 complete -F _iwspy iwspy
       
  1252 
       
  1253 # Linux iwpriv(8) completion
       
  1254 #
       
  1255 [ $UNAME = Linux ] && have iwpriv &&
       
  1256 _iwpriv()
       
  1257 {
       
  1258 	local cur prev
       
  1259 
       
  1260 	COMPREPLY=()
       
  1261 	cur=`_get_cword`
       
  1262 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  1263 
       
  1264 	case "$prev" in
       
  1265 		roam)
       
  1266 			COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
       
  1267 			return 0
       
  1268 			;;
       
  1269 		port)
       
  1270 			COMPREPLY=( $( compgen -W 'ad-hoc managed' -- $cur ) )
       
  1271 			return 0
       
  1272 			;;
       
  1273 	esac
       
  1274 
       
  1275 	if [ $COMP_CWORD -eq 1 ]; then
       
  1276 		if [[ "$cur" == -* ]]; then
       
  1277 			COMPREPLY=( $( compgen -W '--help --version' -- $cur ) ) 
       
  1278 		else
       
  1279 			_available_interfaces -w
       
  1280 		fi
       
  1281 	else
       
  1282 		COMPREPLY=( $( compgen -W '--all roam port' -- $cur ) ) 
       
  1283 	fi
       
  1284 } &&
       
  1285 complete -F _iwpriv iwpriv
       
  1286 
       
  1287 # RedHat & Debian GNU/Linux if{up,down} completion
       
  1288 #
       
  1289 [ $UNAME = Linux ] && { have ifup || have ifdown; } &&
       
  1290 _ifupdown()
       
  1291 {
       
  1292 	local cur
       
  1293 
       
  1294 	COMPREPLY=()
       
  1295 	cur=`_get_cword`
       
  1296 
       
  1297 	if [ $COMP_CWORD -eq 1 ]; then
       
  1298 		_configured_interfaces
       
  1299 		COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") )
       
  1300        fi
       
  1301 
       
  1302        return 0
       
  1303 } &&
       
  1304 complete -F _ifupdown ifup ifdown
       
  1305 [ $UNAME = Linux ] && have ifstatus && complete -F _ifupdown ifstatus
       
  1306 
       
  1307 # Linux ipsec(8) completion (for FreeS/WAN)
       
  1308 #
       
  1309 [ $UNAME = Linux ] && have ipsec &&
       
  1310 _ipsec()
       
  1311 {
       
  1312 	local cur
       
  1313 
       
  1314 	COMPREPLY=()
       
  1315 	cur=`_get_cword`
       
  1316 
       
  1317 	
       
  1318 	if [ $COMP_CWORD -eq 1 ]; then
       
  1319 		COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look \
       
  1320 					   manual pluto ranbits rsasigkey \
       
  1321 					   setup showdefaults showhostkey spi \
       
  1322 					   spigrp tncfg whack' -- $cur ) )
       
  1323 		return 0
       
  1324 	fi
       
  1325 
       
  1326 	case ${COMP_WORDS[1]} in
       
  1327 	auto)
       
  1328 		COMPREPLY=( $( compgen -W '--asynchronous --up --add --delete \
       
  1329 					   --replace --down --route --unroute \
       
  1330 					   --ready --status --rereadsecrets' \
       
  1331 					-- $cur ) )
       
  1332 		;;
       
  1333 	manual)
       
  1334 		COMPREPLY=( $( compgen -W '--up --down --route --unroute \
       
  1335 					   --union' -- $cur ) )
       
  1336 		;;
       
  1337 	ranbits)
       
  1338 		COMPREPLY=( $( compgen -W '--quick --continuous --bytes' \
       
  1339 					  -- $cur ) )
       
  1340 		;;
       
  1341 	setup)
       
  1342 		COMPREPLY=( $( compgen -W '--start --stop --restart' -- $cur ) )
       
  1343 		;;
       
  1344 
       
  1345 	*)
       
  1346 		;;
       
  1347 	esac
       
  1348 
       
  1349 	return 0
       
  1350 } &&
       
  1351 complete -F _ipsec ipsec
       
  1352 
       
  1353 # Postfix completion.
       
  1354 #
       
  1355 have postfix && {
       
  1356 # postfix(1)
       
  1357 #
       
  1358 _postfix()
       
  1359 {
       
  1360 	local cur prev
       
  1361 
       
  1362 	cur=`_get_cword`
       
  1363 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  1364 
       
  1365 	if [[ $cur == '-' ]]; then
       
  1366 		COMPREPLY=(-c -D -v)
       
  1367 		return 0
       
  1368 	fi
       
  1369 	if [[ $prev == '-c' ]]; then
       
  1370 		_filedir -d
       
  1371 		return 0
       
  1372 	fi
       
  1373 	if [[ $prev == '-D' ]]; then
       
  1374 		COMPREPLY=( $( compgen -W 'start' -- "`get_cword`" ) )
       
  1375 		return 0
       
  1376 	fi
       
  1377 	COMPREPLY=( $( compgen -W 'start stop reload abort flush check' -- \
       
  1378 		"`get_cword`" ) )
       
  1379 }
       
  1380 complete -F _postfix postfix
       
  1381 
       
  1382 # postalias(1) and postmap(1)
       
  1383 #
       
  1384 _postmap()
       
  1385 {
       
  1386 	local cur prev len idx
       
  1387 
       
  1388 	cur=`_get_cword`
       
  1389 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  1390 
       
  1391 	if [[ $cur == '-' ]]; then
       
  1392 		COMPREPLY=(-N -f -i -n -o -p -r -v -w -c -d -q)
       
  1393 		return 0
       
  1394 	fi
       
  1395 	if [[ $prev == '-c' ]]; then
       
  1396 		_filedir -d
       
  1397 		return 0
       
  1398 	fi
       
  1399 	if [[ $prev == -[dq] ]]; then
       
  1400 		return 0
       
  1401 	fi
       
  1402 
       
  1403 	if [[ "$cur" == *:* ]]; then
       
  1404 	       	COMPREPLY=( $( compgen -f -- ${cur#*:} ) )
       
  1405 	else
       
  1406 		len=${#cur}
       
  1407 		idx=0
       
  1408 		for pval in $( /usr/sbin/postconf -m ); do
       
  1409 			if [[ "$cur" == "${pval:0:$len}" ]]; then
       
  1410 				COMPREPLY[$idx]="$pval:"
       
  1411 				idx=$(($idx+1))
       
  1412 			fi
       
  1413 		done
       
  1414 		if [[ $idx -eq 0 ]]; then
       
  1415 			COMPREPLY=( $( compgen -f -- "$cur" ) )
       
  1416 		fi
       
  1417 	fi
       
  1418 	return 0
       
  1419 }
       
  1420 complete -F _postmap postmap postalias
       
  1421 
       
  1422 # postcat(1)
       
  1423 #
       
  1424 _postcat()
       
  1425 {
       
  1426 	local cur prev pval len idx qfile
       
  1427 
       
  1428 	cur=`_get_cword`
       
  1429 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  1430 
       
  1431 	if [[ $cur == '-' ]]; then
       
  1432 		COMPREPLY=(-c -q -v)
       
  1433 		return 0
       
  1434 	fi
       
  1435 	if [[ $prev == '-c' ]]; then
       
  1436 		_filedir -d
       
  1437 		return 0
       
  1438 	fi
       
  1439 
       
  1440 	qfile=0
       
  1441 	for idx in "${COMP_WORDS[@]}"; do
       
  1442 		[[ "$idx" = -q ]] && qfile=1 && break
       
  1443 	done
       
  1444 	if [[ $qfile == 1 ]]; then
       
  1445 		len=${#cur}
       
  1446 		idx=0
       
  1447 		for pval in $( mailq | \
       
  1448 			sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
       
  1449 			if [[ "$cur" == "${pval:0:$len}" ]]; then
       
  1450 				COMPREPLY[$idx]=$pval
       
  1451 				idx=$(($idx+1))
       
  1452 			fi
       
  1453 		done
       
  1454 		return 0
       
  1455 	else
       
  1456 		_filedir
       
  1457 		return 0
       
  1458 	fi
       
  1459 }
       
  1460 complete -F _postcat postcat
       
  1461 
       
  1462 # postconf(1)
       
  1463 #
       
  1464 _postconf()
       
  1465 {
       
  1466 	local cur prev pval len idx eqext
       
  1467 
       
  1468 	cur=`_get_cword`
       
  1469 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  1470 	if [[ $cur == '-' ]]; then
       
  1471 		COMPREPLY=(-c -d -e -h -m -l -n -v)
       
  1472 		return 0
       
  1473 	fi
       
  1474 	if [[ $prev == '-c' ]]; then
       
  1475 		_filedir -d
       
  1476 		return 0
       
  1477 	fi
       
  1478 	if [[ $prev == '-e' ]]; then
       
  1479 		cur=${cur#[\"\']}
       
  1480 		eqext='='
       
  1481 	fi
       
  1482 	len=${#cur}
       
  1483 	idx=0
       
  1484 	for pval in $( /usr/sbin/postconf | cut -d ' ' -f 1 ); do
       
  1485 		if [[ "$cur" == "${pval:0:$len}" ]]; then
       
  1486 			COMPREPLY[$idx]="$pval$eqext"
       
  1487 			idx=$(($idx+1))
       
  1488 		fi
       
  1489 	done
       
  1490 	return 0
       
  1491 }
       
  1492 complete -F _postconf postconf
       
  1493 
       
  1494 # postsuper(1)
       
  1495 #
       
  1496 _postsuper()
       
  1497 {
       
  1498 	local cur prev pval len idx
       
  1499 
       
  1500 	cur=`_get_cword`
       
  1501 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  1502 
       
  1503 	if [[ $cur == '-' ]]; then
       
  1504 		COMPREPLY=(-c -d -h -H -p -r -s -v)
       
  1505 		return 0
       
  1506 	fi
       
  1507 	case $prev in
       
  1508 	-[dr])
       
  1509 		len=${#cur}
       
  1510 		idx=0
       
  1511 		for pval in $( echo ALL; mailq | \
       
  1512 			sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
       
  1513 			if [[ "$cur" == "${pval:0:$len}" ]]; then
       
  1514 				COMPREPLY[$idx]=$pval
       
  1515 				idx=$(($idx+1))
       
  1516 			fi
       
  1517 		done
       
  1518 		return 0
       
  1519 		;;
       
  1520 	-h)
       
  1521 		len=${#cur}
       
  1522 		idx=0
       
  1523 		for pval in $( echo ALL; mailq | \
       
  1524 			sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//; /!$/d' ); do
       
  1525 			if [[ "$cur" == "${pval:0:$len}" ]]; then
       
  1526 				COMPREPLY[$idx]=$pval
       
  1527 				idx=$(($idx+1))
       
  1528 			fi
       
  1529 		done
       
  1530 		return 0
       
  1531 		;;
       
  1532 	-H)
       
  1533 		len=${#cur}
       
  1534 		idx=0
       
  1535 		for pval in $( echo ALL; mailq | \
       
  1536 			sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do
       
  1537 			if [[ "$cur" == "${pval:0:$len}" ]]; then
       
  1538 				COMPREPLY[$idx]=$pval
       
  1539 				idx=$(($idx+1))
       
  1540 			fi
       
  1541 		done
       
  1542 		return 0
       
  1543 		;;
       
  1544 	esac
       
  1545 	COMPREPLY=( $( compgen -W 'hold incoming active deferred' -- $cur ) )
       
  1546 	return 0
       
  1547 }
       
  1548 complete -F _postsuper postsuper
       
  1549 }
       
  1550 
       
  1551 # cvs(1) completion
       
  1552 #
       
  1553 have cvs && {
       
  1554 set_prefix()
       
  1555 {
       
  1556 	[ -z ${prefix:-} ] || prefix=${cur%/*}/
       
  1557 	[ -r ${prefix:-}CVS/Entries ] || prefix=""
       
  1558 }
       
  1559 
       
  1560 get_entries()
       
  1561 {
       
  1562 	local IFS=$'\n'
       
  1563 	[ -r ${prefix:-}CVS/Entries ] && \
       
  1564 	entries=$(cut -d/ -f2 -s ${prefix:-}CVS/Entries)
       
  1565 }
       
  1566 
       
  1567 get_modules()
       
  1568 {
       
  1569 	if [ -n "$prefix" ]; then 
       
  1570 		COMPREPLY=( $( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ) )
       
  1571 	else
       
  1572 		COMPREPLY=( $( command ls -d ${cvsroot}/!(CVSROOT) ) )
       
  1573 	fi
       
  1574 }
       
  1575 
       
  1576 _cvs()
       
  1577 {
       
  1578 	local cur count mode i cvsroot cvsroots pwd
       
  1579 	local -a flags miss files entries changed newremoved
       
  1580 
       
  1581 	COMPREPLY=()
       
  1582 	cur=`_get_cword`
       
  1583 
       
  1584 	count=0
       
  1585 	for i in "${COMP_WORDS[@]}"; do
       
  1586 		[ $count -eq $COMP_CWORD ] && break
       
  1587 		# Last parameter was the CVSROOT, now go back to mode selection
       
  1588 		if [ "${COMP_WORDS[((count))]}" == "$cvsroot" -a "$mode" == "cvsroot" ]; then
       
  1589 			mode=""
       
  1590 		fi
       
  1591 		if [ -z "$mode" ]; then
       
  1592 			case $i in
       
  1593 			-d)
       
  1594 				mode=cvsroot
       
  1595 				cvsroot=${COMP_WORDS[((count+1))]}
       
  1596 				;;
       
  1597 			@(ad?(d)|new))
       
  1598 				mode=add
       
  1599 				;;
       
  1600 			@(adm?(in)|rcs))
       
  1601 				mode=admin
       
  1602 				;;
       
  1603 			ann?(notate))
       
  1604 				mode=annotate
       
  1605 				;;
       
  1606 			@(checkout|co|get))
       
  1607 				mode=checkout
       
  1608 				;;
       
  1609 			@(com?(mit)|ci))
       
  1610 				mode=commit
       
  1611 				;;
       
  1612 			di?(f?(f)))
       
  1613 				mode=diff
       
  1614 				;;
       
  1615 			ex?(p?(ort)))
       
  1616 				mode=export
       
  1617 				;;
       
  1618 			?(un)edit)
       
  1619 				mode=$i
       
  1620 				;;
       
  1621 			hi?(s?(tory)))
       
  1622 				mode=history
       
  1623 				;;
       
  1624 			im?(p?(ort)))
       
  1625 				mode=import
       
  1626 				;;
       
  1627 			re?(l?(ease)))
       
  1628 				mode=release
       
  1629 				;;
       
  1630 			?(r)log)
       
  1631 				mode=log
       
  1632 				;;
       
  1633 			@(rdiff|patch))
       
  1634 				mode=rdiff
       
  1635 				;;
       
  1636 			@(remove|rm|delete))
       
  1637 				mode=remove
       
  1638 				;;
       
  1639 			@(rtag|rfreeze))
       
  1640 				mode=rtag
       
  1641 				;;
       
  1642 			st?(at?(us)))
       
  1643 				mode=status
       
  1644 				;;
       
  1645 			@(tag|freeze))
       
  1646 				mode=tag
       
  1647 				;;
       
  1648 			up?(d?(ate)))
       
  1649 				mode=update
       
  1650 				;;
       
  1651 			*)
       
  1652 				;;
       
  1653 			esac
       
  1654 		elif [[ "$i" = -* ]]; then
       
  1655 			flags=( "${flags[@]}" $i )
       
  1656 		fi
       
  1657 		count=$((++count))
       
  1658 	done
       
  1659 
       
  1660 	case "$mode" in
       
  1661 	add)
       
  1662 		if [[ "$cur" != -* ]]; then
       
  1663 			set_prefix
       
  1664 			if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
       
  1665 				get_entries
       
  1666 				[ -z "$cur" ] && \
       
  1667 				files=$( command ls -Ad !(CVS) ) || \
       
  1668 				files=$( command ls -d ${cur}* 2>/dev/null )
       
  1669 				for i in "${entries[@]}"; do
       
  1670 					files=( ${files[@]/#$i//} )
       
  1671 				done
       
  1672 				COMPREPLY=( $( compgen -W '${files[@]}' -- \
       
  1673 					       $cur ) )
       
  1674 			fi
       
  1675 		else
       
  1676 			COMPREPLY=( $( compgen -W '-k -m' -- $cur ) )
       
  1677 		fi
       
  1678 		;;
       
  1679 	admin)
       
  1680 		if [[ "$cur" = -* ]]; then
       
  1681 			COMPREPLY=( $( compgen -W '-i -a -A -e -b -c -k -l -u \
       
  1682 						   -L -U -m -M -n -N -o -q -I \
       
  1683 						   -s -t -t- -T -V -x -z' -- \
       
  1684 					$cur ) )
       
  1685 		fi
       
  1686 		;;
       
  1687 	annotate)
       
  1688 		if [[ "$cur" = -* ]]; then
       
  1689 			COMPREPLY=( $( compgen -W '-D -F -f -l -R -r' -- $cur ) )
       
  1690 		else
       
  1691 			get_entries
       
  1692 			COMPREPLY=( $( compgen -W '${entries[@]}' -- $cur ) )
       
  1693 		fi
       
  1694 		;;
       
  1695 	checkout)
       
  1696 		if [[ "$cur" != -* ]]; then
       
  1697 			[ -z "$cvsroot" ] && cvsroot=$CVSROOT
       
  1698 			COMPREPLY=( $( cvs -d "$cvsroot" co -c 2> /dev/null | \
       
  1699 					awk '{print $1}' ) )
       
  1700 			COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
       
  1701 		else
       
  1702 			COMPREPLY=( $( compgen -W '-A -N -P -R -c -f -l -n -p \
       
  1703 						  -s -r -D -d -k -j' -- $cur ) )
       
  1704 		fi
       
  1705 		;;
       
  1706 	commit)
       
  1707 		set_prefix
       
  1708 
       
  1709 		if [[ "$cur" != -* ]] && [ -r ${prefix:-}CVS/Entries ]; then
       
  1710 			# if $COMP_CVS_REMOTE is not null, 'cvs commit' will
       
  1711 			# complete on remotely checked-out files (requires
       
  1712 			# passwordless access to the remote repository
       
  1713 			if [ -n "${COMP_CVS_REMOTE:-}" ]; then
       
  1714 				# this is the least computationally intensive
       
  1715 				# way found so far, but other changes
       
  1716 				# (something other than changed/removed/new)
       
  1717 				# may be missing
       
  1718 				changed=( $( cvs -q diff --brief 2>&1 | \
       
  1719 				sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ) )
       
  1720 				newremoved=( $( cvs -q diff --brief 2>&1 | \
       
  1721 				sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ) )
       
  1722 				COMPREPLY=( $( compgen -W '${changed[@]:-} \
       
  1723 						   ${newremoved[@]:-}' -- $cur ) )
       
  1724 			else
       
  1725 				_filedir
       
  1726 			fi
       
  1727 		else
       
  1728 			COMPREPLY=( $( compgen -W '-n -R -l -f -F -m -r' -- \
       
  1729 				       $cur ) )
       
  1730 		fi
       
  1731 		;;
       
  1732 	cvsroot)
       
  1733 		if [ -r ~/.cvspass ]; then
       
  1734 			# Ugly escaping because of bash treating ':' specially
       
  1735 			cvsroots=$( sed 's/^[^ ]* //; s/:/\\:/g' ~/.cvspass )
       
  1736 			COMPREPLY=( $( compgen -W '$cvsroots' -- $cur ) )
       
  1737 		fi
       
  1738 		;;
       
  1739 	export)
       
  1740 		if [[ "$cur" != -* ]]; then
       
  1741 			[ -z "$cvsroot" ] && cvsroot=$CVSROOT
       
  1742 			COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) )
       
  1743 			COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
       
  1744 		else
       
  1745 			COMPREPLY=( $( compgen -W '-N -f -l -R -n \
       
  1746 						  -r -D -d -k' -- $cur ) )
       
  1747 		fi
       
  1748 		;;
       
  1749 	diff)
       
  1750 		if [[ "$cur" == -* ]]; then
       
  1751 			_longopt diff
       
  1752 		else
       
  1753 			get_entries
       
  1754 			COMPREPLY=( $( compgen -W '${entries[@]:-}' -- $cur ) )
       
  1755 		fi
       
  1756 		;;
       
  1757 	remove)
       
  1758 		if [[ "$cur" != -* ]]; then
       
  1759 			set_prefix
       
  1760 			if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
       
  1761 				get_entries
       
  1762 				# find out what files are missing
       
  1763 				for i in "${entries[@]}"; do
       
  1764 					[ ! -r "$i" ] && miss=( "${miss[@]}" $i )
       
  1765 				done
       
  1766 				COMPREPLY=( $(compgen -W '${miss[@]:-}' -- $cur) )
       
  1767 			fi
       
  1768 		else
       
  1769 			COMPREPLY=( $( compgen -W '-f -l -R' -- $cur ) )
       
  1770 		fi
       
  1771 		;;
       
  1772 	import)
       
  1773 		if [[ "$cur" != -* ]]; then
       
  1774 			# starts with same algorithm as checkout
       
  1775 			[ -z "$cvsroot" ] && cvsroot=$CVSROOT
       
  1776 			prefix=${cur%/*}
       
  1777 			if [ -r ${cvsroot}/${prefix} ]; then
       
  1778 				get_modules
       
  1779 				COMPREPLY=( ${COMPREPLY[@]#$cvsroot} )
       
  1780 				COMPREPLY=( ${COMPREPLY[@]#\/} )
       
  1781 			fi
       
  1782 			pwd=$( pwd )
       
  1783 			pwd=${pwd##*/}
       
  1784 			COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' -- \
       
  1785 				       $cur ) )
       
  1786 		else
       
  1787 			COMPREPLY=( $( compgen -W '-d -k -I -b -m -W' -- $cur ))
       
  1788 		fi
       
  1789 		;;
       
  1790 	update)
       
  1791 		if [[ "$cur" = -* ]]; then
       
  1792 			COMPREPLY=( $( compgen -W '-A -P -C -d -f -l -R -p \
       
  1793 						   -k -r -D -j -I -W' -- \
       
  1794 						   $cur ) )
       
  1795 		fi
       
  1796 		;;
       
  1797 	"")
       
  1798 		COMPREPLY=( $( compgen -W 'add admin annotate checkout ci co \
       
  1799 					   commit diff delete edit export \
       
  1800 					   freeze get history import log new \
       
  1801 					   patch rcs rdiff release remove \
       
  1802 					   rfreeze rlog rm rtag stat status \
       
  1803 					   tag unedit up update -H -Q -q -b \
       
  1804 					   -d -e -f -l -n -t -r -v -w -x -z \
       
  1805 					   --help --version' -- $cur ) )
       
  1806 		;;
       
  1807 	*)
       
  1808 		;;
       
  1809 	esac
       
  1810 	
       
  1811 	return 0
       
  1812 }
       
  1813 complete -F _cvs $default cvs
       
  1814 }
       
  1815 
       
  1816 have rpm && {
       
  1817 # helper functions for rpm completion
       
  1818 #
       
  1819 _rpm_installed_packages()
       
  1820 {
       
  1821 	local ver nodig nosig
       
  1822 
       
  1823 	if [ -r /var/log/rpmpkgs -a \
       
  1824 		/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]; then
       
  1825 		# using RHL 7.2 or later - this is quicker than querying the DB
       
  1826 		COMPREPLY=( $( sed -ne \
       
  1827 		's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+.*\.rpm$|\1|p' \
       
  1828 				/var/log/rpmpkgs ) )
       
  1829 	else
       
  1830 		nodig=""
       
  1831 		nosig=""
       
  1832 		ver=$(rpm --version)
       
  1833 		ver=${ver##* }
       
  1834 	  
       
  1835 		if [[ "$ver" > "4.0.4" ]]; then
       
  1836 			nodig="--nodigest"
       
  1837 		fi
       
  1838 		if [[ "$ver" > "4.0.99" ]]; then
       
  1839 			nosig="--nosignature"
       
  1840 		fi
       
  1841 
       
  1842 		COMPREPLY=( $( rpm -qa $nodig $nosig | sed -ne \
       
  1843 		's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+$|\1|p' ) )
       
  1844 	fi
       
  1845 }
       
  1846 
       
  1847 _rpm_groups()
       
  1848 {
       
  1849 	local IFS=$'\t'
       
  1850 	# remove trailing backslash, or grep will complain
       
  1851 	cur=${cur%"\\"}
       
  1852 	COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat '%{group}\n' | \
       
  1853 		       grep "^$cur" ) )
       
  1854 	# backslash escape spaces and translate newlines to tabs
       
  1855 	COMPREPLY=( $( echo "${COMPREPLY[@]}" | sed 's/ /\\ /g' | tr '\n' '\t' ) )
       
  1856 }
       
  1857 
       
  1858 # rpm(8) completion
       
  1859 # 
       
  1860 _rpm()
       
  1861 {
       
  1862 	local cur prev ver nodig nosig
       
  1863 
       
  1864 	COMPREPLY=()
       
  1865 	cur=`_get_cword`
       
  1866 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  1867 	nodig=""
       
  1868 	nosig=""
       
  1869 	ver=$(rpm --version); ver=${ver##* }
       
  1870   
       
  1871 	if [[ "$ver" > "4.0.4" ]]; then
       
  1872 		nodig="--nodigest"
       
  1873 	fi
       
  1874 	if [[ "$ver" > "4.0.99" ]]; then
       
  1875 		nosig="--nosignature"
       
  1876 	fi
       
  1877 
       
  1878 	if [ $COMP_CWORD -eq 1 ]; then
       
  1879 		# first parameter on line
       
  1880 		case "$cur" in
       
  1881 		-b*)
       
  1882 			COMPREPLY=( $( compgen -W '-ba -bb -bc -bi -bl -bp -bs'\
       
  1883 				       -- $cur ) )
       
  1884 			;;
       
  1885 		-t*)
       
  1886 			COMPREPLY=( $( compgen -W '-ta -tb -tc -ti -tl -tp -ts'\
       
  1887 				       -- $cur ) )
       
  1888 			;;
       
  1889 		--*)
       
  1890 			COMPREPLY=( $( compgen -W '--help --version --initdb \
       
  1891 			--checksig --recompile --rebuild --resign --addsign \
       
  1892 			--rebuilddb --showrc --setperms --setugids --tarbuild \
       
  1893 			--eval --install --upgrade --query --freshen --erase \
       
  1894 			--verify --querytags --rmsource --rmspec --clean \
       
  1895 			--import' -- $cur ) )
       
  1896 			;;
       
  1897 		*)
       
  1898 			COMPREPLY=( $( compgen -W '-b -e -F -i -q -t -U -V' \
       
  1899 				       -- $cur ) )
       
  1900 			;;
       
  1901 		esac
       
  1902 
       
  1903 	return 0
       
  1904 	fi
       
  1905 
       
  1906 	case "$prev" in
       
  1907 	--@(@(db|exclude)path|prefix|relocate|root))
       
  1908 		_filedir -d
       
  1909 		return 0
       
  1910 		;;
       
  1911 	--eval)
       
  1912 		# get a list of macros
       
  1913 		COMPREPLY=( $( sed -ne 's|^\(%'${cur#\%}'[^ '$'\t'']*\).*$|\1|p' \
       
  1914 			       /usr/lib/rpm/macros ) )
       
  1915 		return 0
       
  1916 		;;
       
  1917 	--pipe)
       
  1918 		COMPREPLY=( $( compgen -c -- $cur ) )
       
  1919 		return 0
       
  1920 		;;
       
  1921 	--rcfile)
       
  1922 		_filedir
       
  1923 		return 0
       
  1924 		;;
       
  1925 	--specfile)
       
  1926 		# complete on .spec files
       
  1927 		_filedir spec
       
  1928 		return 0
       
  1929 		;;
       
  1930 	--whatprovides)
       
  1931 		if [[ "$cur" == */* ]]; then
       
  1932 			_filedir
       
  1933 		else
       
  1934 		# complete on capabilities
       
  1935 			COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat \
       
  1936 					'%{providename}\n' | grep "^$cur" ) )
       
  1937 		fi
       
  1938 		return 0
       
  1939 		;;
       
  1940 	--whatrequires)
       
  1941 		# complete on capabilities
       
  1942 		COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat \
       
  1943 				'%{requirename}\n' | grep "^$cur" ) )
       
  1944 		return 0
       
  1945 		;;
       
  1946 	esac
       
  1947 
       
  1948 	case "${COMP_WORDS[1]}" in
       
  1949 	-@([iFU]*|-install|-freshen|-upgrade))
       
  1950 		if [[ "$cur" == -* ]]; then
       
  1951 			COMPREPLY=( $( compgen -W '--percent --force --test \
       
  1952 			--replacepkgs --replacefiles --root --excludedocs \
       
  1953 			--includedocs --noscripts --rcfile --ignorearch \
       
  1954 			--dbpath --prefix --ignoreos --nodeps --allfiles \
       
  1955 			--ftpproxy --ftpport --justdb --httpproxy --httpport \
       
  1956 			--noorder --relocate --badreloc --notriggers \
       
  1957 			--excludepath --ignoresize --oldpackage --define \
       
  1958 			--eval --pipe --queryformat --repackage --nosuggests \
       
  1959 			--nodigest --nosignature' -- $cur ) )
       
  1960 		else
       
  1961 			_filedir 'rpm'
       
  1962 		fi
       
  1963 		;;
       
  1964 	-@(e|-erase))
       
  1965 		if [[ "$cur" == -* ]]; then
       
  1966 			COMPREPLY=( $( compgen -W '--allmatches --noscripts \
       
  1967 			--notriggers --nodeps --test --repackage' -- $cur ) )
       
  1968 		else
       
  1969 			_rpm_installed_packages
       
  1970 		fi
       
  1971 		;;
       
  1972 	-@(q*|-query))
       
  1973 		# check whether we're doing file completion
       
  1974 		if [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
       
  1975 		    if [[ "$cur" == -* ]]; then
       
  1976 			COMPREPLY=( $( compgen -W '--scripts --root \
       
  1977 				--rcfile --requires --ftpport --ftpproxy \
       
  1978 				--httpproxy --httpport --provides --triggers \
       
  1979 				--dump --changelog --dbpath \
       
  1980 				--last --filesbypkg \
       
  1981 				--info --list --state \
       
  1982 				--docfiles --configfiles --queryformat \
       
  1983 				--conflicts --obsoletes \
       
  1984 				--nodigest --nosignature \
       
  1985 				--triggerscripts' -- $cur ) )
       
  1986 		    else
       
  1987 			_filedir
       
  1988 		    fi
       
  1989 		elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
       
  1990 			_rpm_groups
       
  1991 		elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
       
  1992 			# uninstalled package completion
       
  1993 			if [[ "$cur" == -* ]]; then
       
  1994 				COMPREPLY=( $( compgen -W '--scripts --root \
       
  1995 				--rcfile --whatprovides --whatrequires \
       
  1996 				--requires --triggeredby --ftpport --ftpproxy \
       
  1997 				--httpproxy --httpport --provides --triggers \
       
  1998 				--dump --changelog --dbpath --filesbypkg \
       
  1999 				--define --eval --pipe --showrc --info --list \
       
  2000 				--state --docfiles --configfiles --queryformat\
       
  2001 				--conflicts --obsoletes --nodigest \
       
  2002 				--nosignature' -- $cur ) )
       
  2003 			else
       
  2004 				_filedir 'rpm'
       
  2005 			fi
       
  2006 		else
       
  2007 			# installed package completion
       
  2008 			if [[ "$cur" == -* ]]; then
       
  2009 				COMPREPLY=( $( compgen -W '--scripts --root \
       
  2010 				--rcfile --whatprovides --whatrequires \
       
  2011 				--requires --triggeredby --ftpport --ftpproxy \
       
  2012 				--httpproxy --httpport --provides --triggers \
       
  2013 				--dump --changelog --dbpath --specfile \
       
  2014 				--querybynumber --last --filesbypkg --define \
       
  2015 				--eval --pipe --showrc --info --list --state \
       
  2016 				--docfiles --configfiles --queryformat \
       
  2017 				--conflicts --obsoletes --pkgid --hdrid \
       
  2018 				--fileid --tid --nodigest --nosignature \
       
  2019 				--triggerscripts' -- $cur ) )
       
  2020 			elif [ "${COMP_LINE#* -*([^ -])a}" == "$COMP_LINE" ]; then
       
  2021 				_rpm_installed_packages
       
  2022 			fi
       
  2023 		fi
       
  2024 		;;
       
  2025 	-@(K*|-checksig))
       
  2026 		if [[ "$cur" == -* ]]; then
       
  2027 			COMPREPLY=( $( compgen -W '--nopgp --nogpg --nomd5 \
       
  2028 					--nodigest --nosignature' -- $cur ) )
       
  2029 		else
       
  2030 			_filedir 'rpm'
       
  2031 		fi
       
  2032 		;;
       
  2033 	-@([Vy]*|-verify))
       
  2034 		if [[ "$cur" == -* ]]; then
       
  2035 			COMPREPLY=( $( compgen -W '--root --rcfile --dbpath \
       
  2036 			--nodeps --nogroup --nolinkto --nomode --nomtime \
       
  2037 			--nordev --nouser --nofiles --noscripts --nomd5 \
       
  2038 			--querytags --specfile --whatrequires --whatprovides \
       
  2039 			--nodigest --nosignature' -- $cur ) )
       
  2040 		# check whether we're doing file completion
       
  2041 		elif [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
       
  2042 			_filedir
       
  2043 		elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
       
  2044 			_rpm_groups
       
  2045 		elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
       
  2046 			_filedir 'rpm'
       
  2047 		else
       
  2048 			_rpm_installed_packages
       
  2049 		fi
       
  2050 		;;
       
  2051 	-[bt]*)
       
  2052 		if [[ "$cur" == -* ]]; then
       
  2053 			COMPREPLY=( $( compgen -W '--short-circuit --timecheck \
       
  2054 			--clean --rmsource --rmspec --test --sign --buildroot \
       
  2055 			--target -- buildarch --buildos --nobuild --nodeps \
       
  2056 			--nodirtokens' -- $cur ) )
       
  2057 		elif [[ ${COMP_WORDS[1]} == -b* ]]; then
       
  2058 			_filedir 'spec'
       
  2059 		else
       
  2060 			_filedir '@(tgz|tar.@(gz|bz2))'
       
  2061 		fi
       
  2062 		;;
       
  2063 	--re@(build|compile))
       
  2064 		if [[ "$cur" == -* ]]; then
       
  2065 			COMPREPLY=( $( compgen -W '--nodeps --rmsource \
       
  2066 			  --rmspec --sign --nodirtokens --target' -- $cur ) )
       
  2067 		else
       
  2068 			_filedir '?(no)src.rpm'
       
  2069 		fi
       
  2070 		;;
       
  2071 	--tarbuild)
       
  2072 		_filedir '@(tgz|tar.@(gz|bz2))'
       
  2073 		;;
       
  2074 	--@(re|add)sign)
       
  2075 		_filedir 'rpm'
       
  2076 		;;
       
  2077 	--set@(perms|gids))
       
  2078 		_rpm_installed_packages
       
  2079 		;;
       
  2080 	--@(clean|rms@(ource|pec)))
       
  2081 		if [[ "$cur" == -* ]]; then
       
  2082 			COMPREPLY=( $( compgen -W '--clean --rmsource \
       
  2083 					--rmspec' -- $cur ) )
       
  2084 		else
       
  2085 			_filedir 'spec'
       
  2086 		fi
       
  2087 		;;
       
  2088 	--@(import|dbpath|root))
       
  2089 		if [[ "$cur" == -* ]]; then
       
  2090 			COMPREPLY=( $( compgen -W '--import --dbpath --root' \
       
  2091 					-- $cur ) )
       
  2092 		else
       
  2093 			_filedir
       
  2094 		fi
       
  2095 		;;
       
  2096 	esac
       
  2097 
       
  2098 	return 0
       
  2099 }
       
  2100 complete -F _rpm $filenames rpm rpmbuild
       
  2101 }
       
  2102 
       
  2103 # Debian apt-get(8) completion.
       
  2104 #
       
  2105 have apt-get &&
       
  2106 _apt_get()
       
  2107 {
       
  2108 	local cur prev special i
       
  2109 
       
  2110 	COMPREPLY=()
       
  2111 	cur=`_get_cword`
       
  2112 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  2113 
       
  2114 	for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
       
  2115 		if [[ ${COMP_WORDS[i]} == @(install|remove|purge|source|build-dep) ]]; then
       
  2116 			special=${COMP_WORDS[i]}
       
  2117 		fi
       
  2118 	done
       
  2119 
       
  2120 	if [ -n "$special" ]; then
       
  2121 		case $special in
       
  2122 		remove|purge)
       
  2123 			if [ -f /etc/debian_version ]; then
       
  2124 				# Debian system
       
  2125 				COMPREPLY=( $( _comp_dpkg_installed_packages \
       
  2126 						$cur ) )
       
  2127 			else
       
  2128 				# assume RPM based
       
  2129 				_rpm_installed_packages
       
  2130 			fi
       
  2131 			return 0
       
  2132 			;;
       
  2133 		*)
       
  2134 			COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
       
  2135 			return 0
       
  2136 			;;
       
  2137 
       
  2138 		esac
       
  2139 	fi
       
  2140 
       
  2141 	case "$prev" in
       
  2142 	    -@(c|-config-file))
       
  2143  		     _filedir
       
  2144 		     return 0
       
  2145 		     ;;
       
  2146 
       
  2147 	    -@(t|-target-release|-default-release))
       
  2148 		     COMPREPLY=( $( apt-cache policy | \
       
  2149 				    grep "release.o=Debian,a=$cur" | \
       
  2150 				    sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) )
       
  2151 		     return 0
       
  2152 		     ;;
       
  2153  
       
  2154 	esac
       
  2155 
       
  2156 	if [[ "$cur" == -* ]]; then
       
  2157 
       
  2158 		COMPREPLY=( $( compgen -W '-d -f -h -v -m -q -s -y \
       
  2159 				-u -t -b -c -o --download-only --fix-broken \
       
  2160 				--help --version --ignore-missing \
       
  2161 				--fix-missing --no-download --quiet --simulate \
       
  2162 				--just-print --dry-run --recon --no-act --yes \
       
  2163 				--assume-yes --show-upgraded --only-source \
       
  2164 				--compile --build --ignore-hold \
       
  2165 				--target-release --no-upgrade --force-yes \
       
  2166 				--print-uris --purge --reinstall \
       
  2167 				--list-cleanup --default-release \
       
  2168 				--trivial-only --no-remove --diff-only \
       
  2169 				--tar-only --config-file --option --auto-remove' -- $cur ) )
       
  2170 	else
       
  2171 
       
  2172 		COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \
       
  2173 				dist-upgrade install remove purge source \
       
  2174 				build-dep check clean autoclean autoremove' \
       
  2175 				-- $cur ) )
       
  2176 
       
  2177 	fi
       
  2178 
       
  2179 
       
  2180 	return 0
       
  2181 } &&
       
  2182 complete -F _apt_get $filenames apt-get
       
  2183 
       
  2184 # Debian apt-cache(8) completion.
       
  2185 #
       
  2186 have apt-cache &&
       
  2187 _apt_cache()
       
  2188 {
       
  2189 	local cur prev special i
       
  2190 
       
  2191 	COMPREPLY=()
       
  2192 	cur=`_get_cword`
       
  2193 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  2194 
       
  2195 	
       
  2196 	if [ "$cur" != show ]; then
       
  2197 	    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
       
  2198 		if [[ ${COMP_WORDS[i]} == @(add|depends|dotty|policy|rdepends|madison|show?(pkg|src|)) ]]; then
       
  2199 		    special=${COMP_WORDS[i]}
       
  2200 		fi
       
  2201 	    done
       
  2202 	fi
       
  2203 
       
  2204 
       
  2205 	if [ -n "$special" ]; then
       
  2206 	    case $special in
       
  2207 		add)
       
  2208 		    _filedir
       
  2209 		    return 0
       
  2210 		    ;;
       
  2211 		
       
  2212  		*)
       
  2213 		    COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
       
  2214 		    return 0
       
  2215 		    ;;
       
  2216 		
       
  2217 	    esac
       
  2218 	fi
       
  2219 
       
  2220 
       
  2221 	case "$prev" in
       
  2222 	     -@(c|p|s|-config-file|-@(pkg|src)-cache))
       
  2223 		     _filedir
       
  2224 		     return 0
       
  2225 		     ;;
       
  2226 	     search)
       
  2227 		     if [[ "$cur" != -* ]]; then
       
  2228 			    return 0
       
  2229 		     fi
       
  2230 		     ;;
       
  2231 	esac
       
  2232 
       
  2233 	if [[ "$cur" == -* ]]; then
       
  2234 
       
  2235 		COMPREPLY=( $( compgen -W '-h -v -p -s -q -i -f -a -g -c \
       
  2236 				-o --help --version --pkg-cache --src-cache \
       
  2237 				--quiet --important --full --all-versions \
       
  2238 				--no-all-versions --generate --no-generate \
       
  2239 				--names-only --all-names --recurse \
       
  2240 				--config-file --option' -- $cur ) )
       
  2241 	else
       
  2242 
       
  2243 		COMPREPLY=( $( compgen -W 'add gencaches show showpkg showsrc \
       
  2244 				stats dump dumpavail unmet search search \
       
  2245 				depends rdepends pkgnames dotty xvcg \
       
  2246 				policy madison' -- $cur ) )
       
  2247 
       
  2248 	fi
       
  2249 
       
  2250 
       
  2251 	return 0
       
  2252 } &&
       
  2253 complete -F _apt_cache $filenames apt-cache
       
  2254 
       
  2255 
       
  2256 # Debian aptitude(1) completion
       
  2257 #
       
  2258 have aptitude && {
       
  2259 have grep-status && {
       
  2260 _comp_dpkg_hold_packages()
       
  2261 {
       
  2262 	grep-status -P -e "^$1" -a -FStatus 'hold' -n -s Package
       
  2263 }
       
  2264 } || {
       
  2265 _comp_dpkg_hold_packages()
       
  2266 {
       
  2267 	grep -B 2 'hold' /var/lib/dpkg/status | grep "Package: $1" \
       
  2268 		| cut -d\  -f2
       
  2269 }
       
  2270 }
       
  2271 
       
  2272 _aptitude()
       
  2273 {
       
  2274 	local cur dashoptions prev special i
       
  2275 
       
  2276 	COMPREPLY=()
       
  2277 	cur=`_get_cword`
       
  2278 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  2279 
       
  2280 
       
  2281 	dashoptions='-S -u -i -h --help --version -s --simulate -d \
       
  2282 		     --download-only -P --prompt -y --assume-yes -F \
       
  2283 		     --display-format -O --sort -w --width -f -r -g \
       
  2284 		     --with-recommends --with-suggests -R -G \
       
  2285 		     --without-recommends --without-suggests -t \
       
  2286 		     --target-release -V --show-versions -D --show-deps\
       
  2287 		     -Z -v --verbose --purge-unused'
       
  2288 
       
  2289 	for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
       
  2290 	    if [[ ${COMP_WORDS[i]} == @(install|reinstall|hold|unhold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|forbid-version|purge|remove|changelog|why|why-not|keep|keep-all) ]]; then
       
  2291 		special=${COMP_WORDS[i]}
       
  2292 	    fi
       
  2293 	    #exclude some mutually exclusive options
       
  2294 	    [[ ${COMP_WORDS[i]} == '-u' ]] && dashoptions=${dashoptions/-i}
       
  2295 	    [[ ${COMP_WORDS[i]} == '-i' ]] && dashoptions=${dashoptions/-u}
       
  2296 	done
       
  2297 
       
  2298 	if [[ -n "$special" ]]; then
       
  2299 	   case $special in
       
  2300 	       @(install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|changelog|why|why-not))
       
  2301 		   COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
       
  2302 		   return 0
       
  2303 		   ;;
       
  2304 	       @(purge|remove|reinstall|forbid-version))
       
  2305   		   COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
       
  2306 		   return 0
       
  2307 		   ;;
       
  2308 	       unhold)
       
  2309   		   COMPREPLY=( $( _comp_dpkg_hold_packages $cur ) )
       
  2310 		   return 0
       
  2311 		   ;;
       
  2312 
       
  2313 	   esac
       
  2314 	fi
       
  2315 
       
  2316 	case $prev in
       
  2317 	    # don't complete anything if these options are found
       
  2318 	    @(autoclean|clean|forget-new|search|upgrade|safe-upgrade|update|keep-all))
       
  2319 		return 0
       
  2320 		;;
       
  2321 
       
  2322 	    -S)
       
  2323 		_filedir
       
  2324 		return 0
       
  2325 		;;
       
  2326 
       
  2327 	    -@(t|-target-release|-default-release))
       
  2328 		COMPREPLY=( $( apt-cache policy | \
       
  2329 		    grep "release.o=Debian,a=$cur" | \
       
  2330 		    sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ) )
       
  2331 		return 0
       
  2332 		;;
       
  2333 
       
  2334 	esac
       
  2335 
       
  2336 	if [[ "$cur" == -* ]]; then
       
  2337 	    COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
       
  2338 	else
       
  2339 	    COMPREPLY=( $( compgen -W 'update upgrade safe-upgrade forget-new clean \
       
  2340 				       autoclean install reinstall remove \
       
  2341 				       hold unhold purge markauto unmarkauto why why-not \
       
  2342 				       dist-upgrade full-upgrade download search show \
       
  2343 				       forbid-version changelog keep-all' -- $cur ) )
       
  2344 	fi
       
  2345 
       
  2346 
       
  2347 	return 0
       
  2348 }
       
  2349 complete -F _aptitude $default aptitude
       
  2350 }
       
  2351 
       
  2352 # Debian apt-build(1) completion.
       
  2353 #
       
  2354 have apt-build &&
       
  2355 _apt_build()
       
  2356 {
       
  2357 	local cur prev special i
       
  2358 
       
  2359 	COMPREPLY=()
       
  2360 	cur=`_get_cword`
       
  2361 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  2362 
       
  2363 	for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
       
  2364 		if [[ ${COMP_WORDS[i]} == @(install|remove|source|info|clean) ]]; then
       
  2365 			special=${COMP_WORDS[i]}
       
  2366 		fi
       
  2367 	done
       
  2368 
       
  2369 	if [ -n "$special" ]; then
       
  2370 		case $special in
       
  2371 		@(install|source|info))
       
  2372 			COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
       
  2373 			return 0
       
  2374 			;;
       
  2375 		remove)
       
  2376 			COMPREPLY=( $( _comp_dpkg_installed_packages \
       
  2377 					$cur ) )
       
  2378 			return 0
       
  2379 			;;
       
  2380 		*)
       
  2381 			return 0
       
  2382 			;;
       
  2383 		esac
       
  2384 	fi
       
  2385 
       
  2386 	case "$prev" in
       
  2387 
       
  2388 	     --@(patch|build-dir|repository-dir))
       
  2389 		   _filedir
       
  2390 		   return 0
       
  2391 		   ;;
       
  2392  
       
  2393 	     -@(h|-help))
       
  2394 		   return 0
       
  2395 		   ;;
       
  2396 
       
  2397 	esac
       
  2398 
       
  2399 	if [[ "$cur" == -* ]]; then
       
  2400 	    COMPREPLY=( $( compgen -W '--help --show-upgraded -u --build-dir \
       
  2401 				  --repository-dir --build-only \
       
  2402 				  --build-command --reinstall --rebuild \
       
  2403 				  --remove-builddep --no-wrapper --purge \
       
  2404 				  --patch --patch-strip -p --yes -y \
       
  2405 				  --version -v --no-source' -- $cur ) )
       
  2406 
       
  2407 	else
       
  2408 	    COMPREPLY=( $( compgen -W 'update upgrade install remove \
       
  2409 				  source dist-upgrade world clean info \
       
  2410 				  clean-build update-repository ' -- $cur ) )
       
  2411 	fi
       
  2412 
       
  2413 
       
  2414 	return 0
       
  2415 } &&
       
  2416 complete -F _apt_build $filenames apt-build
       
  2417 
       
  2418 # chsh(1) completion
       
  2419 #
       
  2420 _chsh()
       
  2421 {
       
  2422 	local cur prev
       
  2423 
       
  2424 	COMPREPLY=()
       
  2425 	cur=`_get_cword`
       
  2426 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  2427 
       
  2428 	if [ "$prev" = "-s" ]; then
       
  2429 	  if [ -f /etc/debian_version ]; then
       
  2430 	    COMPREPLY=( $( </etc/shells ) )
       
  2431 	  else
       
  2432 	    COMPREPLY=( $( chsh -l | grep "^$cur" ) )
       
  2433 	  fi
       
  2434 	else
       
  2435 	  COMPREPLY=( $( compgen -u -- $cur ) )
       
  2436 	fi
       
  2437 
       
  2438 	return 0
       
  2439 }
       
  2440 complete -F _chsh chsh
       
  2441 
       
  2442 # chkconfig(8) completion
       
  2443 #
       
  2444 have chkconfig &&
       
  2445 _chkconfig()
       
  2446 {
       
  2447 	local cur prev
       
  2448 
       
  2449 	COMPREPLY=()
       
  2450 	cur=`_get_cword`
       
  2451 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  2452 
       
  2453 	case "$prev" in
       
  2454 	@([1-6]|--@(list|add|del)))
       
  2455 		_services
       
  2456 		return 0
       
  2457 		;;
       
  2458 	--level)
       
  2459 		COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- $cur ) )
       
  2460 		return 0
       
  2461 		;;
       
  2462 	esac
       
  2463 
       
  2464 	if [[ "$cur" == -* ]]; then
       
  2465 		COMPREPLY=( $( compgen -W '--list --add --del --level' -- $cur ) )
       
  2466 	else
       
  2467 		if [ $COMP_CWORD -eq 2 -o $COMP_CWORD -eq 4 ]; then
       
  2468 			COMPREPLY=( $( compgen -W 'on off reset' -- $cur ) )
       
  2469 		else
       
  2470 			_services
       
  2471 		fi
       
  2472 	fi
       
  2473 } &&
       
  2474 complete -F _chkconfig chkconfig
       
  2475 
       
  2476 # This function provides simple user@host completion
       
  2477 #
       
  2478 _user_at_host() {
       
  2479 	local cur
       
  2480 
       
  2481 	COMPREPLY=()
       
  2482 	cur=`_get_cword`
       
  2483 
       
  2484 	if [[ $cur == *@* ]]; then
       
  2485 		_known_hosts
       
  2486 	else
       
  2487 		COMPREPLY=( $( compgen -u -- "$cur" ) )
       
  2488 	fi
       
  2489 
       
  2490 	return 0
       
  2491 }
       
  2492 shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
       
  2493 
       
  2494 # This function performs host completion based on ssh's known_hosts files,
       
  2495 # defaulting to standard host completion if they don't exist.
       
  2496 #
       
  2497 _known_hosts()
       
  2498 {
       
  2499        local cur curd ocur user suffix aliases global_kh user_kh hosts i host
       
  2500        local -a kh khd config
       
  2501 
       
  2502 	COMPREPLY=()
       
  2503 	cur=`_get_cword`
       
  2504 	ocur=$cur
       
  2505 
       
  2506 	[ "$1" = -a ] || [ "$2" = -a ] && aliases='yes'
       
  2507 	[ "$1" = -c ] || [ "$2" = -c ] && suffix=':'
       
  2508 	[[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}
       
  2509 	kh=()
       
  2510 
       
  2511 	# ssh config files
       
  2512 	[ -r /etc/ssh/ssh_config ] &&
       
  2513 	  config=( "${config[@]}" "/etc/ssh/ssh_config" )
       
  2514 	[ -r "${HOME}/.ssh/config" ] &&
       
  2515 	  config=( "${config[@]}" "${HOME}/.ssh/config" )
       
  2516 	[ -r "${HOME}/.ssh2/config" ] &&
       
  2517 	  config=( "${config[@]}" "${HOME}/.ssh2/config" )
       
  2518 
       
  2519 	if [ ${#config[@]} -gt 0 ]; then
       
  2520 	    # expand path (if present) to global known hosts file
       
  2521 	    global_kh=$( eval echo $( 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[@]}" ) )
       
  2522 	    # expand path (if present) to user known hosts file
       
  2523 	    user_kh=$( eval echo $( 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[@]}" ) )
       
  2524 	fi
       
  2525 
       
  2526 	# Global known_hosts files
       
  2527 	[ -r "$global_kh" ] &&
       
  2528 	    kh=( "${kh[@]}" "$global_kh" )
       
  2529 	[ -r /etc/ssh/ssh_known_hosts ] &&
       
  2530 	    kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts )
       
  2531 	[ -r /etc/ssh/ssh_known_hosts2 ] &&
       
  2532 	    kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts2 )
       
  2533 	[ -r /etc/known_hosts ] &&
       
  2534 	    kh=( "${kh[@]}" /etc/known_hosts )
       
  2535 	[ -r /etc/known_hosts2 ] &&
       
  2536 	    kh=( "${kh[@]}" /etc/known_hosts2 )
       
  2537 	[ -d /etc/ssh2/knownhosts ] &&
       
  2538 	    khd=( "${khd[@]}" /etc/ssh2/knownhosts/*pub )
       
  2539 
       
  2540 	# User known_hosts files
       
  2541 	[ -r "$user_kh" ] &&
       
  2542 	    kh=( "${kh[@]}" "$user_kh" )
       
  2543 	[ -r ~/.ssh/known_hosts ] &&
       
  2544 	    kh=( "${kh[@]}" ~/.ssh/known_hosts )
       
  2545 	[ -r ~/.ssh/known_hosts2 ] &&
       
  2546 	    kh=( "${kh[@]}" ~/.ssh/known_hosts2 )
       
  2547 	[ -d ~/.ssh2/hostkeys ] &&
       
  2548 	    khd=( "${khd[@]}" ~/.ssh2/hostkeys/*pub )
       
  2549 
       
  2550 	# If we have known_hosts files to use
       
  2551 	if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 ]; then
       
  2552 	    # Escape slashes and dots in paths for awk
       
  2553 	    cur=${cur//\//\\\/}
       
  2554 	    cur=${cur//\./\\\.}
       
  2555 	    curd=$cur
       
  2556 
       
  2557 	    if [[ "$cur" == [0-9]*.* ]]; then
       
  2558 		# Digits followed by a dot - just search for that
       
  2559 		cur="^$cur.*"
       
  2560 	    elif [[ "$cur" == [0-9]* ]]; then
       
  2561 		# Digits followed by no dot - search for digits followed
       
  2562 		# by a dot
       
  2563 		cur="^$cur.*\."
       
  2564 	    elif [ -z "$cur" ]; then
       
  2565 		# A blank - search for a dot or an alpha character
       
  2566 		cur="[a-z.]"
       
  2567 	    else
       
  2568 		cur="^$cur"
       
  2569 	    fi
       
  2570 
       
  2571 	    if [ ${#kh[@]} -gt 0 ]; then
       
  2572 
       
  2573 		# FS needs to look for a comma separated list
       
  2574 		COMPREPLY=( $( awk 'BEGIN {FS=","}
       
  2575 				/^[^|]/ {for (i=1; i<=2; ++i) { \
       
  2576 				       gsub(" .*$", "", $i); \
       
  2577 				       if ($i ~ /'$cur'/) {print $i} \
       
  2578 				}}' "${kh[@]}" 2>/dev/null ) )
       
  2579 	    fi
       
  2580 	    if [ ${#khd[@]} -gt 0 ]; then
       
  2581 		# Needs to look for files called
       
  2582 		# .../.ssh2/key_22_<hostname>.pub
       
  2583 		# dont fork any processes, because in a cluster environment, 
       
  2584 		# there can be hundreds of hostkeys
       
  2585 		for i in "${khd[@]}" ; do
       
  2586 		    if [[ "$i" == *key_22_$curd*.pub ]] && [ -r "$i" ] ; then
       
  2587 			host=${i/#*key_22_/}
       
  2588 			host=${host/%.pub/}
       
  2589 			COMPREPLY=( "${COMPREPLY[@]}" $host )
       
  2590 		    fi
       
  2591 		done
       
  2592 	    fi
       
  2593 
       
  2594 	    # append any available aliases from config files
       
  2595 	    if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
       
  2596 		local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^*?]*\)$/\2/p' "${config[@]}" )
       
  2597 		hosts=$( compgen -W "$host_aliases" -- $ocur )
       
  2598 		COMPREPLY=( "${COMPREPLY[@]}" $hosts )
       
  2599 	    fi
       
  2600 
       
  2601 	    # Now add results of normal hostname completion
       
  2602 	    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -A hostname -- $ocur ) )
       
  2603 
       
  2604 	    # apply suffix
       
  2605 	    for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
       
  2606 		COMPREPLY[i]=$user${COMPREPLY[i]}$suffix
       
  2607 	    done
       
  2608 	else
       
  2609 	    # Just do normal hostname completion
       
  2610 	    COMPREPLY=( $( compgen -A hostname -S "$suffix" -- $cur ) )
       
  2611 	fi
       
  2612 
       
  2613 	return 0
       
  2614 }
       
  2615 complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \
       
  2616 	ping ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr
       
  2617 
       
  2618 # ssh(1) completion
       
  2619 #
       
  2620 have ssh && {
       
  2621 _ssh()
       
  2622 {
       
  2623 	local cur prev
       
  2624 	local -a config
       
  2625 
       
  2626 	COMPREPLY=()
       
  2627 	cur=`_get_cword`
       
  2628 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  2629 
       
  2630 	case "$prev" in
       
  2631 	-*c)
       
  2632 	    COMPREPLY=( $( compgen -W 'blowfish 3des 3des-cbc blowfish-cbc \
       
  2633 			   arcfour cast128-cbc' -- $cur ) )
       
  2634 	    ;;
       
  2635 	-*i)
       
  2636 	    _filedir
       
  2637 	    ;;
       
  2638 	-*l)
       
  2639 	    COMPREPLY=( $( compgen -u -- $cur ) )
       
  2640 	    ;;
       
  2641 	*)
       
  2642 	    _known_hosts -a
       
  2643 
       
  2644 	    [ $COMP_CWORD -eq 1 ] || \
       
  2645 		COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
       
  2646 	esac
       
  2647 
       
  2648 	return 0
       
  2649 }
       
  2650 shopt -u hostcomplete && complete -F _ssh ssh slogin sftp xhost autossh
       
  2651 
       
  2652 # scp(1) completion
       
  2653 #
       
  2654 _scp()
       
  2655 {
       
  2656 	local cur userhost path
       
  2657 
       
  2658 	COMPREPLY=()
       
  2659 	cur=`_get_cword`
       
  2660 
       
  2661 	_expand || return 0
       
  2662 
       
  2663 	if [[ "$cur" == *:* ]]; then
       
  2664 		local IFS=$'\t\n'
       
  2665 		# remove backslash escape from :
       
  2666 		cur=${cur/\\:/:}
       
  2667 		userhost=${cur%%?(\\):*}
       
  2668 		path=${cur#*:}
       
  2669 		# unescape spaces
       
  2670 		path=${path//\\\\\\\\ / }
       
  2671 		if [ -z "$path" ]; then
       
  2672 			# default to home dir of specified user on remote host
       
  2673 			path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
       
  2674 		fi
       
  2675 		# escape spaces; remove executables, aliases, pipes and sockets;
       
  2676 		# add space at end of file names
       
  2677 		COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
       
  2678 			       command ls -aF1d "$path*" 2>/dev/null | \
       
  2679 			       sed -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\\\\\\\\\&/g" \
       
  2680 				   -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
       
  2681 		return 0
       
  2682 	fi
       
  2683 
       
  2684 	[[ "$cur" == */* ]] || _known_hosts -c -a
       
  2685 		local IFS=$'\t\n'
       
  2686 		COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \
       
  2687 			    2>/dev/null | sed \
       
  2688 			    -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\&/g" \
       
  2689 			    -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
       
  2690 	return 0
       
  2691 }
       
  2692 complete -F _scp $nospace scp
       
  2693 }
       
  2694 
       
  2695 # rsync(1) completion
       
  2696 #
       
  2697 have rsync &&
       
  2698 _rsync()
       
  2699 {
       
  2700 	local cur prev shell i userhost path
       
  2701  
       
  2702 	COMPREPLY=()
       
  2703 	cur=`_get_cword`
       
  2704 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  2705 
       
  2706 	_expand || return 0
       
  2707 
       
  2708 	case "$prev" in
       
  2709 	--@(config|password-file|include-from|exclude-from))
       
  2710 		_filedir
       
  2711 		return 0
       
  2712 		;;
       
  2713 	-@(T|-temp-dir|-compare-dest))
       
  2714 		_filedir -d
       
  2715 		return 0
       
  2716 		;;
       
  2717 	-@(e|-rsh))
       
  2718 		COMPREPLY=( $( compgen -W 'rsh ssh' -- $cur ) )
       
  2719 		return 0
       
  2720 		;;
       
  2721 	esac
       
  2722  
       
  2723 	case "$cur" in
       
  2724 	-*)
       
  2725 		COMPREPLY=( $( compgen -W '-v -q  -c -a -r -R -b -u -l -L -H \
       
  2726 				-p -o -g -D -t -S -n -W -x -B -e -C -I -T -P \
       
  2727 				-z -h -4 -6 --verbose --quiet --checksum \
       
  2728 				--archive --recursive --relative --backup \
       
  2729 				--backup-dir --suffix= --update --links \
       
  2730 				--copy-links --copy-unsafe-links --safe-links \
       
  2731 				--hard-links --perms --owner --group --devices\
       
  2732 				--times --sparse --dry-run --whole-file \
       
  2733 				--no-whole-file --one-file-system \
       
  2734 				--block-size= --rsh= --rsync-path= \
       
  2735 				--cvs-exclude --existing --ignore-existing \
       
  2736 				--delete --delete-excluded --delete-after \
       
  2737 				--ignore-errors --max-delete= --partial \
       
  2738 				--force --numeric-ids --timeout= \
       
  2739 				--ignore-times --size-only --modify-window= \
       
  2740 				--temp-dir= --compare-dest= --compress \
       
  2741 				--exclude= --exclude-from= --include= \
       
  2742 				--include-from= --version --daemon --no-detach\
       
  2743 				--address= --config= --port= --blocking-io \
       
  2744 				--no-blocking-io --stats --progress \
       
  2745 				--log-format= --password-file= --bwlimit= \
       
  2746 				--write-batch= --read-batch= --help' -- $cur ))
       
  2747 		;;
       
  2748 	*:*)
       
  2749 		# find which remote shell is used
       
  2750 		shell=rsh
       
  2751 		for (( i=1; i < COMP_CWORD; i++ )); do
       
  2752 			if [[ "${COMP_WORDS[i]}" == -@(e|-rsh) ]]; then
       
  2753 				shell=${COMP_WORDS[i+1]}
       
  2754 				break
       
  2755 			fi
       
  2756 		done
       
  2757 		if [[ "$shell" == ssh ]]; then
       
  2758 			# remove backslash escape from :
       
  2759 			cur=${cur/\\:/:}
       
  2760 			userhost=${cur%%?(\\):*}
       
  2761 			path=${cur#*:}
       
  2762 			# unescape spaces
       
  2763 			path=${path//\\\\\\\\ / }
       
  2764 			if [ -z "$path" ]; then
       
  2765 				# default to home dir of specified
       
  2766 				# user on remote host
       
  2767 				path=$(ssh -o 'Batchmode yes' \
       
  2768 					$userhost pwd 2>/dev/null)
       
  2769 			fi
       
  2770 			# escape spaces; remove executables, aliases, pipes
       
  2771 			# and sockets; add space at end of file names
       
  2772 			COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
       
  2773 				command ls -aF1d "$path*" 2>/dev/null | \
       
  2774 				sed -e 's/ /\\\\\\\ /g' -e 's/[*@|=]$//g' \
       
  2775 				-e 's/[^\/]$/& /g' ) )
       
  2776 		fi
       
  2777 		;;
       
  2778 	*)
       
  2779 		_known_hosts -c -a
       
  2780 		_filedir
       
  2781 		;;
       
  2782 	esac
       
  2783  
       
  2784 	return 0
       
  2785 } &&
       
  2786 complete -F _rsync $nospace $filenames rsync
       
  2787 
       
  2788 # Linux route(8) completion
       
  2789 #
       
  2790 [ $UNAME = Linux ] &&
       
  2791 _route()
       
  2792 {
       
  2793 	local cur prev
       
  2794 
       
  2795 	COMPREPLY=()
       
  2796 	cur=`_get_cword`
       
  2797 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  2798 
       
  2799 	if [ "$prev" = dev ]; then
       
  2800 	    COMPREPLY=( $( ifconfig -a | sed -ne 's|^\('$cur'[^ ]*\).*$|\1|p' ))
       
  2801 	    return 0
       
  2802 	fi
       
  2803 
       
  2804 	COMPREPLY=( $( compgen -W 'add del -host -net netmask metric mss \
       
  2805 				   window irtt reject mod dyn reinstate dev \
       
  2806 				   default gw' -- $cur ) )
       
  2807 
       
  2808 	COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \
       
  2809 		       (while read -d ' ' i; do
       
  2810 			   [ "$i" == "" ] && continue
       
  2811 			   # flatten array with spaces on either side,
       
  2812 			   # otherwise we cannot grep on word
       
  2813 			   # boundaries of first and last word
       
  2814 			   COMPREPLY=" ${COMPREPLY[@]} "
       
  2815 			   # remove word from list of completions
       
  2816 			   COMPREPLY=( ${COMPREPLY/ $i / } )
       
  2817 			done
       
  2818 		       echo "${COMPREPLY[@]}")
       
  2819 		  ) )
       
  2820 	return 0
       
  2821 }
       
  2822 [ $UNAME = Linux ] && complete -F _route route
       
  2823 
       
  2824 # GNU make(1) completion
       
  2825 #
       
  2826 have make || have gmake || have gnumake || have pmake &&
       
  2827 _make()
       
  2828 {
       
  2829 	local file makef makef_dir="." makef_inc cur prev i
       
  2830 
       
  2831 	COMPREPLY=()
       
  2832 	cur=`_get_cword`
       
  2833 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  2834 
       
  2835 	# --name value style option
       
  2836 	case $prev in
       
  2837 		-@(f|o|W))
       
  2838 			_filedir
       
  2839 			return 0
       
  2840 			;;
       
  2841 		-@(I|C))
       
  2842 			_filedir -d
       
  2843 			return 0
       
  2844 			;;
       
  2845 	esac
       
  2846 
       
  2847 	# --name=value style option
       
  2848 	if [[ "$cur" == *=* ]]; then
       
  2849 		prev=${cur/=*/}
       
  2850 		cur=${cur/*=/}
       
  2851 		case "$prev" in
       
  2852 			--@(file|makefile))
       
  2853 				_filedir
       
  2854 				return 0
       
  2855 				;;
       
  2856 			--@(directory|include-dir))
       
  2857 				_filedir -d
       
  2858 				return 0
       
  2859 				;;
       
  2860 		esac
       
  2861 	fi
       
  2862 
       
  2863 	if [[ "$cur" == -* ]]; then
       
  2864 		COMPREPLY=( $( compgen -W '-b -m -B -C -d -e -f -h -i -I\
       
  2865 			-j -l -k -n -o -p -q -r -R - s -S -t -v -w -W \
       
  2866 			--always-make --directory= --debug \
       
  2867 			--environment-overrides --file= --makefile= --help \
       
  2868 			--ignore-errors --include-dir= --jobs --load-average \
       
  2869 			--max-load --keep-going --just-print --dry-run \
       
  2870 			--recon --old-file= --assume-old= --print-data-base \
       
  2871 			--question --no-builtin-rules --no-builtin-variables \
       
  2872 			--silent --quiet --no-keep-goind --stop --touch \
       
  2873 			--version --print-directory --no-print-directory \
       
  2874 			--what-if= --new-file= --assume-new= \
       
  2875 			--warn-undefined-variables' -- $cur ) )
       
  2876 	else
       
  2877 		# before we check for makefiles, see if a path was specified
       
  2878 		# with -C
       
  2879 		for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
       
  2880 			if [[ ${COMP_WORDS[i]} == -C ]]; then
       
  2881 				# eval for tilde expansion
       
  2882 				eval makef_dir=${COMP_WORDS[i+1]}
       
  2883 				break
       
  2884 			fi
       
  2885 		done
       
  2886 
       
  2887 		# make reads `GNUmakefile', then `makefile', then `Makefile'
       
  2888 		if [ -f ${makef_dir}/GNUmakefile ]; then
       
  2889 			makef=${makef_dir}/GNUmakefile
       
  2890 		elif [ -f ${makef_dir}/makefile ]; then
       
  2891 			makef=${makef_dir}/makefile
       
  2892 		elif [ -f ${makef_dir}/Makefile ]; then
       
  2893 			makef=${makef_dir}/Makefile
       
  2894 		else
       
  2895 			makef=${makef_dir}/*.mk	       # local convention
       
  2896 		fi
       
  2897 
       
  2898 		# before we scan for targets, see if a Makefile name was
       
  2899 		# specified with -f
       
  2900 		for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
       
  2901 			if [[ ${COMP_WORDS[i]} == -f ]]; then
       
  2902 				# eval for tilde expansion
       
  2903 				eval makef=${COMP_WORDS[i+1]}
       
  2904 				break
       
  2905 			fi
       
  2906 		done
       
  2907 
       
  2908 		[ ! -f $makef ] && return 0
       
  2909 
       
  2910 		# deal with included Makefiles
       
  2911  		makef_inc=$( grep -E '^-?include' $makef | sed -e "s,^.* ,"$makef_dir"/," )
       
  2912 
       
  2913  		for file in $makef_inc; do
       
  2914  			[ -f $file ] && makef="$makef $file"
       
  2915  		done
       
  2916 
       
  2917 		COMPREPLY=( $( awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \
       
  2918 				{split($1,A,/ /);for(i in A)print A[i]}' \
       
  2919 				$makef 2>/dev/null | command grep "^$cur" ))
       
  2920 	fi
       
  2921 } &&
       
  2922 complete -f -F _make $filenames make gmake gnumake pmake
       
  2923 
       
  2924 # GNU tar(1) completion
       
  2925 #
       
  2926 _tar()
       
  2927 {
       
  2928 	local cur ext regex tar untar
       
  2929 
       
  2930 	COMPREPLY=()
       
  2931 	cur=`_get_cword`
       
  2932 
       
  2933 	if [ $COMP_CWORD -eq 1 ]; then
       
  2934 		COMPREPLY=( $( compgen -W 'c t x u r d A' -- $cur ) )
       
  2935 		return 0
       
  2936 	fi
       
  2937 
       
  2938 	case "${COMP_WORDS[1]}" in
       
  2939 	?(-)[cr]*f)
       
  2940 		_filedir
       
  2941 		return 0
       
  2942 		;;
       
  2943 	+([^IZzjy])f)
       
  2944 		ext='t@(ar?(.@(Z|gz|bz?(2)))|gz|bz?(2))'
       
  2945 		regex='t\(ar\(\.\(Z\|gz\|bz2\?\)\)\?\|gz\|bz2\?\)'
       
  2946 		;;
       
  2947 	*[Zz]*f)
       
  2948 		ext='t?(ar.)@(gz|Z)'
       
  2949 		regex='t\(ar\.\)\?\(gz\|Z\)'
       
  2950 		;;
       
  2951 	*[Ijy]*f)
       
  2952 		ext='t?(ar.)bz?(2)'
       
  2953 		regex='t\(ar\.\)\?bz2\?'
       
  2954 		;;
       
  2955 	*)
       
  2956 		_filedir
       
  2957 		return 0
       
  2958 		;;
       
  2959 		
       
  2960 	esac
       
  2961 
       
  2962 	if [[ "$COMP_LINE" == *$ext' ' ]]; then
       
  2963 		# complete on files in tar file
       
  2964 		#
       
  2965 		# get name of tar file from command line
       
  2966 		tar=$( echo "$COMP_LINE" | \
       
  2967 			sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' )
       
  2968 		# devise how to untar and list it
       
  2969 		untar=t${COMP_WORDS[1]//[^Izjyf]/}
       
  2970 
       
  2971 		COMPREPLY=( $( compgen -W "$( echo $( tar $untar $tar \
       
  2972 				2>/dev/null ) )" -- "$cur" ) )
       
  2973 		return 0
       
  2974 	fi
       
  2975 
       
  2976 	# file completion on relevant files
       
  2977 	_filedir "$ext"
       
  2978 
       
  2979 	return 0
       
  2980 }
       
  2981 [ -n "${COMP_TAR_INTERNAL_PATHS:-}" ] && complete -F _tar $dirnames tar ||
       
  2982 	complete -F _tar $filenames tar
       
  2983 
       
  2984 # jar(1) completion
       
  2985 #
       
  2986 have jar &&
       
  2987 _jar()
       
  2988 {
       
  2989 	local cur
       
  2990 
       
  2991 	COMPREPLY=()
       
  2992 	cur=`_get_cword`
       
  2993 
       
  2994 	if [ $COMP_CWORD = 1 ]; then
       
  2995 		COMPREPLY=( $( compgen -W 'c t x u' -- $cur ) )
       
  2996 		return 0
       
  2997 	fi
       
  2998 
       
  2999 	case "${COMP_WORDS[1]}" in
       
  3000 		*c*f)
       
  3001 			_filedir
       
  3002 			;;
       
  3003 		*f)
       
  3004 			_filedir '?(e|j|w)ar'
       
  3005 			;;
       
  3006 		*)
       
  3007 			_filedir
       
  3008 			;;
       
  3009 	esac
       
  3010 } &&
       
  3011 complete -F _jar $filenames jar
       
  3012 
       
  3013 # Linux iptables(8) completion
       
  3014 #
       
  3015 have iptables &&
       
  3016 _iptables()
       
  3017 {
       
  3018 	local cur prev table chain
       
  3019 
       
  3020 	COMPREPLY=()
       
  3021 	cur=`_get_cword`
       
  3022 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  3023 	chain='s/^Chain \([^ ]\+\).*$/\1/p'
       
  3024 
       
  3025 	if [[ $COMP_LINE == *-t\ *filter* ]]; then
       
  3026 		table="-t filter"
       
  3027 	elif [[ $COMP_LINE == *-t\ *nat* ]]; then
       
  3028 		table="-t nat"
       
  3029 	elif [[ $COMP_LINE == *-t\ *mangle* ]]; then
       
  3030 		table="-t mangle"
       
  3031 	fi
       
  3032 
       
  3033 	case "$prev" in
       
  3034 	-*[AIDRPFXLZ])
       
  3035 		COMPREPLY=( $( compgen -W '`iptables $table -nL | \
       
  3036 			    sed -ne "s/^Chain \([^ ]\+\).*$/\1/p"`' -- $cur ) )
       
  3037 		;;
       
  3038 	-*t)
       
  3039 		COMPREPLY=( $( compgen -W 'nat filter mangle' -- $cur ) )
       
  3040 		;;
       
  3041 	-j)
       
  3042 		if [ "$table" = "-t filter" -o "$table" = "" ]; then
       
  3043 		    COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
       
  3044 		    `iptables $table -nL | sed -ne "$chain" \
       
  3045 		    -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
       
  3046 		    $cur ) )
       
  3047 		elif [ "$table" = "-t nat" ]; then
       
  3048 		    COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
       
  3049 		    MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \
       
  3050 		    sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \
       
  3051 		    -- $cur ) )
       
  3052 		elif [ "$table" = "-t mangle" ]; then
       
  3053 		    COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
       
  3054 		    MARK TOS `iptables $table -nL | sed -ne "$chain" \
       
  3055 		    -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
       
  3056 		    $cur ) )
       
  3057 		fi
       
  3058 		;;
       
  3059 	*)
       
  3060 		if [[ "$cur" == -* ]]; then
       
  3061 		    COMPREPLY=( $( compgen -W '-i -o -s -d -p -f -m --append \
       
  3062 		    --delete --insert --replace --list --flush --zero --new \
       
  3063 		    --delete-chain --policy --rename-chain --proto --source \
       
  3064 		    --destination --in-interface --jump --match --numeric \
       
  3065 		    --out-interface --table --verbose --line-numbers --exact \
       
  3066 		    --fragment --modprobe= --set-counters --version' -- "$cur") )
       
  3067 		fi
       
  3068 		;;
       
  3069 	esac
       
  3070 
       
  3071 } &&
       
  3072 complete -F _iptables iptables
       
  3073 
       
  3074 # tcpdump(8) completion
       
  3075 #
       
  3076 have tcpdump &&
       
  3077 _tcpdump()
       
  3078 {
       
  3079 	local cur
       
  3080 
       
  3081 	COMPREPLY=()
       
  3082 	cur=`_get_cword`
       
  3083 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  3084 
       
  3085 	case "$prev" in
       
  3086 		-@(r|w|F))
       
  3087 			_filedir
       
  3088 			return 0
       
  3089 			;;
       
  3090 		-i)
       
  3091 			_available_interfaces -a
       
  3092 			return 0
       
  3093 			;;
       
  3094 	esac
       
  3095 
       
  3096 
       
  3097 	if [[ "$cur" == -* ]]; then
       
  3098 		COMPREPLY=( $( compgen -W '-a -d -e -f -l -n -N -O -p \
       
  3099 			-q -R -S -t -u -v -x -C -F -i -m -r -s -T -w \
       
  3100 			-E' -- $cur ) )
       
  3101 	fi
       
  3102 
       
  3103 } &&
       
  3104 complete -F _tcpdump tcpdump
       
  3105 
       
  3106 # autorpm(8) completion
       
  3107 #
       
  3108 have autorpm &&
       
  3109 _autorpm()
       
  3110 {
       
  3111 	local cur
       
  3112 
       
  3113 	COMPREPLY=()
       
  3114 	cur=`_get_cword`
       
  3115 
       
  3116 	COMPREPLY=( $( compgen -W '--notty --debug --help --version \
       
  3117 				   auto add fullinfo info help install list \
       
  3118 				   remove set' -- $cur ) )
       
  3119 
       
  3120 } &&
       
  3121 complete -F _autorpm autorpm
       
  3122 
       
  3123 # This meta-cd function observes the CDPATH variable, so that cd additionally
       
  3124 # completes on directories under those specified in CDPATH.
       
  3125 #
       
  3126 _cd()
       
  3127 {
       
  3128 	local IFS=$'\t\n' cur=`_get_cword` i j k
       
  3129 
       
  3130 	# try to allow variable completion
       
  3131 	if [[ "$cur" == ?(\\)\$* ]]; then
       
  3132 		COMPREPLY=( $( compgen -v -P '$' -- "${cur#?(\\)$}" ) )
       
  3133 		return 0
       
  3134 	fi
       
  3135 
       
  3136 	# Use standard dir completion if no CDPATH or parameter starts with /,
       
  3137 	# ./ or ../
       
  3138 	if [ -z "${CDPATH:-}" ] || [[ "$cur" == ?(.)?(.)/* ]]; then
       
  3139 		_filedir -d
       
  3140 		return 0
       
  3141 	fi
       
  3142 
       
  3143 	local -r mark_dirs=$(_rl_enabled mark-directories && echo y)
       
  3144 	local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y)
       
  3145 
       
  3146 	# we have a CDPATH, so loop on its contents
       
  3147 	for i in ${CDPATH//:/$'\t'}; do
       
  3148 		# create an array of matched subdirs
       
  3149 		k="${#COMPREPLY[@]}"
       
  3150 		for j in $( compgen -d $i/$cur ); do
       
  3151 			if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
       
  3152 				j="${j}/"
       
  3153 			fi
       
  3154 			COMPREPLY[k++]=${j#$i/}
       
  3155 		done
       
  3156 	done
       
  3157 
       
  3158 	_filedir -d
       
  3159 
       
  3160 	if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
       
  3161 	    i=${COMPREPLY[0]}
       
  3162 	    if [ "$i" == "$cur" ] && [[ $i != "*/" ]]; then
       
  3163 		COMPREPLY[0]="${i}/"
       
  3164 	    fi
       
  3165 	fi
       
  3166 	    
       
  3167 	return 0
       
  3168 }
       
  3169 if shopt -q cdable_vars; then
       
  3170     complete -v -F _cd $nospace $filenames cd
       
  3171 else
       
  3172     complete -F _cd $nospace $filenames cd
       
  3173 fi
       
  3174 
       
  3175 _remove_comp_word()
       
  3176 {
       
  3177 	if [[ COMP_CWORD -eq 0 ]]; then
       
  3178 		return
       
  3179 	elif [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
       
  3180 		local old_cw0="${COMP_WORDS[0]}"
       
  3181 		local new_cw0="${COMP_WORDS[1]}"
       
  3182 		local old_length="${#COMP_LINE}"
       
  3183 		COMP_LINE=${COMP_LINE#${old_cw0}}
       
  3184 		local head=${COMP_LINE:0:${#new_cw0}}
       
  3185 		local i=1
       
  3186 		while [[ $head != $new_cw0 ]]; do
       
  3187 			COMP_LINE=${COMP_LINE:1}
       
  3188 			head=${COMP_LINE:0:${#new_cw0}}
       
  3189 			if (( ++i > 10 )); then
       
  3190 				break
       
  3191 			fi
       
  3192 		done
       
  3193 		local new_length="${#COMP_LINE}"
       
  3194 		COMP_POINT=$(( COMP_POINT + new_length - old_length))
       
  3195 
       
  3196 		COMP_CWORD=$(( COMP_CWORD - 1 ))
       
  3197 		for (( i=0; i < ${#COMP_WORDS[@]} - 1; ++i )); do
       
  3198 			COMP_WORDS[i]="${COMP_WORDS[i+1]}"
       
  3199 		done
       
  3200 		unset COMP_WORDS[${#COMP_WORDS[@]}-1]
       
  3201 	else
       
  3202 		return
       
  3203 	fi
       
  3204 }
       
  3205 
       
  3206 # A meta-command completion function for commands like sudo(8), which need to
       
  3207 # first complete on a command, then complete according to that command's own
       
  3208 # completion definition - currently not quite foolproof (e.g. mount and umount
       
  3209 # don't work properly), but still quite useful.
       
  3210 #
       
  3211 _command()
       
  3212 {
       
  3213 	local cur func cline cspec noglob cmd done i \
       
  3214 	      _COMMAND_FUNC _COMMAND_FUNC_ARGS
       
  3215 
       
  3216 	_remove_comp_word
       
  3217 	COMPREPLY=()
       
  3218 	cur=`_get_cword`
       
  3219 	# If the the first arguments following our meta-command-invoker are
       
  3220 	# switches, get rid of them. Most definitely not foolproof.
       
  3221 	done=
       
  3222 	while [ -z $done ] ; do
       
  3223 	    cmd=${COMP_WORDS[0]}
       
  3224 	    if [[ "$cmd" == -* ]] && [ $COMP_CWORD -ge 1 ]; then
       
  3225 	        _remove_comp_word
       
  3226 	    elif [[ "$cmd" == -* ]] && [[ $COMP_CWORD -eq 0 ]]; then
       
  3227 		return
       
  3228 	    else 
       
  3229 		done=1
       
  3230 	    fi
       
  3231 	done
       
  3232 
       
  3233 	if [ $COMP_CWORD -eq 0 ]; then
       
  3234 		COMPREPLY=( $( compgen -c -- $cur ) )
       
  3235 	elif complete -p $cmd &>/dev/null; then
       
  3236 		cspec=$( complete -p $cmd )
       
  3237 		if [ "${cspec#* -F }" != "$cspec" ]; then
       
  3238 			# COMP_CWORD and COMP_WORDS() are not read-only,
       
  3239 			# so we can set them before handing off to regular
       
  3240 			# completion routine
       
  3241 
       
  3242 			# get function name
       
  3243 			func=${cspec#*-F }
       
  3244 			func=${func%% *}
       
  3245 
       
  3246 			if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
       
  3247 				$func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}"
       
  3248 			else
       
  3249 				$func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}"
       
  3250 			fi
       
  3251 
       
  3252 			# remove any \: generated by a command that doesn't
       
  3253 			# default to filenames or dirnames (e.g. sudo chown)
       
  3254 			# FIXME: I'm pretty sure this does not work!
       
  3255 			if [ "${cspec#*-o }" != "$cspec" ]; then
       
  3256 				cspec=${cspec#*-o }
       
  3257 				cspec=${cspec%% *}
       
  3258 				if [[ "$cspec" != @(dir|file)names ]]; then
       
  3259 					COMPREPLY=("${COMPREPLY[@]//\\\\:/:}")
       
  3260 				fi
       
  3261 			fi
       
  3262 		elif [ -n "$cspec" ]; then
       
  3263 			cspec=${cspec#complete};
       
  3264 			cspec=${cspec%%$cmd};
       
  3265 			COMPREPLY=( $( eval compgen "$cspec" -- "$cur" ) );
       
  3266 		fi
       
  3267 	fi
       
  3268 
       
  3269 	[ ${#COMPREPLY[@]} -eq 0 ] && _filedir
       
  3270 }
       
  3271 complete -F _command $filenames nohup exec nice eval strace time ltrace then \
       
  3272 	else do vsound command xargs
       
  3273 
       
  3274 _root_command()
       
  3275 {
       
  3276 	PATH=/usr/gnu/bin:$PATH:/sbin:/usr/sbin _command $1 $2 $3
       
  3277 }
       
  3278 complete -F _root_command $filenames sudo fakeroot really
       
  3279 
       
  3280 # ant(1) completion
       
  3281 #
       
  3282 have ant && {
       
  3283 _ant()
       
  3284 {
       
  3285 	local cur prev buildfile i
       
  3286 
       
  3287 	COMPREPLY=()
       
  3288 	cur=`_get_cword`
       
  3289 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  3290 
       
  3291 	case "$prev" in
       
  3292 		-buildfile|-f)
       
  3293 			_filedir 'xml'
       
  3294 			return 0
       
  3295 			;;
       
  3296 		-logfile)
       
  3297 			_filedir
       
  3298 			return 0
       
  3299 			;;
       
  3300 	esac
       
  3301 
       
  3302 	if [[ "$cur" == -* ]]; then
       
  3303 		# relevant options completion
       
  3304 		COMPREPLY=( $( compgen -W '-help -projecthelp -version -quiet \
       
  3305 			       -verbose -debug -emacs -logfile -logger \
       
  3306 			       -listener -buildfile -f -D -find' -- $cur ) )
       
  3307 	else
       
  3308 		# available targets completion
       
  3309 		# find which buildfile to use
       
  3310 		buildfile=build.xml
       
  3311 		for (( i=1; i < COMP_CWORD; i++ )); do
       
  3312 			if [[ "${COMP_WORDS[i]}" == -buildfile ]]; then
       
  3313 				buildfile=${COMP_WORDS[i+1]}
       
  3314 				break
       
  3315 			fi
       
  3316 		done
       
  3317 		[ ! -f $buildfile ] && return 0
       
  3318 
       
  3319 		# parse buildfile for targets
       
  3320 		COMPREPLY=( $( awk -F'"' '/<target name="/ {print $2}' \
       
  3321 				$buildfile | grep "^$cur" )
       
  3322 			    $( awk -F"'" "/<target name='/ "'{print $2}' \
       
  3323 				$buildfile | grep "^$cur" )
       
  3324 			    $( awk -F'"' '/<target [^n]/ {if ($1 ~ /name=/) { print $2 } else if ($3 ~ /name=/) {print $4} else if ($5 ~ /name=/) {print $6}}' \
       
  3325 				$buildfile | grep "^$cur" ) )
       
  3326 	fi
       
  3327 }
       
  3328 have complete-ant-cmd.pl && \
       
  3329      complete -C complete-ant-cmd.pl -F _ant $filenames ant || \
       
  3330      complete -F _ant $filenames ant
       
  3331 }
       
  3332 
       
  3333 have nslookup &&
       
  3334 _nslookup()
       
  3335 {
       
  3336 	local cur
       
  3337 
       
  3338 	COMPREPLY=()
       
  3339 	cur=${COMP_WORDS[COMP_CWORD]#-}
       
  3340 
       
  3341 	COMPREPLY=( $( compgen -P '-' -W 'all class= debug d2 domain= \
       
  3342 			       srchlist= defname search port= querytype= \
       
  3343 			       type= recurse retry root timeout vc \
       
  3344 			       ignoretc' -- $cur ) )
       
  3345 } &&
       
  3346 complete -F _nslookup nslookup
       
  3347 
       
  3348 # mysqladmin(1) completion
       
  3349 #
       
  3350 have mysqladmin &&
       
  3351 _mysqladmin()
       
  3352 {
       
  3353 	local cur prev
       
  3354 
       
  3355 	COMPREPLY=()
       
  3356 	cur=`_get_cword`
       
  3357 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  3358 
       
  3359 	case "$prev" in
       
  3360 	-u)
       
  3361 		COMPREPLY=( $( compgen -u -- $cur ) )
       
  3362 		return 0
       
  3363 		;;
       
  3364 	*)
       
  3365 		;;
       
  3366 	esac
       
  3367 
       
  3368 	COMPREPLY=( $( compgen -W '-# -f -? -C -h -p -P -i -r -E -s -S -t -u \
       
  3369 					      -v -V -w' -- $cur ) )
       
  3370 
       
  3371 	COMPREPLY=( "${COMPREPLY[@]}" \
       
  3372 		    $( compgen -W 'create drop extended-status flush-hosts \
       
  3373 				   flush-logs flush-status flush-tables \
       
  3374 				   flush-threads flush-privileges kill \
       
  3375 				   password ping processlist reload refresh \
       
  3376 				   shutdown status variables version' \
       
  3377 		       -- $cur ) )
       
  3378 } &&
       
  3379 complete -F _mysqladmin mysqladmin
       
  3380 
       
  3381 # gzip(1) completion
       
  3382 #
       
  3383 have gzip &&
       
  3384 _gzip()
       
  3385 {
       
  3386 	local cur prev xspec IFS=$'\t\n'
       
  3387 
       
  3388 	COMPREPLY=()
       
  3389 	cur=`_get_cword`
       
  3390 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  3391 
       
  3392 	if [[ "$cur" == -* ]]; then
       
  3393 		COMPREPLY=( $( compgen -W '-c -d -f \
       
  3394 			-h -l -L -n -N -q -r -S -t -v -V \
       
  3395 			-1 -2 -3 -4 -5 -6 -7 -8 -9 \
       
  3396 			--stdout --decompress --force --help --list \
       
  3397 			--license --no-name --name --quiet --recursive \
       
  3398 			--suffix --test --verbose --version --fast \
       
  3399 			--best' -- $cur ) )
       
  3400 		return 0
       
  3401 	fi
       
  3402 
       
  3403 	xspec="*.?(t)gz"
       
  3404 	if [[ "$prev" == --* ]]; then
       
  3405 		[[ "$prev" == --decompress || \
       
  3406 			"$prev" == --list || \
       
  3407 			"$prev" == --test ]] && xspec="!"$xspec
       
  3408 		[[ "$prev" == --force ]] && xspec=
       
  3409 	elif [[ "$prev" == -* ]]; then
       
  3410 		[[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec
       
  3411 		[[ "$prev" == -*f* ]] && xspec=
       
  3412 	elif [ "$prev" = '>' ]; then
       
  3413 		xspec=
       
  3414 	elif [ "$prev" = '<' ]; then
       
  3415 		xspec=
       
  3416 	fi
       
  3417 
       
  3418 	_expand || return 0
       
  3419 
       
  3420 	COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
       
  3421 		    $( compgen -d -- $cur ) )
       
  3422 } &&
       
  3423 complete -F _gzip $filenames gzip
       
  3424 
       
  3425 # bzip2(1) completion
       
  3426 #
       
  3427 have bzip2 &&
       
  3428 _bzip2()
       
  3429 {
       
  3430 	local cur prev xspec IFS=$'\t\n'
       
  3431 
       
  3432 	COMPREPLY=()
       
  3433 	cur=`_get_cword`
       
  3434 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  3435 
       
  3436 	if [[ "$cur" == -* ]]; then
       
  3437 		COMPREPLY=( $( compgen -W '-c -d -f -h -k -L -q -s \
       
  3438 			-t -v -V -z -1 -2 -3 -4 -5 -6 -7 -8 -9 \
       
  3439 			--help --decompress --compress --keep --force \
       
  3440 			--test --stdout --quiet --verbose --license \
       
  3441 			--version --small --fast --best' -- $cur ) )
       
  3442 		return 0
       
  3443 	fi
       
  3444 
       
  3445 	xspec="*.bz2"
       
  3446 	if [[ "$prev" == --* ]]; then
       
  3447 		[[ "$prev" == --decompress || \
       
  3448 			"$prev" == --list || \
       
  3449 			"$prev" == --test ]] && xspec="!"$xspec
       
  3450 		[[ "$prev" == --compress ]] && xspec=
       
  3451 	elif [[ "$prev" == -* ]]; then
       
  3452 		[[ "$prev" == -*[dt]* ]] && xspec="!"$xspec
       
  3453 		[[ "$prev" == -*z* ]] && xspec=
       
  3454 	fi
       
  3455 
       
  3456 	_expand || return 0
       
  3457 
       
  3458 	COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
       
  3459 		    $( compgen -d -- $cur ) )
       
  3460 } &&
       
  3461 complete -F _bzip2 $filenames bzip2
       
  3462 
       
  3463 # openssl(1) completion
       
  3464 #
       
  3465 have openssl && {
       
  3466 _openssl_sections()
       
  3467 {
       
  3468 	local config
       
  3469 
       
  3470 	config=/etc/ssl/openssl.cnf
       
  3471 	[ ! -f $config ] && config=/usr/share/ssl/openssl.cnf
       
  3472 	for (( i=2; i < COMP_CWORD; i++ )); do
       
  3473 		if [[ "${COMP_WORDS[i]}" == -config ]]; then
       
  3474 			config=${COMP_WORDS[i+1]}
       
  3475 			break
       
  3476 		fi
       
  3477 	done
       
  3478 	[ ! -f $config ] && return 0
       
  3479 
       
  3480 	COMPREPLY=( $( awk '/\[.*\]/ {print $2} ' $config | grep "^$cur" ) )
       
  3481 }
       
  3482 
       
  3483 _openssl()
       
  3484 {
       
  3485 	local cur prev
       
  3486 
       
  3487 	COMPREPLY=()
       
  3488 	cur=`_get_cword`
       
  3489 
       
  3490 	if [ $COMP_CWORD -eq 1 ]; then
       
  3491 		COMPREPLY=( $( compgen -W 'asn1parse ca ciphers crl crl2pkcs7 \
       
  3492 			dgst dh dhparam dsa dsaparam enc errstr gendh gendsa \
       
  3493 			genrsa nseq passwd pkcs12 pkcs7 pkcs8 rand req rsa \
       
  3494 			rsautl s_client s_server s_time sess_id smime speed \
       
  3495 			spkac verify version x509 md2 md4 md5 mdc2 rmd160 sha \
       
  3496 			sha1 base64 bf bf-cbc bf-cfb bf-ecb bf-ofb cast \
       
  3497 			cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb des \
       
  3498 			des-cbc des-cfb des-ecb des-ede des-ede-cbc \
       
  3499 			des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc \
       
  3500 			des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 \
       
  3501 			rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb \
       
  3502 			rc4 rc4-40' -- $cur ) )
       
  3503 	else
       
  3504 		prev=${COMP_WORDS[COMP_CWORD-1]}
       
  3505 		case ${COMP_WORDS[1]} in
       
  3506 			asn1parse)
       
  3507 				case $prev in
       
  3508 					-inform)
       
  3509 						COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
       
  3510 						return 0
       
  3511 						;;
       
  3512 					-@(in|out|oid))
       
  3513 						_filedir
       
  3514 						return 0
       
  3515 						;;
       
  3516 					esac
       
  3517 
       
  3518 				if [[ "$cur" == -* ]]; then
       
  3519 					COMPREPLY=( $( compgen -W '-inform -in -out -noout -offset \
       
  3520 						-length -i -oid -strparse' -- $cur ) )
       
  3521 				fi
       
  3522 				;;
       
  3523 			ca)
       
  3524 				case $prev in
       
  3525 					-@(config|revoke|cert|in|out|spkac|ss_cert))
       
  3526 						_filedir
       
  3527 						return 0
       
  3528 						;;
       
  3529 					-outdir)
       
  3530 						_filedir -d
       
  3531 						return 0
       
  3532 						;;
       
  3533 					-@(name|crlexts|extensions))
       
  3534 						_openssl_sections
       
  3535 						return 0
       
  3536 						;;
       
  3537 				esac
       
  3538 
       
  3539 				if [[ "$cur" == -* ]]; then
       
  3540 					COMPREPLY=( $( compgen -W '-verbose -config -name \
       
  3541 						-gencrl -revoke -crldays -crlhours -crlexts \
       
  3542 						-startdate -enddate -days -md -policy -keyfile \
       
  3543 						-key -passin -cert -in -out -notext -outdir \
       
  3544 						-infiles -spkac -ss_cert -preserveDN -batch \
       
  3545 						-msie_hack -extensions' -- $cur ) )
       
  3546 				fi
       
  3547 				;;
       
  3548 			ciphers)
       
  3549 				if [[ "$cur" == -* ]]; then
       
  3550 					COMPREPLY=( $( compgen -W '-v -ssl2 -ssl3 -tls1' -- $cur ) )
       
  3551 				fi
       
  3552 				;;
       
  3553 			crl)
       
  3554 				case $prev in
       
  3555 					-@(in|out)form)
       
  3556 						COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
       
  3557 						return 0
       
  3558 						;;
       
  3559 					-@(in|out|CAfile))
       
  3560 						_filedir
       
  3561 						return 0
       
  3562 						;;
       
  3563 					-CAPath)
       
  3564 						_filedir -d
       
  3565 						return 0
       
  3566 						;;
       
  3567 				esac
       
  3568 
       
  3569 				if [[ "$cur" == -* ]]; then
       
  3570 					COMPREPLY=( $( compgen -W '-inform -outform -text -in -out -noout \
       
  3571 						-hash -issuer -lastupdate -nextupdate -CAfile -CApath' -- $cur ) )
       
  3572 				fi
       
  3573 				;;
       
  3574 			crl2pkcs7)
       
  3575 				case $prev in
       
  3576 					-@(in|out)form)
       
  3577 						COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
       
  3578 						return 0
       
  3579 						;;
       
  3580 					-@(in|out))
       
  3581 						_filedir
       
  3582 						return 0
       
  3583 						;;
       
  3584 				esac
       
  3585 
       
  3586 				if [[ "$cur" == -* ]]; then
       
  3587 					COMPREPLY=( $( compgen -W '-inform -outform -in -out -print_certs' -- $cur ) )
       
  3588 				fi
       
  3589 				;;
       
  3590 			dgst)
       
  3591 				case $prev in
       
  3592 					-@(out|sign|verify|prvrify|signature))
       
  3593 						_filedir
       
  3594 						return 0
       
  3595 						;;
       
  3596 				esac
       
  3597 
       
  3598 				if [[ "$cur" == -* ]]; then
       
  3599 					COMPREPLY=( $( compgen -W '-md5 -md4 -md2 -sha1 -sha -mdc2 -ripemd160 -dss1 \
       
  3600 						-c -d -hex -binary -out -sign -verify -prverify -signature' -- $cur ) )
       
  3601 				else
       
  3602 						_filedir
       
  3603 				fi
       
  3604 			       ;;
       
  3605 			dsa)
       
  3606 				case $prev in
       
  3607 					-@(in|out)form)
       
  3608 						COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
       
  3609 						return 0
       
  3610 						;;
       
  3611 					-@(in|out))
       
  3612 						_filedir
       
  3613 						return 0
       
  3614 						;;
       
  3615 				esac
       
  3616 
       
  3617 				if [[ "$cur" == -* ]]; then
       
  3618 					COMPREPLY=( $( compgen -W '-inform -outform -in -passin -out -passout -des -des3 -idea -text -noout \
       
  3619 						-modulus -pubin -pubout' -- $cur ) )
       
  3620 				fi
       
  3621 				;;
       
  3622 			dsaparam)
       
  3623 				case $prev in
       
  3624 					-@(in|out)form)
       
  3625 						COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
       
  3626 						return 0
       
  3627 						;;
       
  3628 					-@(in|out|rand))
       
  3629 						_filedir
       
  3630 						return 0
       
  3631 						;;
       
  3632 				esac
       
  3633 
       
  3634 				if [[ "$cur" == -* ]]; then
       
  3635 					COMPREPLY=( $( compgen -W '-inform -outform -in -out -noout \
       
  3636 						-text -C -rand -genkey' -- $cur ) )
       
  3637 				fi
       
  3638 				;;
       
  3639 			enc)
       
  3640 				case $prev in
       
  3641 					-@(in|out|kfile))
       
  3642 						_filedir
       
  3643 						return 0
       
  3644 						;;
       
  3645 				esac
       
  3646 
       
  3647 				if [[ "$cur" == -* ]]; then
       
  3648 					COMPREPLY=( $( compgen -W '-ciphername -in -out -pass \
       
  3649 						-e -d -a -A -k -kfile -S -K -iv -p -P -bufsize -debug' -- $cur ) )
       
  3650 				fi
       
  3651 				;;
       
  3652 			dhparam)
       
  3653 				case $prev in
       
  3654 					-@(in|out)form)
       
  3655 						COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
       
  3656 						return 0
       
  3657 						;;
       
  3658 					-@(in|out|rand))
       
  3659 						_filedir
       
  3660 						return 0
       
  3661 						;;
       
  3662 				esac
       
  3663 
       
  3664 				if [[ "$cur" == -* ]]; then
       
  3665 					COMPREPLY=( $( compgen -W '-inform -outform -in -out -dsaparam -noout \
       
  3666 						-text -C -2 -5 -rand' -- $cur ) )
       
  3667 				fi
       
  3668 				;;
       
  3669 			gendsa)
       
  3670 				case $prev in
       
  3671 					-@(out|rand))
       
  3672 						_filedir
       
  3673 						return 0
       
  3674 						;;
       
  3675 				esac
       
  3676 
       
  3677 				if [[ "$cur" == -* ]]; then
       
  3678 					COMPREPLY=( $( compgen -W '-out -des -des3 -idea -rand' -- $cur ) )
       
  3679 				else
       
  3680 						_filedir
       
  3681 				fi
       
  3682 				;;
       
  3683 			genrsa)
       
  3684 				case $prev in
       
  3685 					-@(out|rand))
       
  3686 						_filedir
       
  3687 						return 0
       
  3688 						;;
       
  3689 				esac
       
  3690 
       
  3691 				if [[ "$cur" == -* ]]; then
       
  3692 					COMPREPLY=( $( compgen -W '-out -passout -des -des3 -idea -f4 -3 -rand' -- $cur ) )
       
  3693 				fi
       
  3694 				;;
       
  3695 			pkcs7)
       
  3696 				case $prev in
       
  3697 					-@(in|out)form)
       
  3698 						COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
       
  3699 						return 0
       
  3700 						;;
       
  3701 					-@(in|out))
       
  3702 						_filedir
       
  3703 						return 0
       
  3704 						;;
       
  3705 				esac
       
  3706 
       
  3707 				if [[ "$cur" == -* ]]; then
       
  3708 					COMPREPLY=( $( compgen -W '-inform -outform -in -out -print_certs -text -noout' -- $cur ) )
       
  3709 				fi
       
  3710 				;;
       
  3711 			rand)
       
  3712 				case $prev in
       
  3713 					-@(out|rand))
       
  3714 						_filedir
       
  3715 						return 0
       
  3716 						;;
       
  3717 				esac
       
  3718 
       
  3719 				if [[ "$cur" == -* ]]; then
       
  3720 					COMPREPLY=( $( compgen -W '-out -rand -base64' -- $cur ) )
       
  3721 				fi
       
  3722 				;;
       
  3723 			req)
       
  3724 				case "$prev" in
       
  3725 					-@(in|out|key)form)
       
  3726 						COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
       
  3727 						return 0
       
  3728 						;;
       
  3729 
       
  3730 					-@(in|out|rand|key|keyout|config))
       
  3731 						_filedir
       
  3732 						return 0
       
  3733 						;;
       
  3734 					-extensions)
       
  3735 						_openssl_sections
       
  3736 						return 0
       
  3737 						;;
       
  3738 				esac
       
  3739 
       
  3740 				if [[ "$cur" == -* ]]; then
       
  3741 					COMPREPLY=( $( compgen -W '-inform -outform -in \
       
  3742 						-passin -out -passout -text -noout -verify \
       
  3743 						-modulus -new -rand -newkey -newkey -nodes \
       
  3744 						-key -keyform -keyout -md5 -sha1 -md2 -mdc2 \
       
  3745 						-config -x509 -days -asn1-kludge -newhdr \
       
  3746 						-extensions -reqexts section' -- $cur ) )
       
  3747 				fi
       
  3748 				;;
       
  3749 			rsa)
       
  3750 				case $prev in
       
  3751 					-@(in|out)form)
       
  3752 						COMPREPLY=( $( compgen -W 'DER NET PEM' -- $cur ) )
       
  3753 						return 0
       
  3754 						;;
       
  3755 					-@(in|out))
       
  3756 						_filedir
       
  3757 						return 0
       
  3758 						;;
       
  3759 				esac
       
  3760 
       
  3761 				if [[ "$cur" == -* ]]; then
       
  3762 					COMPREPLY=( $( compgen -W '-inform -outform -in -passin -out -passout \
       
  3763 						-sgckey -des -des3 -idea -text -noout -modulus -check -pubin \
       
  3764 						-pubout -engine' -- $cur ) )
       
  3765 				fi
       
  3766 				;;
       
  3767 			rsautl)
       
  3768 				case $prev in
       
  3769 					-@(in|out|inkey))
       
  3770 						_filedir
       
  3771 						return 0
       
  3772 						;;
       
  3773 				esac
       
  3774 
       
  3775 				if [[ "$cur" == -* ]]; then
       
  3776 					COMPREPLY=( $( compgen -W '-in -out -inkey -pubin -certin -sign -verify \
       
  3777 						-encrypt -decrypt -pkcs -ssl -raw -hexdump -asn1parse' -- $cur ) )
       
  3778 				fi
       
  3779 				;;
       
  3780 			s_client)
       
  3781 				case $prev in
       
  3782 					-connect)
       
  3783 						_known_hosts
       
  3784 						return 0
       
  3785 						;;
       
  3786 					-@(cert|key|CAfile|rand))
       
  3787 						_filedir
       
  3788 						return 0
       
  3789 						;;
       
  3790 					-CApath)
       
  3791 						_filedir -d
       
  3792 						return 0
       
  3793 						;;
       
  3794 				esac
       
  3795 
       
  3796 				if [[ "$cur" == -* ]]; then
       
  3797 					COMPREPLY=( $( compgen -W '-connect -verify -cert -key -CApath -CAfile \
       
  3798 						-reconnect -pause -showcerts -debug -msg -nbio_test -state -nbio \
       
  3799 						-crlf -ign_eof -quiet -ssl2 -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 \
       
  3800 						-bugs -cipher -starttls -engine -rand' -- $cur ) )
       
  3801 				fi
       
  3802 				;;
       
  3803 			s_server)
       
  3804 				case $prev in
       
  3805 					-@(cert|key|dcert|dkey|dhparam|CAfile|rand))
       
  3806 						_filedir
       
  3807 						return 0
       
  3808 						;;
       
  3809 					-CApath)
       
  3810 						_filedir -d
       
  3811 						return 0
       
  3812 						;;
       
  3813 				esac
       
  3814 
       
  3815 				if [[ "$cur" == -* ]]; then
       
  3816 					COMPREPLY=( $( compgen -W '-accept -context -verify -Verify -cert -key \
       
  3817 						 -dcert -dkey -dhparam -nbio -nbio_test -crlf -debug -msg -state -CApath \
       
  3818 						 -CAfile -nocert -cipher -quiet -no_tmp_rsa -ssl2 -ssl3 -tls1 -no_ssl2 \
       
  3819 						 -no_ssl3 -no_tls1 -no_dhe -bugs -hack -www -WWW -HTTP -engine -id_prefix \
       
  3820 						 -rand' -- $cur ) )
       
  3821 				 fi
       
  3822 				 ;;
       
  3823 			s_time)
       
  3824 				case $prev in
       
  3825 					-connect)
       
  3826 						_known_hosts
       
  3827 						return 0
       
  3828 						;;
       
  3829 					-@(cert|key|CAfile))
       
  3830 						_filedir
       
  3831 						return 0
       
  3832 						;;
       
  3833 					-CApath)
       
  3834 						_filedir -d
       
  3835 						return 0
       
  3836 						;;
       
  3837 				esac
       
  3838 
       
  3839 				if [[ "$cur" == -* ]]; then
       
  3840 					COMPREPLY=( $( compgen -W '-connect -www -cert -key -CApath -CAfile -reuse \
       
  3841 						-new -verify -nbio -time -ssl2 -ssl3 -bugs -cipher' -- $cur ) )
       
  3842 				fi
       
  3843 				;;
       
  3844 
       
  3845 			sess_id) 
       
  3846 				case $prev in
       
  3847 					-@(in|out)form)
       
  3848 						COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
       
  3849 						return 0
       
  3850 						;;
       
  3851 					-@(in|out))
       
  3852 						_filedir
       
  3853 						return 0
       
  3854 						;;
       
  3855 				esac
       
  3856 
       
  3857 
       
  3858 				if [[ "$cur" == -* ]]; then
       
  3859 					COMPREPLY=( $( compgen -W '-inform -outform -in -out -text -noout \
       
  3860 						-context ID' -- $cur ) )
       
  3861 				fi
       
  3862 				;;
       
  3863 			smime)
       
  3864 				case $prev in
       
  3865 					-@(in|out)form)
       
  3866 						COMPREPLY=( $( compgen -W 'SMIME DER PEM' -- $cur ) )
       
  3867 						return 0
       
  3868 						;;
       
  3869 					-@(in|out|certfile|signer|recip|inkey|content|rand))
       
  3870 						_filedir
       
  3871 						return 0
       
  3872 						;;
       
  3873 				esac
       
  3874 
       
  3875 				if [[ "$cur" == -* ]]; then
       
  3876 					COMPREPLY=( $( compgen -W '-encrypt -decrypt -sign -verify -pk7out -des -des3 \
       
  3877 						-rc2-40 -rc2-64 -rc2-128 -aes128 -aes192 -aes256 -in -certfile -signer \
       
  3878 						-recip -inform -passin -inkey -out -outform -content -to -from -subject \
       
  3879 						-text -rand' -- $cur ) )
       
  3880 				else
       
  3881 						_filedir
       
  3882 				fi
       
  3883 				;;
       
  3884 			speed)
       
  3885 				if [[ "$cur" == -* ]]; then
       
  3886 					COMPREPLY=( $( compgen -W '-engine' -- $cur ) )
       
  3887 				else
       
  3888 					COMPREPLY=( $( compgen -W 'md2 mdc2 md5 hmac sha1 rmd160 idea-cbc \
       
  3889 						rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4 rsa512 rsa1024 rsa2048 \
       
  3890 						rsa4096 dsa512 dsa1024 dsa2048 idea rc2 des rsa blowfish' -- $cur ) )
       
  3891 				fi
       
  3892 				;;
       
  3893 			verify)
       
  3894 				case $prev in
       
  3895 					-@(CAfile|untrusted))
       
  3896 						_filedir
       
  3897 						return 0
       
  3898 						;;
       
  3899 					-CApath)
       
  3900 						_filedir -d
       
  3901 						return 0
       
  3902 						;;
       
  3903 				esac
       
  3904 
       
  3905 				if [[ "$cur" == -* ]]; then
       
  3906 					COMPREPLY=( $( compgen -W '-CApath -CAfile -purpose -untrusted -help -issuer_checks \
       
  3907 						-verbose -certificates' -- $cur ) )
       
  3908 				else
       
  3909 						_filedir
       
  3910 				fi
       
  3911 				;;
       
  3912 			x509)
       
  3913 				case "$prev" in
       
  3914 					-@(in|out|CA|CAkey|CAserial|extfile))
       
  3915 						_filedir
       
  3916 						return 0
       
  3917 						;;
       
  3918 					-@(in|out)form)
       
  3919 						COMPREPLY=( $( compgen -W 'DER PEM NET' -- $cur ) )
       
  3920 						return 0
       
  3921 						;;
       
  3922 					-@(key|CA|CAkey)form)
       
  3923 						COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
       
  3924 						return 0
       
  3925 						;;
       
  3926 					-extensions)
       
  3927 						_openssl_sections
       
  3928 						return 0
       
  3929 						;;
       
  3930 				esac
       
  3931 
       
  3932 				if [[ "$cur" == -* ]]; then
       
  3933 					COMPREPLY=( $( compgen -W '-inform -outform \
       
  3934 						-keyform -CAform -CAkeyform -in -out \
       
  3935 						-serial -hash -subject -issuer -nameopt \
       
  3936 						-email -startdate -enddate -purpose \
       
  3937 						-dates -modulus -fingerprint -alias \
       
  3938 						-noout -trustout -clrtrust -clrreject \
       
  3939 						-addtrust -addreject -setalias -days \
       
  3940 						-set_serial -signkey -x509toreq -req \
       
  3941 						-CA -CAkey -CAcreateserial -CAserial \
       
  3942 						-text -C -md2 -md5 -sha1 -mdc2 -clrext \
       
  3943 						-extfile -extensions -engine' -- $cur ) )
       
  3944 				fi
       
  3945 				;;
       
  3946 			@(md5|md4|md2|sha1|sha|mdc2|ripemd160))
       
  3947 				if [[ "$cur" == -* ]]; then
       
  3948 					COMPREPLY=( $( compgen -W '-c -d' -- $cur ) )
       
  3949 				else
       
  3950 						_filedir
       
  3951 				fi
       
  3952 				;;
       
  3953 		esac
       
  3954 	fi
       
  3955 
       
  3956 	return 0
       
  3957 }
       
  3958 complete -F _openssl $default openssl
       
  3959 }
       
  3960 
       
  3961 # screen(1) completion
       
  3962 #
       
  3963 have screen &&
       
  3964 _screen()
       
  3965 {
       
  3966 	local cur prev preprev
       
  3967 
       
  3968 	COMPREPLY=()
       
  3969 	cur=`_get_cword`
       
  3970 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  3971 
       
  3972 	[ "$COMP_CWORD" -ge 2 ] && preprev=${COMP_WORDS[COMP_CWORD-2]}
       
  3973 
       
  3974 	if [ "$preprev" = "-d" -o "$preprev" = "-D" -a "$prev" = "-r" -o \
       
  3975 	     "$prev" = "-R" ]; then
       
  3976 		# list all
       
  3977 		COMPREPLY=( $( command screen -ls | \
       
  3978 				sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*$|\1|p' ) )
       
  3979 	else
       
  3980 		case "$prev" in
       
  3981 		-[rR])
       
  3982 			# list detached
       
  3983 			COMPREPLY=( $( command screen -ls | \
       
  3984 					sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*Detached.*$|\1|p' ) )
       
  3985 			;;
       
  3986 		-[dDx])
       
  3987 			# list attached
       
  3988 			COMPREPLY=( $( command screen -ls | \
       
  3989 					sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*Attached.*$|\1|p' ) )
       
  3990 			;;
       
  3991 		-s)
       
  3992 			# shells
       
  3993 			COMPREPLY=( $( grep ^${cur:-[^#]} /etc/shells ) )
       
  3994 			;;
       
  3995 		*)
       
  3996 			;;
       
  3997 		esac
       
  3998 	fi
       
  3999 
       
  4000 	return 0
       
  4001 } &&
       
  4002 complete -F _screen $default screen
       
  4003 
       
  4004 # lftp(1) bookmark completion
       
  4005 #
       
  4006 have lftp &&
       
  4007 _lftp()
       
  4008 {
       
  4009 	local cur
       
  4010 
       
  4011 	COMPREPLY=()
       
  4012 	cur=`_get_cword`
       
  4013 
       
  4014 	if [ $COMP_CWORD -eq 1 ] && [ -f ~/.lftp/bookmarks ]; then
       
  4015 	    COMPREPLY=( $( compgen -W '$( sed -ne "s/^\(.*\)'$'\t''.*$/\1/p" \
       
  4016 			   ~/.lftp/bookmarks )' -- $cur ) )
       
  4017 	fi
       
  4018 
       
  4019 	return 0
       
  4020 } &&
       
  4021 complete -F _lftp $default lftp
       
  4022 
       
  4023 # ncftp(1) bookmark completion
       
  4024 #
       
  4025 have ncftp &&
       
  4026 _ncftp()
       
  4027 {
       
  4028 	local cur
       
  4029 
       
  4030 	COMPREPLY=()
       
  4031 	cur=`_get_cword`
       
  4032 
       
  4033 	if [ $COMP_CWORD -eq 1 ] && [ -f ~/.ncftp/bookmarks ]; then
       
  4034 	    COMPREPLY=( $( compgen -W '$( sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \
       
  4035 			   ~/.ncftp/bookmarks )' -- $cur ) )
       
  4036 	fi
       
  4037 
       
  4038 	return 0
       
  4039 } &&
       
  4040 complete -F _ncftp $default ncftp
       
  4041 
       
  4042 # gdb(1) completion
       
  4043 #
       
  4044 have gdb &&
       
  4045 _gdb()
       
  4046 {
       
  4047 	local cur prev
       
  4048 
       
  4049 	COMPREPLY=()
       
  4050 	cur=`_get_cword`
       
  4051 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4052 
       
  4053 	if [ $COMP_CWORD -eq 1 ]; then
       
  4054 		COMPREPLY=( $( compgen -c -- $cur ) )
       
  4055 	elif [ $COMP_CWORD -eq 2 ]; then
       
  4056 		prev=${prev##*/}
       
  4057 		COMPREPLY=( $( compgen -fW "$( command ps axo comm,pid | \
       
  4058 				awk '{if ($1 ~ /^'"$prev"'/) print $2}' ) )" \
       
  4059 				-- "$cur" ) )
       
  4060 	fi
       
  4061 } &&
       
  4062 complete -F _gdb $filenames gdb
       
  4063 
       
  4064 # Postgresql completion
       
  4065 #
       
  4066 have psql && {
       
  4067 _pg_databases() 
       
  4068 {
       
  4069 	return
       
  4070 	COMPREPLY=( $( psql -l 2>/dev/null | \
       
  4071 			sed -e '1,/^-/d' -e '/^(/,$d' | \
       
  4072 			awk '{print $1}' | grep "^$cur" ) )
       
  4073 }
       
  4074 
       
  4075 _pg_users()
       
  4076 {
       
  4077 	#COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
       
  4078 	#		grep "^ $cur" ) )
       
  4079 	#[ ${#COMPREPLY[@]} -eq 0 ] &&
       
  4080 	COMPREPLY=( $( compgen -u -- $cur ) )
       
  4081 }
       
  4082 
       
  4083 # createdb(1) completion
       
  4084 #
       
  4085 _createdb() 
       
  4086 {
       
  4087 	local cur prev
       
  4088 
       
  4089 	COMPREPLY=()
       
  4090 	cur=`_get_cword`
       
  4091 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4092 
       
  4093 	case "$prev" in
       
  4094 	-@(h|-host=)) 
       
  4095 		_known_hosts
       
  4096 		return 0
       
  4097 		;;
       
  4098 	-@(U|-username=))
       
  4099 		_pg_users
       
  4100 		return 0
       
  4101 		;;
       
  4102 	esac
       
  4103 
       
  4104 	if [[ "$cur" == -* ]]; then
       
  4105 		COMPREPLY=( $( compgen -W '-D -T -E -h -p -U -W -e -q \
       
  4106 			--location= --template= --encoding= --host= --port= \
       
  4107 			--username= --password --echo --quiet --help' -- $cur ))
       
  4108 	else
       
  4109 		_pg_databases
       
  4110 	fi
       
  4111 }
       
  4112 complete -F _createdb $default createdb
       
  4113 
       
  4114 # dropdb(1) completion
       
  4115 #
       
  4116 _dropdb() 
       
  4117 {
       
  4118 	local cur prev
       
  4119 
       
  4120 	COMPREPLY=()
       
  4121 	cur=`_get_cword`
       
  4122 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4123 
       
  4124 	case "$prev" in
       
  4125 	-@(h|-host=)) 
       
  4126 		_known_hosts
       
  4127 		return 0
       
  4128 		;;
       
  4129 	-@(U|-username=))
       
  4130 		_pg_users
       
  4131 		return 0
       
  4132 		;;
       
  4133 	esac
       
  4134 
       
  4135 	if [[ "$cur" == -* ]]; then
       
  4136 		COMPREPLY=( $( compgen -W '-h -p -U -W -e -q \
       
  4137 				--host= --port= --username= --password \
       
  4138 				--interactive --echo --quiet --help' -- $cur ) )
       
  4139 	else
       
  4140 		_pg_databases
       
  4141 	fi
       
  4142 }
       
  4143 complete -F _dropdb $default dropdb
       
  4144 
       
  4145 # psql(1) completion
       
  4146 #
       
  4147 _psql() 
       
  4148 {
       
  4149 	local cur prev
       
  4150 
       
  4151 	COMPREPLY=()
       
  4152 	cur=`_get_cword`
       
  4153 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4154 
       
  4155 	case "$prev" in
       
  4156 	-h|--host) 
       
  4157 		_known_hosts
       
  4158 		return 0
       
  4159 		;;
       
  4160 	-U|--username)
       
  4161 		_pg_users
       
  4162 		return 0
       
  4163 		;;
       
  4164 	-d|--dbname)
       
  4165 		_pg_databases
       
  4166 		return 0
       
  4167 		;;
       
  4168 	-@(o|f)|--output|--file)
       
  4169 		_filedir
       
  4170 		return 0
       
  4171 		;;
       
  4172 	esac
       
  4173 
       
  4174 	if [[ "$cur" == -* ]]; then
       
  4175 		# return list of available options
       
  4176 		COMPREPLY=( $( compgen -W '-a --echo-all -A --no-align \
       
  4177 			-c --command -d --dbname -e --echo-queries \
       
  4178 			-E --echo-hidden -f --file -F --filed-separator \
       
  4179 			-h --host -H --html -l --list -n -o --output \
       
  4180 			-p --port -P --pset -q -R --record-separator \
       
  4181 			-s --single-step -S --single-line -t --tuples-only \
       
  4182 			-T --table-attr -U --username -v --variable \
       
  4183 			-V --version -W --password -x --expanded -X --nopsqlrc \
       
  4184 			-? --help ' -- $cur ) )
       
  4185 	else
       
  4186 		# return list of available databases
       
  4187 		_pg_databases
       
  4188 	fi
       
  4189 }
       
  4190 complete -F _psql $default psql
       
  4191 }
       
  4192 
       
  4193 _longopt()
       
  4194 {
       
  4195 	local cur opt
       
  4196 
       
  4197 	cur=`_get_cword`
       
  4198 
       
  4199 	if [[ "$cur" == --*=* ]]; then
       
  4200 		opt=${cur%%=*}
       
  4201 		# cut backslash that gets inserted before '=' sign
       
  4202 		opt=${opt%\\*}
       
  4203 		cur=${cur#*=}
       
  4204 		_filedir
       
  4205 		COMPREPLY=( $( compgen -P "$opt=" -W '${COMPREPLY[@]}' -- $cur))
       
  4206 		return 0
       
  4207 	fi
       
  4208 
       
  4209 	if [[ "$cur" == -* ]]; then
       
  4210 		COMPREPLY=( $( $1 --help 2>&1 | sed -e '/--/!d' \
       
  4211 				-e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | \
       
  4212 			       command grep "^$cur" | sort -u ) )
       
  4213 	elif [[ "$1" == @(mk|rm)dir ]]; then
       
  4214 		_filedir -d
       
  4215 	else
       
  4216 		_filedir
       
  4217 	fi
       
  4218 }
       
  4219 # makeinfo and texi2dvi are defined elsewhere.
       
  4220 for i in a2ps autoconf automake bc gprof ld nm objcopy objdump readelf strip \
       
  4221 	 bison cpio diff patch enscript cp df dir du ln ls mkfifo mknod mv rm \
       
  4222 	 touch vdir awk gperf grep grub indent less m4 sed shar date \
       
  4223 	 tee who texindex cat csplit cut expand fmt fold head \
       
  4224 	 md5sum nl od paste pr ptx sha1sum sort split tac tail tr unexpand \
       
  4225 	 uniq wc ldd bash id irb mkdir rmdir; do
       
  4226   have $i && complete -F _longopt $filenames $i
       
  4227 done
       
  4228 
       
  4229 # These commands use filenames, so '-o filenames' is not needed.
       
  4230 for i in env netstat seq uname units wget; do
       
  4231   have $i && complete -F _longopt $default $i
       
  4232 done
       
  4233 unset i
       
  4234 
       
  4235 # gcc(1) completion
       
  4236 #
       
  4237 # The only unusual feature is that we don't parse "gcc --help -v" output
       
  4238 # directly, because that would include the options of all the other backend
       
  4239 # tools (linker, assembler, preprocessor, etc) without any indication that
       
  4240 # you cannot feed such options to the gcc driver directly.  (For example, the
       
  4241 # linker takes a -z option, but you must type -Wl,-z for gcc.)  Instead, we
       
  4242 # ask the driver ("g++") for the name of the compiler ("cc1"), and parse the
       
  4243 # --help output of the compiler.
       
  4244 #
       
  4245 have gcc &&
       
  4246 _gcc()
       
  4247 {
       
  4248 	local cur cc backend
       
  4249 
       
  4250 	COMPREPLY=()
       
  4251 	cur=`_get_cword`
       
  4252 
       
  4253 	_expand || return 0
       
  4254 
       
  4255 	case "$1" in
       
  4256 	gcj)
       
  4257 		backend=jc1
       
  4258 		;;
       
  4259 	gpc)
       
  4260 		backend=gpc1
       
  4261 		;;
       
  4262 	*77)
       
  4263 		backend=f771
       
  4264 		;;
       
  4265 	*)
       
  4266 		backend=cc1	# (near-)universal backend
       
  4267 		;;
       
  4268 	esac
       
  4269 
       
  4270 	if [[ "$cur" == -* ]]; then
       
  4271 		cc=$( $1 -print-prog-name=$backend )
       
  4272 		# sink stderr:
       
  4273 		# for C/C++/ObjectiveC it's useless
       
  4274 		# for FORTRAN/Java it's an error
       
  4275 		COMPREPLY=( $( $cc --help 2>/dev/null | tr '\t' ' ' | \
       
  4276 			       sed -e '/^  *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | \
       
  4277 			       command grep "^$cur" | sort -u ) )
       
  4278 	else
       
  4279 		_filedir
       
  4280 	fi
       
  4281 } &&
       
  4282 complete $filenames -F _gcc gcc g++ c++ g77 gcj gpc
       
  4283 [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Cygwin ] && \
       
  4284 [ -n "${have:-}" ] && complete $filenames -F _gcc cc
       
  4285 
       
  4286 # Linux cardctl(8) completion
       
  4287 #
       
  4288 have cardctl &&
       
  4289 _cardctl()
       
  4290 {
       
  4291 	local cur
       
  4292 
       
  4293 	COMPREPLY=()
       
  4294 	cur=`_get_cword`
       
  4295 
       
  4296 	if [ $COMP_CWORD -eq 1 ]; then
       
  4297 		COMPREPLY=( $( compgen -W 'status config ident suspend \
       
  4298 					   resume reset eject insert scheme' \
       
  4299 			       -- $cur ) )
       
  4300 	fi
       
  4301 } &&
       
  4302 complete -F _cardctl cardctl
       
  4303 
       
  4304 # This function is required by _dpkg() and _dpkg-reconfigure()
       
  4305 #
       
  4306 have dpkg && {
       
  4307 _comp_dpkg_installed_packages()
       
  4308 {
       
  4309 	grep -A 1 "Package: $1" /var/lib/dpkg/status | \
       
  4310 		grep -B 1 -E "ok installed|half-installed|unpacked| \
       
  4311        			      half-configured|config-files" | \
       
  4312 	        grep "Package: $1" | cut -d\  -f2
       
  4313 }
       
  4314 
       
  4315 # Debian dpkg(8) completion
       
  4316 #
       
  4317 _dpkg()
       
  4318 {
       
  4319 	local cur prev i
       
  4320 
       
  4321 	COMPREPLY=()
       
  4322 	cur=`_get_cword`
       
  4323 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4324 	i=$COMP_CWORD
       
  4325 
       
  4326 	_expand || return 0
       
  4327 
       
  4328 	# find the last option flag
       
  4329 	if [[ $cur != -* ]]; then
       
  4330 		while [[ $prev != -* && $i != 1 ]]; do
       
  4331 			i=$((i-1))
       
  4332 			prev=${COMP_WORDS[i-1]}
       
  4333 		done
       
  4334 	fi
       
  4335 
       
  4336 	case "$prev" in 
       
  4337 	-@(c|i|A|I|f|e|x|X|-@(install|unpack|record-avail|contents|info|fsys-tarfile|field|control|extract)))
       
  4338 		_filedir '?(u)deb'
       
  4339 		return 0
       
  4340 		;;
       
  4341 	-@(b|-build))
       
  4342 		_filedir -d
       
  4343 		return 0
       
  4344 		;;
       
  4345    	-@(s|p|l|-@(status|print-avail|list)))
       
  4346 		COMPREPLY=( $( apt-cache pkgnames $cur 2>/dev/null ) )
       
  4347 		return 0
       
  4348 		;;
       
  4349 	-@(S|-search))
       
  4350 		_filedir
       
  4351 		return 0
       
  4352 		;;
       
  4353 	-@(r|L|P|-@(remove|purge|listfiles)))
       
  4354 		COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
       
  4355 		return 0
       
  4356 		;;
       
  4357 	*)
       
  4358 
       
  4359 	COMPREPLY=( $( compgen -W '-i --install --unpack -A --record-avail \
       
  4360 			--configure -r --remove -P --purge --get-selections \
       
  4361 			--set-selections --update-avail --merge-avail \
       
  4362 			--clear-avail  --command-fd --forget-old-unavail -s \
       
  4363 			--status -p --print-avail -L --listfiles -l --list \
       
  4364 			-S --search -C --audit --print-architecture \
       
  4365 			--print-gnu-build-architecture \
       
  4366 			--print-installation-architecture \
       
  4367 			--compare-versions --help --version --force-help \
       
  4368 			--force-all --force-auto-select --force-downgrade \
       
  4369 			--force-configure-any --force-hold --force-bad-path \
       
  4370 			--force-not-root --force-overwrite \
       
  4371 			--force-overwrite-diverted --force-bad-verify \
       
  4372 			--force-depends-version --force-depends \
       
  4373 			--force-confnew --force-confold --force-confdef \
       
  4374 			--force-confmiss --force-conflicts --force-architecture\
       
  4375 			--force-overwrite-dir --force-remove-reinstreq \
       
  4376 			--force-remove-essential -Dh \
       
  4377 			--debug=help --licence --admindir= --root= --instdir= \
       
  4378 			-O --selected-only -E --skip-same-version \
       
  4379 			-G --refuse-downgrade -B --auto-deconfigure \
       
  4380 			--no-debsig --no-act -D --debug= --status-fd \
       
  4381 			-b --build -I --info -f --field -c --contents \
       
  4382 			-x --extract -X --vextract --fsys-tarfile -e --control \
       
  4383 			--ignore-depends= --abort-after' -- $cur ) )
       
  4384 		;;
       
  4385 	esac
       
  4386 
       
  4387 
       
  4388 }
       
  4389 complete -F _dpkg $filenames dpkg dpkg-deb
       
  4390 }
       
  4391 
       
  4392 # Debian GNU dpkg-reconfigure(8) completion
       
  4393 #
       
  4394 have dpkg-reconfigure &&
       
  4395 _dpkg_reconfigure()
       
  4396 {
       
  4397 	local cur prev opt
       
  4398 
       
  4399 	COMPREPLY=()
       
  4400 	cur=`_get_cword`
       
  4401 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4402 
       
  4403 
       
  4404 	case "$prev" in
       
  4405 	    -@(f|-frontend))
       
  4406 		opt=( $( echo /usr/share/perl5/Debconf/FrontEnd/* ) )
       
  4407 		opt=( ${opt[@]##*/} )
       
  4408 		opt=( ${opt[@]%.pm} )
       
  4409 		COMPREPLY=( $( compgen -W '${opt[@]}' -- $cur ) )
       
  4410 		return 0
       
  4411 		;;
       
  4412 	    -@(p|-priority))
       
  4413   		COMPREPLY=( $( compgen -W 'low medium high critical' -- $cur ) )
       
  4414 		return 0
       
  4415 		;;
       
  4416 	esac
       
  4417 
       
  4418 	if [[ "$cur" == -* ]]; then
       
  4419 	    COMPREPLY=( $( compgen -W '-f --frontend -p --priority -a --all \
       
  4420 				       -u --unseen-only -h --help -s --showold \
       
  4421 				       --force --terse' -- $cur ) )
       
  4422 	else
       
  4423 	    COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
       
  4424 	fi
       
  4425 } &&
       
  4426 complete -F _dpkg_reconfigure $default dpkg-reconfigure
       
  4427 
       
  4428 # Debian dpkg-source completion
       
  4429 #
       
  4430 have dpkg-source &&
       
  4431 _dpkg_source()
       
  4432 {
       
  4433 	local cur prev options work i action packopts unpackopts
       
  4434 
       
  4435 	packopts="-c -l -F -V -T -D -U -W -E -sa -i -I -sk -sp -su -sr -ss -sn -sA -sK -sP -sU -sR"
       
  4436 	unpackopts="-sp -sn -su"
       
  4437 	options=`echo "-x -b $packopts $unpackopts" | xargs echo | sort -u | xargs echo`
       
  4438 
       
  4439 	COMPREPLY=()
       
  4440 	if [ "$1" != "dpkg-source" ]; then
       
  4441 		exit 1
       
  4442 	fi
       
  4443 	cur=`_get_cword`
       
  4444 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4445 	action="options"
       
  4446 	for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
       
  4447 		if [[ ${COMP_WORDS[$i]} == "-x" ]]; then
       
  4448 			action=unpack
       
  4449 		elif [[ ${COMP_WORDS[$i]} == "-b" ]]; then
       
  4450 			action=pack
       
  4451 		elif [[ ${COMP_WORDS[$i]} == "-h" ]]; then
       
  4452 			action=help
       
  4453 		fi
       
  4454 	done
       
  4455 	# if currently seeing a complete option, return just itself.
       
  4456 	for i in $options; do
       
  4457 		if [ "$cur" = "$i" ]; then
       
  4458 			COMPREPLY=( "$cur" )
       
  4459 			return 0
       
  4460 		fi
       
  4461 	done
       
  4462 	case "$action" in
       
  4463 		"unpack")
       
  4464 			if [ "$cur" = "-" -o "$cur" = "-s" ]; then
       
  4465 				COMPREPLY=( $unpackots )
       
  4466 				return 0
       
  4467 			fi
       
  4468 			case "$prev" in
       
  4469 				"-x")
       
  4470 					COMPREPLY=( $( compgen -d -- "$cur" ) \
       
  4471 						    $( compgen -f -X '!*.dsc' -- "$cur" ) )
       
  4472 					return 0
       
  4473 					;;
       
  4474 				*)
       
  4475 					COMPREPLY=( $unpackopts $(compgen -d -f -- "$cur" ) )
       
  4476 					return 0
       
  4477 					;;
       
  4478 			esac
       
  4479 			return 0
       
  4480 			;;
       
  4481 		"pack")
       
  4482 			if [ "$cur" = "-" ]; then
       
  4483 				COMPREPLY=( $packopts )
       
  4484 				return 0
       
  4485 			fi
       
  4486 			if [ "$cur" = "-s" ]; then
       
  4487 				COMPREPLY=( "-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" \
       
  4488 			    		"-sA" "-sK" "-sP" "-sU" "-sR" )
       
  4489 				return 0
       
  4490 			fi
       
  4491 			case "$prev" in
       
  4492 				"-b")
       
  4493 					COMPREPLY=( $( compgen -d -- "$cur" ) )
       
  4494 					return 0
       
  4495 					;;
       
  4496 				"-c"|"-l"|"-T"|"-i"|"-I")
       
  4497 					# -c: get controlfile
       
  4498 					# -l: get per-version info from this file
       
  4499 					# -T: read variables here, not debian/substvars
       
  4500 					# -i: <regexp> filter out files to ignore diffs of.
       
  4501 					# -I: filter out files when building tarballs.
       
  4502 					# return directory names and file names
       
  4503 					COMPREPLY=( $( compgen -d -f ) )
       
  4504 					return 0
       
  4505 					;;
       
  4506 				"-F")
       
  4507 					# -F: force change log format
       
  4508 					COMPREPLY=( $( ( cd /usr/lib/dpkg/parsechangelog; compgen -f "$cur" ) ) )
       
  4509 					return 0
       
  4510 					;;
       
  4511 				"-V"|"-D")
       
  4512 					# -V: set a substitution variable
       
  4513 					# we don't know anything about possible variables or values
       
  4514 					# so we don't try to suggest any completion.
       
  4515 					COMPREPLY=()
       
  4516 					return 0
       
  4517 					;;
       
  4518 				"-D")
       
  4519 					# -D: override or add a .dsc field and value
       
  4520 					# if $cur doesn't contain a = yet, suggest variable names
       
  4521 					if echo -- "$cur" | grep -q "="; then
       
  4522 						# $cur contains a "="
       
  4523 						COMPREPLY=()
       
  4524 						return 0
       
  4525 					else
       
  4526 						COMPREPLY=( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files )
       
  4527 						return 0
       
  4528 					fi
       
  4529 					;;
       
  4530 				"-U")
       
  4531 					# -U: remove a field
       
  4532 					# Suggest possible fieldnames
       
  4533 					COMPREPLY=( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files )
       
  4534 					return 0
       
  4535 					;;
       
  4536 				*)
       
  4537 					COMPREPLY=( $packopts )
       
  4538 					return 0
       
  4539 					;;
       
  4540 			esac
       
  4541 			return 0
       
  4542 			;;
       
  4543 		*)
       
  4544 			# if seeing a partial option, return possible completions.
       
  4545 			if [ "$cur" = "-s" ]; then
       
  4546 				COMPREPLY=( "-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" \
       
  4547 			    		"-sA" "-sK" "-sP" "-sU" "-sR" )
       
  4548 				return 0
       
  4549 			fi
       
  4550 			# else return all possible options.
       
  4551 			COMPREPLY=( $options )
       
  4552 			return 0
       
  4553 			;;
       
  4554 	esac
       
  4555 } &&
       
  4556 complete -F _dpkg_source dpkg-source
       
  4557 
       
  4558 # Debian Linux dselect(8) completion.
       
  4559 #
       
  4560 have dselect &&
       
  4561 _dselect()
       
  4562 {
       
  4563 	local cur prev
       
  4564 
       
  4565 	COMPREPLY=()
       
  4566 	cur=`_get_cword`
       
  4567 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4568 
       
  4569 	case "$prev" in
       
  4570 	     --admindir)
       
  4571 		  _filedir -d
       
  4572 		  return 0
       
  4573 		  ;;
       
  4574 
       
  4575 	     -@(D|debug))
       
  4576 		  _filedir
       
  4577 		  return 0
       
  4578 		  ;;
       
  4579 	esac
       
  4580 
       
  4581 	if [[ "$cur" == -* ]]; then
       
  4582 	    COMPREPLY=( $( compgen -W '--admindir --help --version --licence \
       
  4583 				  --license --expert --debug' -- $cur ) )
       
  4584 	else
       
  4585 	    COMPREPLY=( $( compgen -W 'access update select install config \
       
  4586 				  remove quit' -- $cur ) )
       
  4587 	fi
       
  4588 
       
  4589 
       
  4590 	return 0
       
  4591 } &&
       
  4592 complete -F _dselect $filenames dselect
       
  4593 
       
  4594 # Java completion
       
  4595 #
       
  4596 
       
  4597 # available path elements completion
       
  4598 have java && {
       
  4599 _java_path()
       
  4600 {
       
  4601 	cur=${cur##*:}
       
  4602 	_filedir '@(jar|zip)'
       
  4603 }
       
  4604 
       
  4605 # exact classpath determination
       
  4606 _java_find_classpath()
       
  4607 {
       
  4608 	local i
       
  4609 
       
  4610 	# search first in current options
       
  4611 	for (( i=1; i < COMP_CWORD; i++ )); do
       
  4612 		if [[ "${COMP_WORDS[i]}" == -@(cp|classpath) ]]; then
       
  4613 			classpath=${COMP_WORDS[i+1]}
       
  4614 			break
       
  4615 		fi
       
  4616 	done
       
  4617 
       
  4618 	# default to environment
       
  4619 	[ -z "$classpath" ] && classpath=$CLASSPATH
       
  4620 
       
  4621 	# default to current directory
       
  4622 	[ -z "$classpath" ] && classpath=.
       
  4623 }
       
  4624 
       
  4625 # exact sourcepath determination
       
  4626 _java_find_sourcepath()
       
  4627 {
       
  4628 	local i
       
  4629 
       
  4630 	# search first in current options
       
  4631 	for (( i=1; i < COMP_CWORD; i++ )); do
       
  4632 		if [[ "${COMP_WORDS[i]}" == -sourcepath ]]; then
       
  4633 			sourcepath=${COMP_WORDS[i+1]}
       
  4634 			break
       
  4635 		fi
       
  4636 	done
       
  4637 
       
  4638 	# default to classpath
       
  4639 	[ -z "$sourcepath" ] && _java_find_classpath
       
  4640 	sourcepath=$classpath
       
  4641 }
       
  4642 
       
  4643 # available classes completion
       
  4644 _java_classes()
       
  4645 {
       
  4646 	local classpath i
       
  4647 
       
  4648 	# find which classpath to use
       
  4649 	_java_find_classpath
       
  4650 
       
  4651 	# convert package syntax to path syntax
       
  4652 	cur=${cur//.//}
       
  4653 	# parse each classpath element for classes
       
  4654 	for i in ${classpath//:/ }; do
       
  4655 		if [ -r $i ] && [[ "$i" == *.@(jar|zip) ]]; then
       
  4656 			if type zipinfo &> /dev/null; then
       
  4657 				COMPREPLY=( "${COMPREPLY[@]}" $( zipinfo -1 \
       
  4658 				"$i" | grep "^$cur" | grep '\.class$' | \
       
  4659 				grep -v "\\$" ) )
       
  4660 			else
       
  4661 				COMPREPLY=( "${COMPREPLY[@]}" $( jar tf "$i" \
       
  4662 				"$cur" | grep "\.class$" | grep -v "\\$" ) )
       
  4663 			fi
       
  4664 
       
  4665 		elif [ -d $i ]; then
       
  4666 			i=${i%/}
       
  4667 			COMPREPLY=( "${COMPREPLY[@]}" $( find "$i" -type f \
       
  4668 			-path "$i/$cur*.class" 2>/dev/null | \
       
  4669 			grep -v "\\$" | sed -e "s|^$i/||" ) )
       
  4670 		fi
       
  4671 	done
       
  4672 
       
  4673 	# remove class extension
       
  4674 	COMPREPLY=( ${COMPREPLY[@]%.class} )
       
  4675 	# convert path syntax to package syntax
       
  4676 	COMPREPLY=( ${COMPREPLY[@]//\//.} )
       
  4677 }
       
  4678 
       
  4679 # available packages completion
       
  4680 _java_packages()
       
  4681 {
       
  4682 	local sourcepath i
       
  4683 
       
  4684 	# find wich sourcepath to use
       
  4685 	_java_find_sourcepath
       
  4686 
       
  4687 	# convert package syntax to path syntax
       
  4688 	cur=${cur//.//}
       
  4689 	# parse each sourcepath element for packages
       
  4690 	for i in ${sourcepath//:/ }; do
       
  4691 		if [ -d $i ]; then
       
  4692 			COMPREPLY=( "${COMPREPLY[@]}" $( command ls -F -d \
       
  4693 				$i/$cur* 2>/dev/null | sed -e 's|^'$i'/||' ) )
       
  4694 		fi
       
  4695 	done
       
  4696 	# keep only packages
       
  4697 	COMPREPLY=( $( echo "${COMPREPLY[@]}" | tr " " "\n" | grep "/$" ) )
       
  4698 	# remove packages extension
       
  4699 	COMPREPLY=( ${COMPREPLY[@]%/} )
       
  4700 	# convert path syntax to package syntax
       
  4701 	cur=${COMPREPLY[@]//\//.}
       
  4702 }
       
  4703 
       
  4704 # java completion
       
  4705 #
       
  4706 _java()
       
  4707 {
       
  4708 	local cur prev i
       
  4709 
       
  4710 	COMPREPLY=()
       
  4711 	cur=`_get_cword`
       
  4712 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4713 
       
  4714 	for ((i=1; i < $COMP_CWORD; i++)); do
       
  4715 		case ${COMP_WORDS[$i]} in
       
  4716 		    -cp|-classpath)
       
  4717 			((i++))	# skip the classpath string.
       
  4718 			;;
       
  4719 		    -*)
       
  4720 			# this is an option, not a class/jarfile name.
       
  4721 			;;
       
  4722 		    *)
       
  4723 			# once we've seen a class, just do filename completion
       
  4724 			_filedir
       
  4725 			return 0
       
  4726 			;;
       
  4727 		esac
       
  4728 	done
       
  4729 
       
  4730 	case $prev in
       
  4731 		-@(cp|classpath))
       
  4732 			_java_path
       
  4733 			return 0
       
  4734 			;;
       
  4735 	esac
       
  4736 
       
  4737 	if [[ "$cur" == -* ]]; then
       
  4738 		# relevant options completion
       
  4739 		COMPREPLY=( $( compgen -W '-client -hotspot -server -classic \
       
  4740 				-cp -classpath -D -verbose -verbose:class \
       
  4741 				-verbose:gc -version:jni -version \
       
  4742 				-showversion -? -help -X -jar \
       
  4743 				-ea -enableassertions -da -disableassertions \
       
  4744 				-esa -enablesystemassertions \
       
  4745 				-dsa -disablesystemassertions ' -- $cur ) )
       
  4746 	else
       
  4747 		if [[ "$prev" == -jar ]]; then
       
  4748 			# jar file completion
       
  4749 			_filedir jar
       
  4750 		else
       
  4751 			# classes completion
       
  4752 			_java_classes
       
  4753 		fi
       
  4754 	fi
       
  4755 }
       
  4756 complete -F _java $filenames java
       
  4757 }
       
  4758 
       
  4759 # javadoc completion
       
  4760 #
       
  4761 have javadoc &&
       
  4762 _javadoc()
       
  4763 {
       
  4764 	COMPREPLY=()
       
  4765 	local cur prev
       
  4766 
       
  4767 	cur=`_get_cword`
       
  4768 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4769 
       
  4770 	case $prev in
       
  4771 		-@(overview|helpfile|stylesheetfile))
       
  4772 			_filedir
       
  4773 			return 0
       
  4774 			;;
       
  4775 		-d)
       
  4776 			_filedir -d
       
  4777 			return 0
       
  4778 			;;
       
  4779 		-@(classpath|bootclasspath|docletpath|sourcepath|extdirs))
       
  4780 			_java_path
       
  4781 			return 0
       
  4782 			;;
       
  4783 	esac
       
  4784 
       
  4785 	if [[ "$cur" == -* ]]; then
       
  4786 		# relevant options completion
       
  4787 		COMPREPLY=( $( compgen -W '-overview -public -protected \
       
  4788 				-package -private -help -doclet -docletpath \
       
  4789 				-sourcepath -classpath -exclude -subpackages \
       
  4790 				-breakiterator -bootclasspath -source -extdirs \
       
  4791 				-verbose -locale -encoding -J -d -use -version \
       
  4792 				-author -docfilessubdirs -splitindex \
       
  4793 				-windowtitle -doctitle -header -footer -bottom \
       
  4794 				-link -linkoffline -excludedocfilessubdir \
       
  4795 				-group -nocomment -nodeprecated -noqualifier \
       
  4796 				-nosince -nodeprecatedlist -notree -noindex \
       
  4797 				-nohelp -nonavbar -quiet -serialwarn -tag \
       
  4798 				-taglet -tagletpath -charset -helpfile \
       
  4799 				-linksource -stylesheetfile -docencoding' -- \
       
  4800 				$cur ) )
       
  4801 	else
       
  4802 		# source files completion
       
  4803 		_filedir java
       
  4804 		# packages completion
       
  4805 		_java_packages
       
  4806 	fi
       
  4807 } &&
       
  4808 complete -F _javadoc $filenames javadoc
       
  4809 
       
  4810 # javac completion
       
  4811 #
       
  4812 have javac &&
       
  4813 _javac()
       
  4814 {
       
  4815 	COMPREPLY=()
       
  4816 	local cur prev
       
  4817 
       
  4818 	cur=`_get_cword`
       
  4819 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4820 
       
  4821 	case $prev in
       
  4822 		-d)
       
  4823 			_filedir -d
       
  4824 			return 0
       
  4825 			;;
       
  4826 		-@(classpath|bootclasspath|sourcepath|extdirs))
       
  4827 			_java_path
       
  4828 			return 0
       
  4829 			;;
       
  4830 	esac
       
  4831 
       
  4832 	if [[ "$cur" == -* ]]; then
       
  4833 		# relevant options completion
       
  4834 		COMPREPLY=( $( compgen -W '-g -g:none -g:lines -g:vars\
       
  4835 		-g:source -O -nowarn -verbose -deprecation -classpath\
       
  4836 		-sourcepath -bootclasspath -extdirs -d -encoding -source\
       
  4837 		-target -help' -- $cur ) )
       
  4838 	else
       
  4839 		# source files completion
       
  4840 		_filedir java
       
  4841 	fi
       
  4842 } &&
       
  4843 complete -F _javac $filenames javac
       
  4844 
       
  4845 # PINE address-book completion
       
  4846 #
       
  4847 have pine &&
       
  4848 _pineaddr()
       
  4849 {
       
  4850 	local cur
       
  4851 
       
  4852 	COMPREPLY=()
       
  4853 	cur=`_get_cword`
       
  4854 
       
  4855 	COMPREPLY=( $( compgen -W '$( awk "{print \$1}" ~/.addressbook 2>/dev/null)' \
       
  4856 			-- $cur ) )
       
  4857 } &&
       
  4858 complete -F _pineaddr $default pine
       
  4859 
       
  4860 # mutt completion
       
  4861 #
       
  4862 # Mutt doesn't have an "addressbook" like Pine, but it has aliases and
       
  4863 # a "query" function to retrieve addresses, so that's what we use here.
       
  4864 have mutt || have muttng && {
       
  4865 _muttaddr()
       
  4866 {
       
  4867 	_muttaliases
       
  4868 	_muttquery
       
  4869 	return 0
       
  4870 }
       
  4871 
       
  4872 _muttconffiles()
       
  4873 {
       
  4874 	local file sofar
       
  4875 	local -a newconffiles
       
  4876 
       
  4877 	sofar=" $1 "
       
  4878 	shift
       
  4879 	while [[ "$1" ]]; do
       
  4880 	    newconffiles=( $(sed -rn 's|^source[[:space:]]+([^[:space:]]+).*$|\1|p' $(eval echo $1) ) )
       
  4881 	    for file in "${newconffiles[@]}"; do
       
  4882 		[[ ! "$file" ]] || [[ "${sofar/ ${file} / }" != "$sofar" ]] &&
       
  4883 		    continue
       
  4884 		sofar="$sofar $file"
       
  4885 		sofar=" $(eval _muttconffiles \"$sofar\" $file) "
       
  4886 	    done
       
  4887 	    shift
       
  4888 	done
       
  4889 	echo $sofar
       
  4890 }
       
  4891 
       
  4892 _muttaliases()
       
  4893 {
       
  4894 	local cur muttrc
       
  4895 	local -a conffiles aliases
       
  4896 	cur=`_get_cword`
       
  4897 
       
  4898 	[ -f ~/.${muttcmd}/${muttcmd}rc ] && muttrc="~/.${muttcmd}/${muttcmd}rc"
       
  4899 	[ -f ~/.${muttcmd}rc ] && muttrc="~/.${muttcmd}rc"
       
  4900 	[ -z "$muttrc" ] && return 0
       
  4901 
       
  4902 	conffiles=( $(eval _muttconffiles $muttrc $muttrc) )
       
  4903 	aliases=( $( sed -rn 's|^alias[[:space:]]+([^[:space:]]+).*$|\1|p' \
       
  4904 			$(eval echo "${conffiles[@]}") ) )
       
  4905 	COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${aliases[*]}" -- $cur ) )
       
  4906 
       
  4907 	return 0
       
  4908 }
       
  4909 
       
  4910 _muttquery()
       
  4911 {
       
  4912 	local cur querycmd
       
  4913 	local -a queryresults
       
  4914 	cur=`_get_cword`
       
  4915 
       
  4916 	querycmd="$( $muttcmd -Q query_command  | sed -r 's|^query_command=\"(.*)\"$|\1|; s|%s|'$cur'|' )"
       
  4917 	if [ -z "$cur" -o -z "$querycmd" ]; then
       
  4918 	    queryresults=()
       
  4919 	else 
       
  4920 	    queryresults=( $( $querycmd | \
       
  4921 	      sed -nr '2,$s|^([^[:space:]]+).*|\1|p' ) )
       
  4922 	fi
       
  4923 
       
  4924 	COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${queryresults[*]}" \
       
  4925 			-- $cur ) )
       
  4926 
       
  4927 	return 0
       
  4928 }
       
  4929 
       
  4930 _muttfiledir()
       
  4931 {
       
  4932 	local cur folder spoolfile
       
  4933 	cur=`_get_cword`
       
  4934 
       
  4935 	# This is currently not working so well. Perhaps this function should
       
  4936 	# just call _filedir() for the moment.
       
  4937 	if [[ $cur == [=+]* ]]; then
       
  4938 		folder="$( $muttcmd -Q folder | sed -r 's|^folder=\"(.*)\"$|\1|' )"
       
  4939 		: folder:=~/Mail
       
  4940 
       
  4941 		# Match any file in $folder beginning with $cur
       
  4942 		# (minus the leading '=' sign).
       
  4943 		COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) )
       
  4944 		COMPREPLY=( ${COMPREPLY[@]#$folder/} )
       
  4945 		return 0
       
  4946 	elif [ "$cur" == !* ]; then
       
  4947 		spoolfile="$( $muttcmd -Q spoolfile | sed -r 's|^spoolfile=\"(.*)\"$|\1|' )"
       
  4948 		[ ! -z "$spoolfile" ] && eval cur="${cur/^!/$spoolfile}";
       
  4949 	fi
       
  4950 	_filedir
       
  4951 
       
  4952 	return 0
       
  4953 }
       
  4954 
       
  4955 _mutt()
       
  4956 {
       
  4957 	local cur prev
       
  4958 	cur=`_get_cword`
       
  4959 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  4960 
       
  4961 	COMPREPLY=()
       
  4962 	
       
  4963 	[ ${COMP_WORDS[0]} == muttng ] && muttcmd="muttng" || muttcmd="mutt"
       
  4964 
       
  4965 	case "$cur" in
       
  4966 	-*)
       
  4967 		COMPREPLY=( $( compgen -W '-A -a -b -c -e -f -F -H -i -m -n \
       
  4968 					    -p -Q -R -s -v -x -y -z -Z -h' \
       
  4969 					    -- $cur ) )
       
  4970 		return 0
       
  4971 		;;
       
  4972 	*)
       
  4973 	    case "$prev" in
       
  4974 	    -@(a|f|F|H|i))
       
  4975 		    _muttfiledir
       
  4976 		    return 0
       
  4977 		    ;;
       
  4978 	    -A)
       
  4979 		    _muttaliases
       
  4980 		    return 0
       
  4981 		    ;;
       
  4982 	    -@(e|m|Q|s|h|p|R|v|y|z|Z))
       
  4983 		    return 0
       
  4984 		    ;;
       
  4985 	    *)
       
  4986 		    _muttaddr
       
  4987 		    return 0
       
  4988 		    ;;
       
  4989 	    esac
       
  4990 	    ;;
       
  4991 	esac
       
  4992 	
       
  4993 }
       
  4994 complete -F _mutt $default $filenames mutt muttng
       
  4995 }
       
  4996 
       
  4997 _configure_func()
       
  4998 {
       
  4999 	local cur
       
  5000 
       
  5001 	COMPREPLY=()
       
  5002 	cur=`_get_cword`
       
  5003 
       
  5004 	# if $COMP_CONFIGURE_HINTS is not null, then completions of the form
       
  5005 	# --option=SETTING will include 'SETTING' as a contextual hint
       
  5006 	[[ "$cur" != -* ]] && return 0
       
  5007 
       
  5008 	if [ -n "$COMP_CONFIGURE_HINTS" ]; then
       
  5009 		COMPREPLY=( $( $1 --help | awk '/^  --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' | grep ^$cur ) )
       
  5010 
       
  5011 	else
       
  5012 		COMPREPLY=( $( $1 --help | awk '/^  --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,=].*//g' | grep ^$cur ) )
       
  5013 	fi
       
  5014 }
       
  5015 complete -F _configure_func $default configure
       
  5016 
       
  5017 # Debian reportbug(1) completion
       
  5018 #
       
  5019 have reportbug &&
       
  5020 _reportbug()
       
  5021 {
       
  5022 	local cur prev
       
  5023 
       
  5024 	COMPREPLY=()
       
  5025 	cur=`_get_cword`
       
  5026 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  5027 
       
  5028 	case "$prev" in
       
  5029 	    -f|--filename|-i|--include|--mta|-o|--output)
       
  5030 		_filedir
       
  5031 		return 0
       
  5032 		;;
       
  5033 	    -B|--bts)
       
  5034 		COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \
       
  5035 			       $cur ))
       
  5036 		return 0
       
  5037 		;;
       
  5038 	    -e|--editor|--mua)
       
  5039 		COMP_WORDS=(COMP_WORDS[0] $cur)
       
  5040 		COMP_CWORD=1
       
  5041 		_command
       
  5042 		return 0
       
  5043 		;;
       
  5044 	    --mode)
       
  5045 		COMPREPLY=( $( compgen -W "novice standard expert" -- $cur ) )
       
  5046 		return 0
       
  5047 		;;
       
  5048 	    -S|--severity)
       
  5049 		COMPREPLY=( $( compgen -W "grave serious important normal \
       
  5050 					   minor wishlist" -- $cur ) )
       
  5051 		return 0
       
  5052 		;;
       
  5053 	    -u|--ui|--interface)
       
  5054 		COMPREPLY=( $( compgen -W "newt text gnome" -- $cur ) )
       
  5055 		return 0
       
  5056 		;;
       
  5057 	    -t|--type)
       
  5058 		COMPREPLY=( $( compgen -W "gnats debbugs" -- $cur ) )
       
  5059 		return 0
       
  5060 		;;
       
  5061 	    -T|--tags)
       
  5062 		COMPREPLY=( $( compgen -W "none patch security upstream sid \
       
  5063 					   woody potato sarge fixed" -- $cur ))
       
  5064 		return 0
       
  5065 		;;
       
  5066 	    *)
       
  5067 		;;
       
  5068 	esac
       
  5069 	
       
  5070 	COMPREPLY=($( compgen -W '-h --help -v --version -a --af -b \
       
  5071 			--no-query-bts --query-bts -B --bts -c --configure \
       
  5072 			--no-config-files --check-available -d --debug \
       
  5073 			--no-check-available -e --editor --email -f \
       
  5074 			--filename -g --gnupg -H --header -i --include -j \
       
  5075 			--justification -l --ldap --no-ldap -L --list-cc -m \
       
  5076 			--maintonly --mode --mua --mta --mutt -n --mh --nmh \
       
  5077 			-o --output -p --print -P --pgp --proxy --http_proxy\
       
  5078 			-q --quiet -Q --query-only --realname --report-quiet \
       
  5079 			--reply-to --replyto -s --subject -S --severity \
       
  5080 			--smtphost -t --type -T --tags --template -V -x \
       
  5081 			--no-cc --package-version -z --no-compress \
       
  5082 			--ui --interface -u \
       
  5083 			wnpp boot-floppies kernel-image' -- $cur ) \
       
  5084 	    		$( apt-cache pkgnames -- $cur 2> /dev/null ) )
       
  5085 	_filedir
       
  5086 	return 0
       
  5087 } &&
       
  5088 complete -F _reportbug $filenames reportbug
       
  5089 
       
  5090 # Debian querybts(1) completion
       
  5091 #
       
  5092 have querybts &&
       
  5093 _querybts()
       
  5094 {
       
  5095 	local cur prev
       
  5096 
       
  5097 	COMPREPLY=()
       
  5098 	cur=`_get_cword`
       
  5099 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  5100 
       
  5101 	case "$prev" in
       
  5102 	    -B|--bts)
       
  5103 		COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \
       
  5104 			       $cur ))
       
  5105 		return 0
       
  5106 		;;
       
  5107 	    -u|--ui|--interface)
       
  5108 		COMPREPLY=($( compgen -W "newt text gnome" -- $cur ))
       
  5109 		return 0
       
  5110 		;;
       
  5111 	    *)
       
  5112 		;;
       
  5113 	esac
       
  5114 
       
  5115 	COMPREPLY=($( compgen -W '-h --help -v --version -A --archive \
       
  5116 			-B --bts -l --ldap --no-ldap --proxy= --http_proxy= \
       
  5117 			-s --source -w --web -u --ui --interface \
       
  5118 			wnpp boot-floppies' -- $cur ) \
       
  5119 	    		$( apt-cache pkgnames -- $cur 2> /dev/null ) )
       
  5120 } &&
       
  5121 complete -F _querybts $filenames querybts
       
  5122 
       
  5123 # update-alternatives completion
       
  5124 #
       
  5125 have update-alternatives && {
       
  5126 installed_alternatives()
       
  5127 {
       
  5128 	local admindir
       
  5129 	# find the admin dir
       
  5130 	for i in alternatives dpkg/alternatives rpm/alternatives; do
       
  5131 		[ -d /var/lib/$i ] && admindir=/var/lib/$i && break
       
  5132 	done
       
  5133 	for (( i=1; i < COMP_CWORD; i++ )); do
       
  5134 		if [[ "${COMP_WORDS[i]}" == --admindir ]]; then
       
  5135 			admindir=${COMP_WORDS[i+1]}
       
  5136 			break
       
  5137 		fi
       
  5138 	done
       
  5139 	COMPREPLY=( $( command ls $admindir | grep "^$cur" ) )
       
  5140 }
       
  5141 
       
  5142 _update_alternatives()
       
  5143 {
       
  5144 	local cur prev mode args i
       
  5145 
       
  5146 	COMPREPLY=()
       
  5147 	cur=`_get_cword`
       
  5148 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  5149 
       
  5150 	case "$prev" in
       
  5151 	--@(altdir|admindir))
       
  5152 		_filedir -d
       
  5153 		return 0
       
  5154 		;;
       
  5155 	--@(help|version))
       
  5156 		return 0
       
  5157 		;;
       
  5158 	esac
       
  5159 
       
  5160 	# find wich mode to use and how many real args used so far
       
  5161 	for (( i=1; i < COMP_CWORD; i++ )); do
       
  5162 		if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all) ]]; then
       
  5163 			mode=${COMP_WORDS[i]}
       
  5164 			args=$(($COMP_CWORD - i))
       
  5165 			break
       
  5166 		fi
       
  5167 	done
       
  5168 
       
  5169 	case $mode in
       
  5170 	--install)
       
  5171 		case $args in
       
  5172 		1)
       
  5173 			_filedir
       
  5174 			;;
       
  5175 		2)
       
  5176 			installed_alternatives
       
  5177 			;;
       
  5178 		3)
       
  5179 			_filedir
       
  5180 			;;
       
  5181 		esac
       
  5182 		;;
       
  5183 	--remove)
       
  5184 		case $args in
       
  5185 		1)
       
  5186 			installed_alternatives
       
  5187 			;;
       
  5188 		2)
       
  5189 			_filedir
       
  5190 			;;
       
  5191 		esac
       
  5192 		;;
       
  5193 	--auto)
       
  5194 		installed_alternatives
       
  5195 		;;
       
  5196 	--remove-all)
       
  5197 		installed_alternatives
       
  5198 		;;
       
  5199 	--display)
       
  5200 		installed_alternatives
       
  5201 		;;
       
  5202 	--config)
       
  5203 		installed_alternatives
       
  5204 		;;
       
  5205 	*)
       
  5206 		COMPREPLY=( $( compgen -W '--verbose --quiet --help --version \
       
  5207 			       --altdir --admindir' -- $cur ) \
       
  5208 			    $( compgen -W '--install --remove --auto --display \
       
  5209 			       --config' -- $cur ) )
       
  5210 	esac
       
  5211 }
       
  5212 complete -F _update_alternatives update-alternatives
       
  5213 }
       
  5214 
       
  5215 # Python completion
       
  5216 #
       
  5217 have python &&
       
  5218 _python()
       
  5219 {
       
  5220 	local prev cur
       
  5221 
       
  5222 	COMPREPLY=()
       
  5223 	cur=`_get_cword`
       
  5224 	prev=${COMP_WORDS[COMP_CWORD-1]##*/}
       
  5225 
       
  5226 	case "$prev" in
       
  5227 	-Q)
       
  5228 		COMPREPLY=( $( compgen -W "old new warn warnall" -- $cur ) )
       
  5229 		return 0
       
  5230 		;;
       
  5231 	-W)
       
  5232 		COMPREPLY=( $( compgen -W "ignore default all module once error" -- $cur ) )
       
  5233 		return 0
       
  5234 		;;
       
  5235 	-c)
       
  5236 		_filedir '@(py|pyc|pyo)'
       
  5237 		return 0
       
  5238 		;;
       
  5239 	!(python|-?))
       
  5240 		[[ ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]] && _filedir
       
  5241 		;;
       
  5242 	esac
       
  5243 
       
  5244 
       
  5245 	# if '-c' is already given, complete all kind of files.
       
  5246 	for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
       
  5247 		if [[ ${COMP_WORDS[i]} == -c ]]; then
       
  5248 			_filedir
       
  5249 		fi
       
  5250 	done
       
  5251 
       
  5252 
       
  5253 	if [[ "$cur" != -* ]]; then
       
  5254 		_filedir '@(py|pyc|pyo)'
       
  5255 	else
       
  5256 		COMPREPLY=( $( compgen -W "- -d -E -h -i -O -Q -S -t -u \
       
  5257 					   -U -v -V -W -x -c" -- $cur ) )
       
  5258 	fi
       
  5259 
       
  5260 
       
  5261 
       
  5262 	return 0
       
  5263 } &&
       
  5264 complete -F _python $filenames python
       
  5265 
       
  5266 # Perl completion
       
  5267 #
       
  5268 have perl &&
       
  5269 {
       
  5270 _perlmodules()
       
  5271 {
       
  5272     COMPREPLY=( $( compgen -P "$prefix" -W "$( perl -e 'sub mods { my ($base,$dir)=@_; return if  $base !~ /^\Q$ENV{cur}/; chdir($dir) or return; for (glob(q[*.pm])) {s/\.pm$//; print qq[$base$_\n]}; mods(/^(?:[.\d]+|$Config{archname}-$Config{osname}|auto)$/ ? undef : qq[${base}${_}\\\\:\\\\:],qq[$dir/$_]) for grep {-d} glob(q[*]); } mods(undef,$_) for @INC;' )" -- $cur ) )
       
  5273 }
       
  5274 
       
  5275 _perl()
       
  5276 {
       
  5277     local cur prev prefix temp
       
  5278 
       
  5279     COMPREPLY=()
       
  5280     cur=`_get_cword`
       
  5281     prev=${COMP_WORDS[COMP_CWORD-1]}
       
  5282     prefix=""
       
  5283 
       
  5284     # completing an option (may or may not be separated by a space)
       
  5285     if [[ "$cur" == -?* ]]; then
       
  5286 	temp=$cur
       
  5287 	prev=${temp:0:2}
       
  5288 	cur=${temp:2}
       
  5289 	prefix=$prev
       
  5290     fi
       
  5291 
       
  5292     # only handle module completion for now
       
  5293     case "$prev" in
       
  5294     	-I|-x)
       
  5295 	    COMPREPLY=( $( compgen -d -P "$prev" -- "$cur" ) )
       
  5296 	    return 0
       
  5297 	    ;;
       
  5298 	-m|-M)
       
  5299 	    _perlmodules
       
  5300 	    return 0
       
  5301 	    ;;
       
  5302     esac
       
  5303 
       
  5304     # handle case where first parameter is not a dash option
       
  5305     if [[ "${COMP_WORDS[COMP_CWORD]}" != -* ]]; then
       
  5306 	_filedir
       
  5307 	return 0
       
  5308     fi
       
  5309 
       
  5310     # complete using basic options
       
  5311     COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p \
       
  5312 			-n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) )
       
  5313     return 0
       
  5314 }
       
  5315 complete -F _perl $filenames perl
       
  5316 
       
  5317 _perldoc()
       
  5318 {
       
  5319     local cur prev prefix temp
       
  5320 
       
  5321     COMPREPLY=()
       
  5322     cur=`_get_cword`
       
  5323     prev=${COMP_WORDS[COMP_CWORD-1]}
       
  5324     prefix=""
       
  5325 
       
  5326     # completing an option (may or may not be separated by a space)
       
  5327     if [[ "$cur" == -?* ]]; then
       
  5328 	temp=$cur
       
  5329 	prev=${temp:0:2}
       
  5330 	cur=${temp:2}
       
  5331 	prefix=$prev
       
  5332     fi
       
  5333 
       
  5334     # complete builtin perl functions
       
  5335     case $prev in
       
  5336 	-f)
       
  5337 	    COMPREPLY=( $( compgen -W 'chomp chop chr crypt hex index lc \
       
  5338 	    lcfirst length oct ord pack q qq reverse rindex sprintf \
       
  5339 	    substr tr uc ucfirst y m pos quotemeta s split study qr abs \
       
  5340 	    atan2 cos exp hex int log oct rand sin sqrt srand pop push \
       
  5341 	    shift splice unshift grep join map qw reverse sort unpack \
       
  5342 	    delete each exists keys values binmode close closedir \
       
  5343 	    dbmclose dbmopen die eof fileno flock format getc print \
       
  5344 	    printf read readdir rewinddir seek seekdir select syscall \
       
  5345 	    sysread sysseek syswrite tell telldir truncate warn write \
       
  5346 	    pack read syscall sysread syswrite unpack vec -X chdir chmod \
       
  5347 	    chown chroot fcntl glob ioctl link lstat mkdir open opendir \
       
  5348 	    readlink rename rmdir stat symlink umask unlink utime caller \
       
  5349 	    continue do dump eval exit goto last next redo return \
       
  5350 	    sub wantarray caller import local my our package use defined \
       
  5351 	    formline reset scalar undef \
       
  5352 	    alarm exec fork getpgrp getppid getpriority kill pipe qx \
       
  5353 	    setpgrp setpriority sleep system times wait waitpid \
       
  5354 	    import no package require use bless dbmclose dbmopen package \
       
  5355 	    ref tie tied untie use accept bind connect getpeername \
       
  5356 	    getsockname getsockopt listen recv send setsockopt shutdown \
       
  5357 	    socket socketpair msgctl msgget msgrcv msgsnd semctl semget \
       
  5358 	    semop shmctl shmget shmread shmwrite endgrent endhostent \
       
  5359 	    endnetent endpwent getgrent getgrgid getgrnam getlogin \
       
  5360 	    getpwent getpwnam getpwuid setgrent setpwent endprotoent \
       
  5361 	    endservent gethostbyaddr gethostbyname gethostent \
       
  5362 	    getnetbyaddr getnetbyname getnetent getprotobyname \
       
  5363 	    getprotobynumber getprotoent getservbyname getservbyport \
       
  5364 	    getservent sethostent setnetent setprotoent setservent \
       
  5365 	    gmtime localtime time times' -- $cur ) )
       
  5366 	    return 0
       
  5367 	    ;;
       
  5368     esac
       
  5369 
       
  5370     case $cur in
       
  5371 	-*)
       
  5372 	    COMPREPLY=( $( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- $cur ))
       
  5373 	    return 0
       
  5374 	    ;;
       
  5375 	*/*)
       
  5376 	    return 0
       
  5377 	    ;;
       
  5378 	*)
       
  5379 	    _perlmodules
       
  5380 	    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '$( PAGER=cat man perl 2>/dev/null | sed -ne "/perl.*Perl overview/,/perlwin32/s/^[^a-z0-9]*\([a-z0-9]*\).*$/\1/p")' -- $cur ) )
       
  5381 
       
  5382 	    return 0
       
  5383 	    ;;
       
  5384     esac
       
  5385 }
       
  5386 complete -F _perldoc $default perldoc
       
  5387 }
       
  5388 
       
  5389 # rcs(1) completion
       
  5390 #
       
  5391 have rcs &&
       
  5392 _rcs()
       
  5393 {
       
  5394 	local cur prev file dir i
       
  5395 
       
  5396 	COMPREPLY=()
       
  5397 	cur=`_get_cword`
       
  5398 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  5399 
       
  5400 	file=${cur##*/}
       
  5401 	dir=${cur%/*}
       
  5402 
       
  5403 	# deal with relative directory
       
  5404 	[ "$file" = "$dir" ] && dir=.
       
  5405 
       
  5406 	COMPREPLY=( $( compgen -f "$dir/RCS/$file" ) )
       
  5407 
       
  5408 	for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
       
  5409 		file=${COMPREPLY[$i]##*/}
       
  5410 		dir=${COMPREPLY[$i]%RCS/*}
       
  5411 		COMPREPLY[$i]=$dir$file
       
  5412 	done
       
  5413 	
       
  5414 	COMPREPLY=( "${COMPREPLY[@]}" $( compgen -G "$dir/$file*,v" ) )
       
  5415 
       
  5416 	for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
       
  5417 		COMPREPLY[$i]=${COMPREPLY[$i]%,v}
       
  5418 	done
       
  5419 
       
  5420 	# default to files if nothing returned and we're checking in.
       
  5421 	# otherwise, default to directories
       
  5422 	[ ${#COMPREPLY[@]} -eq 0 -a $1 = ci ] && _filedir || _filedir -d
       
  5423 } &&
       
  5424 complete -F _rcs $filenames ci co rlog rcs rcsdiff
       
  5425 
       
  5426 # lilo(8) completion
       
  5427 #
       
  5428 have lilo && {
       
  5429 _lilo_labels()
       
  5430 {
       
  5431 	COMPREPLY=( $( awk -F'=' '/label/ {print $2}' \
       
  5432 		/etc/lilo.conf | sed -e 's/"//g' | grep "^$cur" ) )
       
  5433 }
       
  5434 
       
  5435 _lilo()
       
  5436 {
       
  5437 	local cur prev
       
  5438 
       
  5439 	COMPREPLY=()
       
  5440 	cur=`_get_cword`
       
  5441 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  5442 
       
  5443 	case $prev in
       
  5444 		-@(C|i|m|s|S))
       
  5445 			_filedir
       
  5446 			return 0
       
  5447 			;;
       
  5448 		-r)
       
  5449 			_filedir -d
       
  5450 			return 0
       
  5451 			;;
       
  5452 		-@(I|D|R))
       
  5453 			# label completion
       
  5454 			_lilo_labels
       
  5455 			return 0
       
  5456 			;;
       
  5457 		-@(A|b|M|u|U))
       
  5458 			# device completion
       
  5459 			cur=${cur:=/dev/}
       
  5460 			_filedir
       
  5461 			return 0
       
  5462 			;;
       
  5463 		-T)
       
  5464 			# topic completion
       
  5465 			COMPREPLY=( $( compgen -W 'help ChRul EBDA geom geom= \
       
  5466 					table= video' -- $cur ) )
       
  5467 			return 0
       
  5468 			;;
       
  5469 	esac
       
  5470 
       
  5471 	if [[ "$cur" == -* ]]; then
       
  5472 		# relevant options completion
       
  5473 		COMPREPLY=( $( compgen -W '-A -b -c -C -d -f -g -i -I -l -L -m \
       
  5474 			-M -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- \
       
  5475 			$cur ) )
       
  5476 	fi
       
  5477 }
       
  5478 complete -F _lilo lilo
       
  5479 }
       
  5480 
       
  5481 # links completion
       
  5482 #
       
  5483 have links &&
       
  5484 _links()
       
  5485 {
       
  5486 	local cur
       
  5487   
       
  5488 	COMPREPLY=()
       
  5489 	cur=`_get_cword`
       
  5490   
       
  5491 	case "$cur" in
       
  5492 	    --*)
       
  5493 		COMPREPLY=( $( compgen -W '--help' -- $cur ) )
       
  5494 		;;
       
  5495 	    -*)
       
  5496 		COMPREPLY=( $( compgen -W '-async-dns -max-connections \
       
  5497 				-max-connections-to-host -retries \
       
  5498 				-receive-timeout -unrestartable-receive-timeout\
       
  5499 				-format-cache-size -memory-cache-size \
       
  5500 				-http-proxy -ftp-proxy -download-dir \
       
  5501 				-assume-codepage -anonymous -dump -no-connect \
       
  5502 				-source -version -help' -- $cur ) )
       
  5503 		;;
       
  5504 	    *)
       
  5505 		if [ -r ~/.links/links.his ]; then
       
  5506 		    COMPREPLY=( $( compgen -W '$( < ~/.links/links.his )' \
       
  5507 				   -- $cur ) )
       
  5508 		fi
       
  5509 				_filedir '@(htm|html)'
       
  5510 				return 0
       
  5511 		;;
       
  5512 	esac
       
  5513   
       
  5514 	return 0
       
  5515 } &&
       
  5516 complete -F _links $filenames links
       
  5517 
       
  5518 [ $UNAME = FreeBSD ] && {
       
  5519 # FreeBSD package management tool completion
       
  5520 #
       
  5521 _pkg_delete()
       
  5522 {
       
  5523 	local cur pkgdir prev
       
  5524 
       
  5525 	pkgdir=${PKG_DBDIR:-/var/db/pkg}/
       
  5526 	cur=`_get_cword`
       
  5527 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  5528 
       
  5529 	[ "$prev" = "-o" -o "$prev" = "-p" -o "$prev" = "-W" ] && return 0
       
  5530 
       
  5531 	COMPREPLY=( $( compgen -d $pkgdir$cur ) )
       
  5532 	COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
       
  5533 
       
  5534 	return 0
       
  5535 }
       
  5536 complete -F _pkg_delete $dirnames pkg_delete pkg_info
       
  5537 have pkg_deinstall && complete -F _pkg_delete $dirnames pkg_deinstall
       
  5538 
       
  5539 # FreeBSD kernel module commands
       
  5540 #
       
  5541 _kldload()
       
  5542 {
       
  5543 	local cur moddir
       
  5544 
       
  5545 	moddir=/modules/
       
  5546 	[ -d $moddir ] || moddir=/boot/kernel/
       
  5547 	cur=`_get_cword`
       
  5548 
       
  5549 	COMPREPLY=( $( compgen -f $moddir$cur ) )
       
  5550 	COMPREPLY=( ${COMPREPLY[@]#$moddir} )
       
  5551 	COMPREPLY=( ${COMPREPLY[@]%.ko} )
       
  5552 
       
  5553 	return 0
       
  5554 }
       
  5555 complete -F _kldload $filenames kldload
       
  5556 
       
  5557 _kldunload()
       
  5558 {
       
  5559 	local cur
       
  5560 	cur=`_get_cword`
       
  5561 	COMPREPLY=( $(kldstat | sed -ne "s/^.*[ \t]\+\($cur[a-z_]\+\).ko$/\1/p") )
       
  5562 }
       
  5563 complete -F _kldunload $filenames kldunload
       
  5564 }
       
  5565 
       
  5566 # FreeBSD portupgrade completion
       
  5567 #
       
  5568 have portupgrade &&
       
  5569 _portupgrade()
       
  5570 {
       
  5571 	local cur pkgdir prev
       
  5572 
       
  5573 	pkgdir=${PKG_DBDIR:-/var/db/pkg}/
       
  5574 	cur=`_get_cword`
       
  5575 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  5576 
       
  5577 	[ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0
       
  5578 
       
  5579 	COMPREPLY=( $( compgen -d $pkgdir$cur ) )
       
  5580 	COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
       
  5581 	COMPREPLY=( ${COMPREPLY[@]%-*} )
       
  5582 
       
  5583 	return 0
       
  5584 } &&
       
  5585 complete -F _portupgrade $dirnames portupgrade
       
  5586 
       
  5587 # FreeBSD portinstall completion
       
  5588 #
       
  5589 have portinstall &&
       
  5590 _portinstall()
       
  5591 {
       
  5592 	local cur portsdir prev indexfile
       
  5593 	local -a COMPREPLY2
       
  5594 
       
  5595 	portsdir=${PORTSDIR:-/usr/ports}/
       
  5596 	cur=`_get_cword`
       
  5597 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  5598 	# First try INDEX-5
       
  5599 	indexfile=$portsdir/INDEX-5
       
  5600 	# Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x
       
  5601 	[ "${OSTYPE%.*}" = "freebsd5" -a -f $indexfile ] ||
       
  5602 	  indexfile=$portsdir/INDEX
       
  5603 
       
  5604 	[ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0
       
  5605 
       
  5606 	COMPREPLY=( $( egrep "^$cur" < $indexfile | cut -d'|' -f1 ) )
       
  5607 	COMPREPLY2=( $( egrep "^[^\|]+\|$portsdir$cur" < $indexfile | \
       
  5608 			cut -d'|' -f2 ) )
       
  5609 	COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
       
  5610 	COMPREPLY=( "${COMPREPLY[@]}" "${COMPREPLY2[@]}" )
       
  5611 
       
  5612 	return 0
       
  5613 } &&
       
  5614 complete -F _portinstall $dirnames portinstall
       
  5615 
       
  5616 # Slackware Linux removepkg completion
       
  5617 #
       
  5618 have removepkg && [ -f /etc/slackware-version ] &&
       
  5619 _removepkg()
       
  5620 {
       
  5621 	local packages cur
       
  5622 
       
  5623 	COMPREPLY=()
       
  5624 	cur=`_get_cword`
       
  5625 
       
  5626 	COMPREPLY=( $( (cd /var/log/packages; compgen -f -- "$cur") ) )
       
  5627 } &&
       
  5628 complete -F _removepkg $filenames removepkg &&
       
  5629 	complete $dirnames -f -X '!*.tgz' installpkg upgradepkg explodepkg
       
  5630 
       
  5631 # look(1) completion
       
  5632 #
       
  5633 have look && 
       
  5634 _look()
       
  5635 {
       
  5636 	local cur
       
  5637   
       
  5638 	COMPREPLY=()
       
  5639 	cur=`_get_cword`
       
  5640 
       
  5641 	if [ $COMP_CWORD = 1 ]; then
       
  5642 		COMPREPLY=( $( compgen -W '$(look $cur)' ) )
       
  5643 	fi
       
  5644 } &&
       
  5645 complete -F _look $default look
       
  5646 
       
  5647 # ypcat(1) and ypmatch(1) completion
       
  5648 #
       
  5649 have ypmatch &&
       
  5650 _ypmatch()
       
  5651 {
       
  5652 	local cur map
       
  5653 
       
  5654 	COMPREPLY=()
       
  5655 	cur=`_get_cword`
       
  5656 
       
  5657 	[ $1 = ypcat ] && [ $COMP_CWORD -gt 1 ] && return 0
       
  5658 	[ $1 = ypmatch ] && [ $COMP_CWORD -gt 2 ] && return 0
       
  5659 
       
  5660 	if [ $1 = ypmatch ] && [ $COMP_CWORD -eq 1 ] && \
       
  5661 	   [ ${#COMP_WORDS[@]} -eq 3 ]; then
       
  5662 		map=${COMP_WORDS[2]}
       
  5663 		COMPREPLY=( $( compgen -W '$( ypcat $map | \
       
  5664 						cut -d':' -f 1 )' -- $cur) )
       
  5665 	else
       
  5666 		[ $1 = ypmatch ] && [ $COMP_CWORD -ne 2 ] && return 0
       
  5667 		COMPREPLY=( $( compgen -W \
       
  5668 			      '$( echo $(ypcat -x | cut -d"\"" -f 2))' -- $cur))
       
  5669 	fi
       
  5670 
       
  5671 	return 0
       
  5672 } &&
       
  5673 complete -F _ypmatch ypmatch ypcat
       
  5674 
       
  5675 # mplayer(1) completion
       
  5676 #
       
  5677 have mplayer && {
       
  5678 _mplayer_options_list()
       
  5679 {
       
  5680 	cur=${cur%\\}
       
  5681 	COMPREPLY=( $( $1 $2 help 2> /dev/null | \
       
  5682 		sed -e '1,/^Available/d' | awk '{print $1}' | \
       
  5683 		sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' | \
       
  5684 		grep "^$cur" ) )
       
  5685 }
       
  5686 
       
  5687 _mplayer()
       
  5688 {
       
  5689 	local cmd cur prev skinsdir IFS=$' \t\n' i j k=0
       
  5690 
       
  5691 	COMPREPLY=()
       
  5692 	cmd=${COMP_WORDS[0]}
       
  5693 	cur=`_get_cword`
       
  5694 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  5695 
       
  5696 	case "$prev" in
       
  5697 		-@(ac|afm|vc|vfm|ao|vo|vop|fstype))
       
  5698 			_mplayer_options_list mplayer $prev
       
  5699 			return 0
       
  5700 			;;
       
  5701 		-@(oac|ovc|of))
       
  5702 			_mplayer_options_list mencoder $prev
       
  5703 			return 0
       
  5704 			;;
       
  5705 		-audiofile)
       
  5706 			_filedir '@(mp3|MP3|mpg|MPG|ogg|OGG|wav|WAV|mid|MID|flac|FLAC|mka|MKA)'
       
  5707 			return 0
       
  5708 			;;
       
  5709 		-font)
       
  5710 			_filedir '@(desc|ttf)'
       
  5711 			return 0
       
  5712 			;;
       
  5713 		-sub)
       
  5714 			_filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js|ssa|SSA|aas|AAS)'
       
  5715 			return 0
       
  5716 			;;
       
  5717 		-vobsub)
       
  5718 			_filedir '@(idx|IDX|ifo|IFO|sub|SUB)'
       
  5719 			IFS=$'\t\n' 
       
  5720 			COMPREPLY=( $( for i in "${COMPREPLY[@]}"; do
       
  5721 						if [ -f $i -a -r $i ]; then
       
  5722 							echo ${i%.*}
       
  5723 						else
       
  5724 							echo $i
       
  5725 						fi
       
  5726 				       done ) )
       
  5727 			IFS=$' \t\n' 
       
  5728 			return 0
       
  5729 			;;
       
  5730 		-ifo)
       
  5731 			_filedir '@(ifo|IFO)'
       
  5732 			return 0
       
  5733 			;;
       
  5734 		-cuefile)
       
  5735 			_filedir '@(bin|BIN|cue|CUE)'
       
  5736 			return 0
       
  5737 			;;
       
  5738 		-skin)
       
  5739 			# if you don't have installed mplayer in /usr you
       
  5740 			# may want to set the MPLAYER_SKINS_DIR global variable
       
  5741 			if [ -n "$MPLAYER_SKINS_DIR" ]; then
       
  5742 				skinsdir=$MPLAYER_SKINS_DIR
       
  5743 			else
       
  5744 				skinsdir=/usr/share/mplayer/Skin
       
  5745 			fi
       
  5746 
       
  5747 			IFS=$'\t\n' 
       
  5748 			for i in ~/.mplayer/Skin $skinsdir; do
       
  5749 				if [ -d $i -a -r $i ]; then
       
  5750 					for j in $( compgen -d $i/$cur ); do
       
  5751 						COMPREPLY[$k]=${j#$i/}
       
  5752 						k=$((++k))
       
  5753 					done
       
  5754 				fi
       
  5755 			done
       
  5756 			IFS=$' \t\n' 
       
  5757 			return 0
       
  5758 			;;
       
  5759 		-@(mixer|@(cdrom|dvd)-device|dvdauth|fb|zrdev))
       
  5760 			cur=${cur:=/dev/}
       
  5761 			_filedir
       
  5762 			return 0
       
  5763 			;;
       
  5764 		-@(edl?(out)|lircconf|menu-cfg|playlist|csslib|dumpfile)| \
       
  5765 		-@(subfile|vobsub|aofile|fbmodeconfig|include|o|dvdkey)| \
       
  5766 		-passlogfile)
       
  5767 			_filedir
       
  5768 			return 0
       
  5769 			;;
       
  5770 		-@(auto@(q|sync)|loop|menu-root|speed|sstep|aid|alang)| \
       
  5771 		-@(?(@(audio|sub)-)demuxer|bandwidth|cache|chapter)| \
       
  5772 		-@(dvd?(angle)|fps|frames|mc|passwd|user|sb|srate|ss|vcd)| \
       
  5773 		-@(vi?(d|vo)|ffactor|sid|slang|spu@(align|aa|gauss))| \
       
  5774 		-@(vobsubid|delay|bpp|brightness|contrast|dfbopts|display)| \
       
  5775 		-@(fbmode|geometry|guiwid|hue|icelayer|screen[wh]|wid)| \
       
  5776 		-@(monitor@(aspect|-@(dotclock|[hv]freq))|panscan|saturation)| \
       
  5777 		-@(xineramascreen|zr@(crop|norm|quality|[xy]doff|[vh]dec))| \
       
  5778 		-@(aspect|pp|x|y|xy|z|stereo|audio-@(density|delay|preload))| \
       
  5779 		-@(endpos|osdlevel|ffourcc|sws|channels|skiplimit|format)| \
       
  5780 		-@(ofps|aa@(driver|@(osd|sub)color)|vobsubout?(i@(ndex|d)))| \
       
  5781 		-sub@(-bg-@(alpha|color)|cp|delay|fps|pos|align|width)| \
       
  5782 		-sub@(font-@(blur|outline|autoscale|encoding|@(osd|text)-scale)))
       
  5783 			return 0
       
  5784 			;;
       
  5785 		-lavdopts)
       
  5786 			COMPREPLY=( $( compgen -W 'ec er= bug= idct= gray' \
       
  5787 					-- $cur ) )
       
  5788 			return 0
       
  5789 			;;
       
  5790 		-lavcopts)
       
  5791 			COMPREPLY=( $( compgen -W 'vcodec= vqmin= vqscale= \
       
  5792 					vqmax= mbqmin= mbqmax= vqdiff= \
       
  5793 					vmax_b_frames= vme= vhq v4mv \
       
  5794 					keyint= vb_strategy= vpass= \
       
  5795 					aspect= vbitrate= vratetol= \
       
  5796 					vrc_maxrate= vrc_minrate= \
       
  5797 					vrc_buf_size= vb_qfactor= vi_qfactor= \
       
  5798 					vb_qoffset= vi_qoffset= vqblur= \
       
  5799 					vqcomp= vrc_eq= vrc_override= \
       
  5800 					vrc_init_cplx= vqsquish= vlelim= \
       
  5801 					vcelim= vstrict= vdpart vpsize= gray \
       
  5802 					vfdct= idct= lumi_mask= dark_mask= \
       
  5803 					tcplx_mask= scplx_mask= naq ildct \
       
  5804 					format= pred qpel precmp= cmp= \
       
  5805 					subcmp= predia= dia= trell last_pred= \
       
  5806 					preme= subq= psnr mpeg_quant aic umv' \
       
  5807 					-- $cur ) )
       
  5808 			return 0
       
  5809 			;;
       
  5810 		-ssf)
       
  5811 			COMPREPLY=( $( compgen -W 'lgb= cgb= ls= cs= chs= \
       
  5812 					cvs=' -- $cur ) )
       
  5813 			return 0
       
  5814 			;;
       
  5815 		-jpeg)
       
  5816 			COMPREPLY=( $( compgen -W 'noprogressive progressive \
       
  5817 					nobaseline baseline optimize= \
       
  5818 					smooth= quality= outdir=' -- $cur ) )
       
  5819 			return 0
       
  5820 			;;
       
  5821 		-xvidopts)
       
  5822 			COMPREPLY=( $( compgen -W 'dr2 nodr2' -- $cur ) )
       
  5823 			return 0
       
  5824 			;;
       
  5825 		-xvidencopts)
       
  5826 			COMPREPLY=( $( compgen -W 'pass= bitrate= \
       
  5827 					fixed_quant= me_quality= 4mv \
       
  5828 					rc_reaction_delay_factor= \
       
  5829 					rc_averaging_period= rc_buffer= \
       
  5830 					quant_range= min_key_interval= \
       
  5831 					max_key_interval= mpeg_quant \
       
  5832 					mod_quant lumi_mask hintedme \
       
  5833 					hintfile debug keyframe_boost= \
       
  5834 					kfthreshold= kfreduction=' -- $cur ) )
       
  5835 			return 0
       
  5836 			;;
       
  5837 		-divx4opts)
       
  5838 			COMPREPLY=( $( compgen -W 'br= key= deinterlace q= \
       
  5839 					min_quant= max_quant= rc_period= \
       
  5840 					rc_reaction_period= crispness= \
       
  5841 					rc_reaction_ratio= pass= vbrpass= \
       
  5842 					help' -- $cur ) )
       
  5843 			return 0
       
  5844 			;;
       
  5845 		-info)
       
  5846 			COMPREPLY=( $( compgen -W 'name= artist= genre= \
       
  5847 					subject= copyright= srcform= \
       
  5848 					comment= help' -- $cur ) )
       
  5849 			return 0
       
  5850 			;;
       
  5851 		-lameopts)
       
  5852 			COMPREPLY=( $( compgen -W 'vbr= abr cbr br= q= aq= \
       
  5853 					ratio= vol= mode= padding= fast \
       
  5854 					preset= help' -- $cur ) )
       
  5855 			return 0
       
  5856 			;;
       
  5857 		-rawaudio)
       
  5858 			COMPREPLY=( $( compgen -W 'on channels= rate= \
       
  5859 					samplesize= format=' -- $cur ) )
       
  5860 			return 0
       
  5861 			;;
       
  5862 		-rawvideo)
       
  5863 			COMPREPLY=( $( compgen -W 'on fps= sqcif qcif cif \
       
  5864 					4cif pal ntsc w= h= y420 yv12 yuy2 \
       
  5865 					y8 format= size=' -- $cur ) )
       
  5866 			return 0
       
  5867 			;;
       
  5868 		-aop)
       
  5869 			COMPREPLY=( $( compgen -W 'list= delay= format= fout= \
       
  5870 					volume= mul= softclip' -- $cur ) )
       
  5871 			return 0
       
  5872 			;;
       
  5873 		-dxr2)
       
  5874 			COMPREPLY=( $( compgen -W 'ar-mode= iec958-encoded \
       
  5875 					iec958-decoded mute ucode= 75ire bw \
       
  5876 					color interlaced macrovision= norm= \
       
  5877 					square-pixel ccir601-pixel cr-left= \
       
  5878 					cr-right= cr-top= cr-bot= ck-rmin= \
       
  5879 					ck-gmin= ck-bmin= ck-rmax= ck-gmax= \
       
  5880 					ck-bmax= ck-r= ck-g= ck-b= \
       
  5881 					ignore-cache= ol-osd= olh-cor= \
       
  5882 					olw-cor= olx-cor= oly-cor= overlay \
       
  5883 					overlay-ratio= update-cache' -- $cur ))
       
  5884 			return 0
       
  5885 			;;
       
  5886 		-tv)
       
  5887 			COMPREPLY=( $( compgen -W 'on noaudio driver= device= \
       
  5888 					input= freq= outfmt= width= height= \
       
  5889 					buffersize= norm= channel= chanlist= \
       
  5890 					audiorate= forceaudio alsa amode= \
       
  5891 					forcechan= adevice= audioid= volume= \
       
  5892 					bass= treble= balance= fps= \
       
  5893 					channels= immediatemode=' -- $cur ) )
       
  5894 			return 0
       
  5895 			;;
       
  5896 		-mf)
       
  5897 			COMPREPLY=( $( compgen -W 'on w= h= fps= type=' \
       
  5898 					-- $cur ) )
       
  5899 			return 0
       
  5900 			;;
       
  5901 		-cdda)
       
  5902 			COMPREPLY=( $( compgen -W 'speed= paranoia= \
       
  5903 					generic-dev= sector-size= overlap= \
       
  5904 					toc-bias toc-offset= skip noskip' \
       
  5905 					-- $cur ) )
       
  5906 			return 0
       
  5907 			;;
       
  5908 		-input)
       
  5909 			COMPREPLY=( $( compgen -W 'conf= ar-delay ar-rate \
       
  5910 					keylist cmdlist js-dev file' -- $cur ) )
       
  5911 			return 0
       
  5912 			;;
       
  5913 		-af)
       
  5914 			COMPREPLY=( $( compgen -W 'resample resample= \
       
  5915 					channels channels= format format= \
       
  5916 					volume volume= delay delay= pan \
       
  5917 					pan= sub sub= surround surround=' \
       
  5918 					-- $cur ) )
       
  5919 			return 0
       
  5920 			;;
       
  5921 		-af-adv)
       
  5922 			COMPREPLY=( $( compgen -W 'force= list=' -- $cur ) )
       
  5923 			return 0
       
  5924 			;;
       
  5925 	esac
       
  5926 
       
  5927 	case "$cur" in
       
  5928 		-*)
       
  5929 			COMPREPLY=( $( compgen -W '-aid -alang -audio-demuxer \
       
  5930 					-audiofile -cdrom-device -cache -cdda \
       
  5931 					-channels -chapter -csslib -demuxer \
       
  5932 					-dvd -dvd-device -dvdangle -dvdauth \
       
  5933 					-dvdkey -dvdnav -forceidx -fps -frames \
       
  5934 					-hr-mp3-seek -idx -mc -mf -ni -nobps \
       
  5935 					-passwd -rawaudio -rtsp-stream-over-tcp\
       
  5936 					-skipopening -sb -srate -ss -tv -user \
       
  5937 					-vcd -vid -vivo -ifo -ffactor -font \
       
  5938 					-noautosub -nooverlapsub -sid -slang \
       
  5939 					-sub -subcc -subcp -sub-demuxer \
       
  5940 					-subdelay -subfont-autoscale \
       
  5941 					-subfont-blur -subfont-encoding \
       
  5942 					-subfont-osd-scale -subfont-outline \
       
  5943 					-subfont-text-scale -subfps -subfile \
       
  5944 					-subpos -unicode -utf8 -vobsub \
       
  5945 					-vobsubid -ac -afm -aspect -flip \
       
  5946 					-lavdopts -noaspect -nosound -pp -ssf \
       
  5947 					-stereo -sws -vc -vfm -vop -xvidopts\
       
  5948 					-xy -zoom -bandwidth -cuefile \
       
  5949 					-noextbased -rawvideo -overlapsub \
       
  5950 					-sub-bg-alpha -sub-bg-color -subalign \
       
  5951 					-subwidth -sub-no-text-pp -spualign \
       
  5952 					-spuaa -spugauss -pphelp -verbose -v \
       
  5953 					-noni -noidx -nohr-mp3-seek -extbased \
       
  5954 					-bps -oldpp -nozoom -noflip -nounicode \
       
  5955 					-noutf8' -- $cur ) )
       
  5956 			# add mplayer specific options
       
  5957 			[[ "$cmd" == @(?(g)mplayer) ]] && COMPREPLY=( "${COMPREPLY[@]}" \
       
  5958 				$(compgen -W '-autoq -autosync -benchmark \
       
  5959 					-framedrop -h -help -hardframedrop \
       
  5960 					-identify -input -lircconf -loop \
       
  5961 					-nojoystick -nolirc -nortc -playlist \
       
  5962 					-quiet -really-quiet -rnd -sdp -skin \
       
  5963 					-slave -softsleep -speed -sstep \
       
  5964 					-use-stdin -dumpaudio -dumpfile \
       
  5965 					-dumpstream -dumpvideo -dumpmicrodvdsub\
       
  5966 					-dumpmpsub -dumpsrtsub -dumpjacosub \
       
  5967 					-dumpsami -dumpsub -osdlevel -af \
       
  5968 					-af-adv -ao -aofile -aop -delay -mixer \
       
  5969 					-nowaveheader -bpp -brightness \
       
  5970 					-contrast -display -double -dr -dxr2 \
       
  5971 					-fb -fbmode -fbmodeconfig -forcexv -fs \
       
  5972 					-geometry -hue -icelayer -jpeg \
       
  5973 					-monitor-dotclock -monitor-hfreq \
       
  5974 					-monitor-vfreq -monitoraspect \
       
  5975 					-nograbpointer -noslices -panscan \
       
  5976 					-rootwin -saturation -screenw -screenh \
       
  5977 					-stop-xscreensaver -vm -vo -vsync -wid \
       
  5978 					-xineramascreen -z -zrbw -zrcrop \
       
  5979 					-zrdev -zrfd -zrhelp -zrnorm -zrquality \
       
  5980 					-zrvdec -zrhdec -zrxdoff -zrydoff -y \
       
  5981 					-edl -edlout -enqueue -fixed-vo \
       
  5982 					-menu -menu-root -menu-cfg -shuffle \
       
  5983 					-format -aahelp -dfbopts -fstype \
       
  5984 					-guiwid -nokeepaspect -x --help \
       
  5985 					-aaosdcolor -aasubcolor -aadriver \
       
  5986 					-aaextended -aaeight' -- $cur) )
       
  5987 			# add mencoder specific options
       
  5988 			[[ "$cmd" = mencoder ]] && COMPREPLY=( "${COMPREPLY[@]}" \
       
  5989 				$(compgen -W '-audio-density -audio-delay \
       
  5990 					-audio-preload -divx4opts -endpos \
       
  5991 					-ffourcc -include -info -lameopts \
       
  5992 					-lavcopts -noskip -o -oac -ofps -ovc \
       
  5993 					-passlogfile -skiplimit -vobsubout \
       
  5994 					-vobsuboutindex -vobsuboutid \
       
  5995 					-xvidencopts -of --verbose' -- $cur) )
       
  5996 			;;
       
  5997 		*)
       
  5998 			_filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fli|FLI|flv|FLV|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[34]|MP[34]|m4v|M4V|og[gm]|OG[GM]|wav|WAV|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|ts|TS|3gp|mpc|MPC|flac|FLAC|flv|FLV|divx|DIVX)'
       
  5999 			;;
       
  6000 	esac
       
  6001 
       
  6002 	return 0
       
  6003 }
       
  6004 complete $filenames -F _mplayer mplayer mencoder gmplayer kplayer
       
  6005 }
       
  6006 
       
  6007 # KDE dcop completion
       
  6008 #
       
  6009 have dcop &&
       
  6010 _dcop()
       
  6011 {
       
  6012 	local cur compstr
       
  6013 
       
  6014 	COMPREPLY=()
       
  6015 	cur=`_get_cword`
       
  6016 	if [ -z $cur ]; then
       
  6017 	    compstr=${COMP_WORDS[*]}
       
  6018 	else
       
  6019 	    compstr=$( command echo ${COMP_WORDS[*]} | sed "s/ $cur$//" )
       
  6020 	fi
       
  6021 	COMPREPLY=( $( compgen -W '$( command $compstr | sed s/\(.*\)// )'  -- $cur ) )
       
  6022 } &&
       
  6023 complete -F _dcop dcop
       
  6024 
       
  6025 # wvdial(1) completion
       
  6026 #
       
  6027 have wvdial &&
       
  6028 _wvdial()
       
  6029 {
       
  6030 	local cur prev config i IFS=$'\t\n'
       
  6031 
       
  6032 	COMPREPLY=()
       
  6033 	cur=`_get_cword`
       
  6034 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  6035 
       
  6036 	case $prev in
       
  6037 		--config)
       
  6038 			_filedir
       
  6039 			return 0
       
  6040 			;;
       
  6041 	esac
       
  6042 
       
  6043 	case $cur in
       
  6044 		-*)
       
  6045 			COMPREPLY=( $( compgen -W '--config --chat \
       
  6046 				--remotename --help --version --no-syslog' \
       
  6047 				-- $cur ) )
       
  6048 			;;
       
  6049 		*)
       
  6050 			# start with global and personal config files
       
  6051 		       	config="/etc/wvdial.conf"$'\t'"$HOME/.wvdialrc"
       
  6052 			# replace with command line config file if present
       
  6053 			for (( i=1; i < COMP_CWORD; i++ )); do
       
  6054 				if [[ "${COMP_WORDS[i]}" == "--config" ]]; then
       
  6055 					config=${COMP_WORDS[i+1]}
       
  6056 					break
       
  6057 				fi
       
  6058 			done
       
  6059 			# parse config files for sections and
       
  6060 			# remove default section
       
  6061 			COMPREPLY=( $( sed -ne \
       
  6062 				    "s|^\[Dialer \($cur.*\)\]$|\1|p" \
       
  6063 				    $config 2>/dev/null |grep -v '^Defaults$'))
       
  6064 			# escape spaces
       
  6065 			COMPREPLY=${COMPREPLY// /\\ }
       
  6066 			;;
       
  6067 	esac
       
  6068 
       
  6069 } &&
       
  6070 complete -F _wvdial wvdial
       
  6071 
       
  6072 # gpg(1) completion
       
  6073 #
       
  6074 have gpg &&
       
  6075 _gpg() 
       
  6076 {
       
  6077 	local cur prev
       
  6078 
       
  6079 	COMPREPLY=()
       
  6080 	cur=`_get_cword`
       
  6081 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  6082 
       
  6083 	case "$prev" in
       
  6084 	-@(s|-sign|-clearsign|-decrypt-files|-load-extension)) 
       
  6085 		_filedir
       
  6086 		return 0
       
  6087 		;;
       
  6088 	--@(export|@(?(l|nr|nrl)sign|edit)-key)) 
       
  6089 		# return list of public keys
       
  6090 		COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*/\([^ ]*\).*\(<\([^>]*\)>\).*$@\1 \3@p')" -- "$cur" ))
       
  6091 		return 0
       
  6092 		;;
       
  6093 	-@(r|-recipient))
       
  6094 		COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ))
       
  6095 		if [ -e ~/.gnupg/gpg.conf ]; then
       
  6096 			COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf  )" -- "$cur") )
       
  6097 		fi
       
  6098 		return 0
       
  6099 		;;
       
  6100 	esac
       
  6101 
       
  6102 	if [[ "$cur" == -* ]]; then
       
  6103 		COMPREPLY=( $( compgen -W '-s -b -e -f -c -d -a -r -u -Z -o -v\
       
  6104 				-q -n -N $(gpg --dump-options)' -- $cur ) )
       
  6105 	 fi
       
  6106 
       
  6107 } &&
       
  6108 complete -F _gpg $default gpg
       
  6109 
       
  6110 # iconv(1) completion
       
  6111 #
       
  6112 have iconv &&
       
  6113 _iconv()
       
  6114 {
       
  6115 	local cur prev
       
  6116 
       
  6117 	COMPREPLY=()
       
  6118 	cur=`_get_cword`
       
  6119 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  6120 
       
  6121 	case "$prev" in
       
  6122 		-@(f|t|-@(from|to)-code))
       
  6123 			COMPREPLY=( $( compgen -W \
       
  6124 			    '$( iconv --list | sed -e "s@//@@;" )' -- "$cur" ) )
       
  6125 			return 0
       
  6126 			;;
       
  6127 	esac
       
  6128 
       
  6129 
       
  6130 	if [[ "$cur" = -* ]]; then
       
  6131 		COMPREPLY=( $( compgen -W '--from-code -f --to-code -t --list
       
  6132 		--output -o --verbose' -- "$cur" ) )
       
  6133 		return 0
       
  6134 	fi
       
  6135 } &&
       
  6136 complete -F _iconv $default iconv
       
  6137 
       
  6138 # dict(1) completion
       
  6139 #
       
  6140 { have dict || have rdict; } && {
       
  6141 _dictdata()
       
  6142 {
       
  6143 	dict $host $port $1 2>/dev/null | sed -ne \
       
  6144 	    's/^['$'\t '']['$'\t '']*\([^'$'\t '']*\).*$/\1/p'
       
  6145 }
       
  6146 
       
  6147 _dict()
       
  6148 {
       
  6149 	local cur prev host port db dictfile
       
  6150 
       
  6151 	COMPREPLY=()
       
  6152 	cur=`_get_cword`
       
  6153 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  6154 	dictfile=/usr/share/dict/words
       
  6155 
       
  6156 	for (( i=1; i < COMP_CWORD; i++ )); do
       
  6157 		case "${COMP_WORDS[i]}" in
       
  6158 		-@(h|--host))
       
  6159 			host=${COMP_WORDS[i+1]}
       
  6160 			[ -n "$host" ] && host="-h $host"
       
  6161 			i=$((++i))
       
  6162 			;;
       
  6163 		-@(p|-port))
       
  6164 			port=${COMP_WORDS[i+1]}
       
  6165 			[ -n "$port" ] && port="-p $port"
       
  6166 			i=$((++i))
       
  6167 			;;
       
  6168 		-@(d|-database))
       
  6169 			db=${COMP_WORDS[i+1]}
       
  6170 			[ -n "$db" ] && host="-d $db"
       
  6171 			i=$((++i))
       
  6172 			;;
       
  6173 		*)
       
  6174 			;;
       
  6175 		esac
       
  6176 	done
       
  6177 
       
  6178 	if [[ "$cur" = -* ]]; then
       
  6179 		COMPREPLY=( $( compgen -W '-h --host -p --port -d --database \
       
  6180 			       -m --match -s --strategy -c --config -C \
       
  6181 			       --nocorrect -D --dbs -S --strats -H \
       
  6182 			       --serverhelp -i --info -I --serverinfo \
       
  6183 			       -a --noauth -u --user -k --key -V --version \
       
  6184 			       -L --license --help -v --verbose -r --raw \
       
  6185 			       -P --pager --debug --html --pipesize --client' \
       
  6186 			       -- "$cur" ) )
       
  6187 		return 0
       
  6188 	fi
       
  6189 
       
  6190 	case "$prev" in
       
  6191 	-@(d|-database|i|info))
       
  6192 		COMPREPLY=( $( compgen -W '$( _dictdata -D )' -- "$cur" ) )
       
  6193 		return 0
       
  6194 		;;
       
  6195 	-@(s|-strategy))
       
  6196 		COMPREPLY=( $( compgen -W '$( _dictdata -S )' -- "$cur" ) )
       
  6197 		return 0
       
  6198 		;;
       
  6199 	*)
       
  6200 		;;
       
  6201 	esac
       
  6202 
       
  6203 	[ -r $dictfile ] && \
       
  6204 		COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) )
       
  6205 }
       
  6206 complete -F _dict $default dict rdict
       
  6207 }
       
  6208 
       
  6209 # cdrecord(1) completion
       
  6210 #
       
  6211 have cdrecord &&
       
  6212 _cdrecord()
       
  6213 {
       
  6214 	local cur prev i generic_options track_options track_mode
       
  6215 
       
  6216 	COMPREPLY=()
       
  6217 	cur=`_get_cword`
       
  6218 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  6219 
       
  6220 	# foo=bar style option
       
  6221 	if [[ "$cur" == *=* ]]; then
       
  6222 		prev=${cur/=*/}
       
  6223 		cur=${cur/*=/}
       
  6224 		case "$prev" in
       
  6225 			@(text|cue)file)
       
  6226 				_filedir
       
  6227 				return 0
       
  6228 				;;
       
  6229 			blank)
       
  6230 				COMPREPLY=( $( compgen -W 'help all fast \
       
  6231 				track unreserve trtail unclose session' \
       
  6232 				-- $cur ) )
       
  6233 				return 0
       
  6234 				;;
       
  6235 			driveropts)
       
  6236 				COMPREPLY=( $( compgen -W 'burnfree noburnfree\
       
  6237 				  varirec= audiomaster forcespeed noforcespeed\
       
  6238 				  speedread nospeedread singlesession \
       
  6239 				  nosinglesession hidecdr nohidecdr tattooinfo\
       
  6240 				  tattoofile=' -- $cur ) )
       
  6241 				return 0
       
  6242 				;;
       
  6243 		esac
       
  6244 	fi
       
  6245 
       
  6246 	generic_options=(-version -v -V -d -silent -s -force -immed -dummy \
       
  6247 			 -dao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc \
       
  6248 			 -atip -fix -nofix -waiti -load -lock -eject -format \
       
  6249 			 -setdropts -checkdrive -prcap -inq -scanbus -reset \
       
  6250 			 -abort -overburn -ignsize -useinfo -packet -noclose \
       
  6251 			 -text debug= kdebug= kd= minbuf= speed= blank= fs= \
       
  6252 			 dev= gracetime= timeout= driver= driveropts= \
       
  6253 			 defpregap= pktsize= mcn= textfile= cuefile=)
       
  6254 	track_options=(-audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi \
       
  6255 		       -isosize -pad padsize= -nopad -shorttrack -noshorttrack\
       
  6256 		       pregap= -preemp -nopreemp -copy -nocopy -scms tcsize= \
       
  6257 		       isrc= index=)
       
  6258 	# look if previous was either a file or a track option
       
  6259 	track_mode=0
       
  6260 	if [ $COMP_CWORD -gt 1 ]; then
       
  6261 		if [ -f "$prev" ]; then
       
  6262 			track_mode=1
       
  6263 		else
       
  6264 			for (( i=0; i < ${#track_options[@]}; i++ )); do
       
  6265 				if [[ "${track_options[i]}" == "$prev" ]]; then
       
  6266 					track_mode=1
       
  6267 					break
       
  6268 				fi
       
  6269 			done
       
  6270 		fi
       
  6271 	fi
       
  6272 
       
  6273 	# files are always eligible completion
       
  6274 	_filedir
       
  6275 	# track options are always available
       
  6276 	COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '${track_options[@]}' -- $cur ) )
       
  6277 	# general options are no more available after file or track option
       
  6278 	if [ $track_mode -eq 0 ]; then
       
  6279 		COMPREPLY=( "${COMPREPLY[@]}" \
       
  6280 			    $( compgen -W '${generic_options[@]}' -- $cur ) )
       
  6281 	fi
       
  6282 
       
  6283 } &&
       
  6284 complete -F _cdrecord $filenames cdrecord
       
  6285 
       
  6286 # mkisofs(8) completion
       
  6287 #
       
  6288 have mkisofs &&
       
  6289 _mkisofs()
       
  6290 {
       
  6291 	local cur prev
       
  6292 
       
  6293 	COMPREPLY=()
       
  6294 	cur=`_get_cword`
       
  6295 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  6296 
       
  6297 	case "$prev" in
       
  6298 		-@(o|abstract|biblio|check-session|copyright|log-file|root-info|prep-boot|*-list))
       
  6299 			_filedir
       
  6300 			return 0
       
  6301 			;;
       
  6302 		-*-charset)
       
  6303 			COMPREPLY=( $( mkisofs -input-charset help 2>&1 | \
       
  6304 					tail +3 | grep "^$cur") )
       
  6305 			return 0
       
  6306 			;;
       
  6307 		-uid)
       
  6308 			_uids
       
  6309 			return 0
       
  6310 			;;
       
  6311 		-gid)
       
  6312 			_gids
       
  6313 			return 0
       
  6314 			;;
       
  6315 	esac
       
  6316 
       
  6317 	if [[ "$cur" == -* ]]; then
       
  6318 		COMPREPLY=( $( compgen -W '-abstract -A -allow-lowercase \
       
  6319 				-allow-multidot -biblio -cache-inodes \
       
  6320 				-no-cache-inodes -b -eltorito-alt-boot -B -G \
       
  6321 				-hard-disk-boot -no-emul-boot -no-boot \
       
  6322 				-boot-load-seg -boot-load-size \
       
  6323 				-boot-info-table -C -c -check-oldname \
       
  6324 				-check-session -copyright -d -D -dir-mode \
       
  6325 				-dvd-video -f -file-mode -gid -gui \
       
  6326 				-graft-points -hide -hide-list -hidden \
       
  6327 				-hidden-list -hide-joliet -hide-joliet-list \
       
  6328 				-hide-joliet-trans-tbl -hide-rr-moved \
       
  6329 				-input-charset -output-charset -iso-level -J \
       
  6330 				-joliet-long -jcharset -l -L -log-file -m \
       
  6331 				-exclude-list -max-iso9660-filenames -M -N \
       
  6332 				-new-dir-mode -nobak -no-bak -force-rr -no-rr \
       
  6333 				-no-split-symlink-components \
       
  6334 				-no-split-symlink-fields -o -pad -no-pad \
       
  6335 				-path-list -P -p -print-size -quiet -R -r \
       
  6336 				-relaxed-filenames -sort -split-output \
       
  6337 				-stream-media-size -stream-file-name -sysid -T\
       
  6338 				-table-name -ucs-level -udf -uid \
       
  6339 				-use-fileversion -U -no-iso-translate -V \
       
  6340 				-volset -volset-size -volset-seqno -v -x -z \
       
  6341 				-hfs -apple -map -magic -hfs-creator \
       
  6342 				-hfs-type -probe -no-desktop -mac-name \
       
  6343 				-boot-hfs-file -part -auto -cluster-size \
       
  6344 				-hide-hfs -hide-hfs-list -hfs-volid \
       
  6345 				-icon-position -root-info -prep-boot \
       
  6346 				-input-hfs-charset -output-hfs-charset \
       
  6347 				-hfs-unlock -hfs-bless -hfs-parms --cap \
       
  6348 				--netatalk --double --ethershare --ushare \
       
  6349 				--exchange --sgi --xinet --macbin --single \
       
  6350 				--dave --sfm --osx-double --osx-hfs' -- $cur ))
       
  6351 	else
       
  6352 		_filedir
       
  6353 	fi
       
  6354 
       
  6355 } &&
       
  6356 complete -F _mkisofs $filenames mkisofs
       
  6357 
       
  6358 # mc(1) completion
       
  6359 #
       
  6360 have mc &&
       
  6361 _mc()
       
  6362 {
       
  6363 	local cur prev
       
  6364 
       
  6365 	COMPREPLY=()
       
  6366 	cur=`_get_cword`
       
  6367 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  6368 
       
  6369 	# -name value style option
       
  6370 	case "$prev" in
       
  6371 		-@(e|v|l|P))
       
  6372 			_filedir
       
  6373 			return 0
       
  6374 			;;
       
  6375 	esac
       
  6376 
       
  6377 	# --name=value style option
       
  6378 	if [[ "$cur" == *=* ]]; then
       
  6379 		prev=${cur/=*/}
       
  6380 		cur=${cur/*=/}
       
  6381 		case "$prev" in
       
  6382 			--@(edit|view|ftplog|printwd))
       
  6383 				_filedir
       
  6384 				return 0
       
  6385 				;;
       
  6386 		esac
       
  6387 	fi
       
  6388 
       
  6389 	if [[ "$cur" == -* ]]; then
       
  6390 		COMPREPLY=( $( compgen -W '-a --stickchars -b --nocolor -c \
       
  6391 			--color -C --colors= -d --nomouse -e --edit= -f \
       
  6392 			--datadir -k --resetsoft -l --ftplog= -P --printwd= \
       
  6393 			-s --slow -t --termcap -u --nosubshell -U --subshell \
       
  6394 			-v --view= -V --version -x --xterm -h --help' -- $cur ) )
       
  6395 	else
       
  6396 		_filedir -d
       
  6397 	fi
       
  6398 } &&
       
  6399 complete -F _mc $filenames mc
       
  6400 
       
  6401 # yum(8) completion
       
  6402 #
       
  6403 have yum && {
       
  6404 _yum()
       
  6405 {
       
  6406 	local cur prev special
       
  6407 	
       
  6408 	COMPREPLY=()
       
  6409 	cur=`_get_cword`
       
  6410 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  6411 
       
  6412 	for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
       
  6413 		if [[ ${COMP_WORDS[i]} == @(install|update|upgrade|remove|erase|deplist) ]]; then
       
  6414 			special=${COMP_WORDS[i]}
       
  6415 		fi
       
  6416 	done
       
  6417 
       
  6418 	if [ -n "$special" ]; then
       
  6419 	    case $special in
       
  6420 		install|deplist)
       
  6421 		    COMPREPLY=( $( compgen -W '$( yum -C list | cut -d" " -f1 )' -- $cur ) )
       
  6422 		    return 0
       
  6423 		    ;;
       
  6424 		*)
       
  6425 		    _rpm_installed_packages
       
  6426 		    return 0
       
  6427 		    ;;
       
  6428 		esac
       
  6429 	fi
       
  6430 
       
  6431 	case $cur in
       
  6432 	    --*)
       
  6433 		COMPREPLY=( $( compgen -W '--installroot --version --help --enablerepo --disablerepo --exclude --obsoletes --noplugins' -- $cur ) )
       
  6434 		return 0
       
  6435 		;;
       
  6436 	    -*)
       
  6437 		COMPREPLY=( $( compgen -W '-c -e -d -y -t -R -C -h' -- $cur ) )
       
  6438 		return 0
       
  6439 		;;
       
  6440 	esac
       
  6441 
       
  6442 	case $prev in
       
  6443 	    list)
       
  6444 		COMPREPLY=( $( compgen -W 'all available updates installed extras obsoletes recent' -- $cur ) )
       
  6445 		;;
       
  6446 	    clean)
       
  6447 		COMPREPLY=( $( compgen -W 'packages headers metadata cache dbcache all' -- $cur ) )
       
  6448 		;;
       
  6449 	    localinstall)
       
  6450 		_filedir rpm
       
  6451 		;;
       
  6452 	    -c)
       
  6453 		_filedir
       
  6454 		;;
       
  6455 	    --installroot)
       
  6456 		_filedir -d
       
  6457 		;;
       
  6458 	    *)
       
  6459 		COMPREPLY=( $( compgen -W 'install update check-update upgrade remove list \
       
  6460 						search info provides clean groupinstall groupupdate \
       
  6461 						grouplist deplist erase groupinfo groupremove \
       
  6462 						localinstall localupdate makecache resolvedep \
       
  6463 						shell whatprovides' -- $cur ) )
       
  6464 		;;
       
  6465 	esac
       
  6466 }
       
  6467 complete -F _yum $filenames yum
       
  6468 
       
  6469 # yum-arch(8) completion
       
  6470 #
       
  6471 _yum_arch()
       
  6472 {
       
  6473     local cur
       
  6474     COMPREPLY=()
       
  6475     cur=`_get_cword`
       
  6476 
       
  6477     case "$cur" in
       
  6478 	-*)
       
  6479 	    COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l -q' -- $cur ) )
       
  6480 	    ;;
       
  6481 	*)
       
  6482 	    _filedir -d
       
  6483 	    ;;
       
  6484     esac
       
  6485 
       
  6486     return 0
       
  6487 
       
  6488 }
       
  6489 complete -F _yum_arch $filenames yum-arch
       
  6490 }
       
  6491 
       
  6492 # ImageMagick completion
       
  6493 #
       
  6494 have convert && {
       
  6495 _ImageMagick()
       
  6496 {
       
  6497 	local prev
       
  6498 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  6499 
       
  6500 	case "$prev" in
       
  6501 		-channel)
       
  6502 			COMPREPLY=( $( compgen -W 'Red Green Blue Opacity \
       
  6503 				Matte Cyan Magenta Yellow Black' -- $cur ) )
       
  6504 			return 0
       
  6505 			;;
       
  6506 		-colormap)
       
  6507 			COMPREPLY=( $( compgen -W 'shared private' -- $cur ) )
       
  6508 			return 0
       
  6509 			;;
       
  6510 		-colorspace)
       
  6511 			COMPREPLY=( $( compgen -W 'GRAY OHTA RGB Transparent \
       
  6512 				XYZ YCbCr YIQ YPbPr YUV CMYK' -- $cur ) )
       
  6513 			return 0
       
  6514 			;;
       
  6515 		-compose)
       
  6516 			COMPREPLY=( $( compgen -W 'Over In Out Atop Xor Plus \
       
  6517 				Minus Add Subtract Difference Multiply Bumpmap\
       
  6518 				Copy CopyRed CopyGreen CopyBlue CopyOpacity' \
       
  6519 				-- $cur ) )
       
  6520 			return 0
       
  6521 			;;
       
  6522 		-compress)
       
  6523 			COMPREPLY=( $( compgen -W 'None BZip Fax Group4 JPEG \
       
  6524 				Lossless LZW RLE Zip' -- $cur ) )
       
  6525 			return 0
       
  6526 			;;
       
  6527 		-dispose)
       
  6528 			COMPREPLY=( $( compgen -W 'Undefined None Background \
       
  6529 						    Previous' -- $cur ) )
       
  6530 			return 0
       
  6531 			;;
       
  6532 		-encoding)
       
  6533 			COMPREPLY=( $( compgen -W 'AdobeCustom AdobeExpert \
       
  6534 				AdobeStandard AppleRoman BIG5 GB2312 Latin2 \
       
  6535 				None SJIScode Symbol Unicode Wansung' -- $cur))
       
  6536 			return 0
       
  6537 			;;
       
  6538 		-endian)
       
  6539 			COMPREPLY=( $( compgen -W 'MSB LSB' -- $cur ) )
       
  6540 			return 0
       
  6541 			;;
       
  6542 		-filter)
       
  6543 			COMPREPLY=( $( compgen -W 'Point Box Triangle Hermite \
       
  6544 				Hanning Hamming Blackman Gaussian Quadratic \
       
  6545 				Cubic Catrom Mitchell Lanczos Bessel Sinc' \
       
  6546 				-- $cur ) )
       
  6547 			return 0
       
  6548 			;;
       
  6549 		-format)
       
  6550 			COMPREPLY=( $( convert -list format | \
       
  6551 				    awk '/ [r-][w-][+-] / {print $1}' | \
       
  6552 				    tr -d '*' | tr [:upper:] [:lower:] | \
       
  6553 				    grep "^$cur" ) )
       
  6554 			return 0
       
  6555 			;;
       
  6556 		-gravity)
       
  6557 			COMPREPLY=( $( compgen -W 'Northwest North NorthEast \
       
  6558 				West Center East SouthWest South SouthEast' \
       
  6559 				-- $cur ) )
       
  6560 			return 0
       
  6561 			;;
       
  6562 		-intent)
       
  6563 			COMPREPLY=( $( compgen -W 'Absolute Perceptual \
       
  6564 					Relative Saturation' -- $cur ) )
       
  6565 			return 0
       
  6566 			;;
       
  6567 		-interlace)
       
  6568 			COMPREPLY=( $( compgen -W 'None Line Plane Partition' \
       
  6569 					-- $cur ) )
       
  6570 			return 0
       
  6571 			;;
       
  6572 		-limit)
       
  6573 			COMPREPLY=( $( compgen -W 'Disk File Map Memory' \
       
  6574 					-- $cur ) )
       
  6575 			return 0
       
  6576 			;;
       
  6577 		-list)
       
  6578 			COMPREPLY=( $( compgen -W 'Delegate Format Magic \
       
  6579 					Module Resource Type' -- $cur ) )
       
  6580 			return 0
       
  6581 			;;
       
  6582 		-map)
       
  6583 			COMPREPLY=( $( compgen -W 'best default gray red \
       
  6584 					green blue' -- $cur ) )
       
  6585 			_filedir
       
  6586 			return 0
       
  6587 			;;
       
  6588 		-noise)
       
  6589 			COMPREPLY=( $( compgen -W 'Uniform Gaussian \
       
  6590 					Multiplicative \
       
  6591 				Impulse Laplacian Poisson' -- $cur ) )
       
  6592 			return 0
       
  6593 			;;
       
  6594 		-preview)
       
  6595 			COMPREPLY=( $( compgen -W 'Rotate Shear Roll Hue \
       
  6596 					Saturation Brightness Gamma Spiff \
       
  6597 					Dull Grayscale Quantize Despeckle \
       
  6598 					ReduceNoise AddNoise Sharpen Blur \
       
  6599 					Treshold EdgeDetect Spread Shade \
       
  6600 					Raise Segment Solarize Swirl Implode \
       
  6601 					Wave OilPaint CharcoalDrawing JPEG' \
       
  6602 					-- $cur ) )
       
  6603 			return 0
       
  6604 			;;
       
  6605 		-@(mask|profile|texture|tile|write))
       
  6606 			_filedir
       
  6607 			return 0
       
  6608 			;;
       
  6609 		-type)
       
  6610 			COMPREPLY=( $( compgen -W 'Bilevel Grayscale Palette \
       
  6611 					PaletteMatte TrueColor TrueColorMatte \
       
  6612 					ColorSeparation ColorSeparationlMatte \
       
  6613 					Optimize' -- $cur ) )
       
  6614 			return 0
       
  6615 			;;
       
  6616 		-units)
       
  6617 			COMPREPLY=( $( compgen -W 'Undefined PixelsPerInch \
       
  6618 					PixelsPerCentimeter' -- $cur ) )
       
  6619 			return 0
       
  6620 			;;
       
  6621 		-virtual-pixel)
       
  6622 			COMPREPLY=( $( compgen -W 'Constant Edge mirror tile' \
       
  6623 					-- $cur ) )
       
  6624 			return 0
       
  6625 			;;
       
  6626 		-visual)
       
  6627 			COMPREPLY=( $( compgen -W 'StaticGray GrayScale \
       
  6628 					StaticColor PseudoColor TrueColor \
       
  6629 					DirectColor defaut visualid' -- $cur ))
       
  6630 			return 0
       
  6631 			;;
       
  6632 	esac
       
  6633 }
       
  6634 
       
  6635 _convert()
       
  6636 {
       
  6637 	local cur
       
  6638 
       
  6639 	COMPREPLY=()
       
  6640 	cur=`_get_cword`
       
  6641 
       
  6642 	_ImageMagick
       
  6643 
       
  6644 	if [[ "$cur" == -* ]]; then
       
  6645 		COMPREPLY=( $( compgen -W '-adjoin -affine -antialias -append \
       
  6646 			-authenticate -average -background -black-threshold \
       
  6647 			-blue-primary -blur -border -bordercolor -channel \
       
  6648 			-charcoal -chop -clip -coalesce -colorize -colors \
       
  6649 			-colorspace -comment -compress -contrast -convolve \
       
  6650 			-crop -cycle -debug -deconstruct -delay -density \
       
  6651 			-depth -despeckle -display -dispose -dither -draw \
       
  6652 			-edge -emboss -encoding -endian -enhance -equalize \
       
  6653 			-extract -fill -filter -flatten -flip -flop -font \
       
  6654 			-frame -fuzz -gamma -gaussian -geometry \
       
  6655 			-green-primary -gravity -help -implode -intent \
       
  6656 			-interlace -label -lat -level -limit -list -log -loop \
       
  6657 			-map -mask -matte -median -modulate -monochrome \
       
  6658 			-morph -mosaic -negate -noop -noise -normalize \
       
  6659 			-opaque -ordered-dither -page -paint -ping -pointsize \
       
  6660 			-preview -profile -quality -raise -random-threshold \
       
  6661 			-region -raise -red-primary -render -resize -resample \
       
  6662 			-roll -rotate -sample -sampling-factor -scale -scene \
       
  6663 			-seed -segment -shade -sharpen -shave -shear -size \
       
  6664 			-solarize -spread -stroke -strokewidth -swirl \
       
  6665 			-texture -threshold -thumbnail -tile -transform \
       
  6666 			-transparent -treedepth -trim -type -undercolor \
       
  6667 			-units -unsharp -verbose -version -view \
       
  6668 			-virtual-pixel -wave -white-point -white-threshold \
       
  6669 			-write' -- $cur ) )
       
  6670 	elif [[ "$cur" == +* ]]; then
       
  6671 		COMPREPLY=( $( compgen -W '+adjoin +append +compress \
       
  6672 			+contrast +debug +dither +endian +gamma +label +map \
       
  6673 			+mask +matte +negate +noise +page +raise +render \
       
  6674 			+write' -- $cur ) ) 
       
  6675 	else
       
  6676 		_filedir
       
  6677 	fi
       
  6678 }
       
  6679 complete -F _convert $filenames convert
       
  6680 
       
  6681 _mogrify()
       
  6682 {
       
  6683 	local cur
       
  6684 
       
  6685 	COMPREPLY=()
       
  6686 	cur=`_get_cword`
       
  6687 
       
  6688 	_ImageMagick
       
  6689 
       
  6690 	if [[ "$cur" == -* ]]; then
       
  6691 		COMPREPLY=( $( compgen -W '-affine -antialias -authenticate \
       
  6692 			-background -black-threshold -blue-primary -blur \
       
  6693 			-border -bordercolor -channel -charcoal -chop \
       
  6694 			-colorize -colors -colorspace -comment -compress \
       
  6695 			-contrast -convolve -crop -cycle -debug -delay \
       
  6696 			-density -depth -despeckle -display -dispose -dither \
       
  6697 			-draw -edge -emboss -encoding -endian -enhance \
       
  6698 			-equalize -extract -fill -filter -flip -flop -font \
       
  6699 			-format -frame -fuzz -gamma -gaussian -geometry \
       
  6700 			-green-primary -implode -interlace -help -label -lat \
       
  6701 			-level -limit -list -log -loop -map -mask -matte \
       
  6702 			-median -modulate -monochrome -negate -noop \
       
  6703 			-normalize -opaque -page -paint -fill -ordered-dither \
       
  6704 			-pointsize -profile -quality -raise -random-threshold \
       
  6705 			-red-primary -region -resample -resize -roll -rotate \
       
  6706 			-sample -sampling-factor -scale -scene -seed -segment \
       
  6707 			-shade -sharpen -shear -size -solarize -spread \
       
  6708 			-stroke -strokewidth -swirl -texture -threshold \
       
  6709 			-thumbnail -tile -transform -transparent -treedepth \
       
  6710 			-trim -type -undercolor -units -unsharp -verbose \
       
  6711 			-version -view -virtual-pixel -wave -white-point \
       
  6712 			-white-threshold' -- $cur ) )
       
  6713 	elif [[ "$cur" == +* ]]; then
       
  6714 		COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
       
  6715 			+endian +gamma +label +map +mask +matte +negate +page \
       
  6716 			+raise' -- $cur ) ) 
       
  6717 	else
       
  6718 		_filedir
       
  6719 	fi
       
  6720 }
       
  6721 complete -F _mogrify $filenames mogrify
       
  6722 
       
  6723 _display()
       
  6724 {
       
  6725 	local cur
       
  6726 
       
  6727 	COMPREPLY=()
       
  6728 	cur=`_get_cword`
       
  6729 
       
  6730 	_ImageMagick
       
  6731 
       
  6732 	if [[ "$cur" == -* ]]; then
       
  6733 		COMPREPLY=( $( compgen -W '-authenticate -backdrop -border \
       
  6734 			-colormap -colors -colorspace -comment -compress \
       
  6735 			-contrast -crop -debug -delay -density -depth \
       
  6736 			-despeckle -display -dispose -dither -edge -endian \
       
  6737 			-enhance -extract -filter -flip -flop -frame -gamma \
       
  6738 			-geometry -help -immutable -interlace -label -limit \
       
  6739 			-log -map -matte -monochrome -negate -noop -page \
       
  6740 			-quality -raise -remote -roll -rotate -sample \
       
  6741 			-sampling-factor -scene -segment -sharpen -size \
       
  6742 			-texture -treedepth -trim -update -verbose -version \
       
  6743 			-virtual-pixel -window -window_group -write' -- $cur))
       
  6744 	elif [[ "$cur" == +* ]]; then
       
  6745 		COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
       
  6746 			+endian +gamma +label +map +matte +negate +page \
       
  6747 			+raise +write' -- $cur ) ) 
       
  6748 	else
       
  6749 		_filedir
       
  6750 	fi
       
  6751 }
       
  6752 complete -F _display $filenames display
       
  6753 
       
  6754 _animate()
       
  6755 {
       
  6756 	local cur
       
  6757 
       
  6758 	COMPREPLY=()
       
  6759 	cur=`_get_cword`
       
  6760 
       
  6761 	_ImageMagick
       
  6762 
       
  6763 	if [[ "$cur" == -* ]]; then
       
  6764 		COMPREPLY=( $( compgen -W '-authenticate -backdrop -colormap \
       
  6765 			-colors -colorspace -crop -debug -delay -density \
       
  6766 			-depth -display -dither -extract -gamma -geometry \
       
  6767 			-help -interlace -limit -log -matte -map -monochrome \
       
  6768 			-noop -pause -remote -rotate -sampling-factor -scene \
       
  6769 			-size -treedepth -trim -verbose -version -visual \
       
  6770 			-virtual-pixel -window' -- $cur ) )
       
  6771 	elif [[ "$cur" == +* ]]; then
       
  6772 		COMPREPLY=( $( compgen -W '+debug +dither +gamma +map +matte' -- $cur ) ) 
       
  6773 	else
       
  6774 		_filedir
       
  6775 	fi
       
  6776 }
       
  6777 complete -F _animate $filenames animate
       
  6778 
       
  6779 _identify()
       
  6780 {
       
  6781 	local cur
       
  6782 
       
  6783 	COMPREPLY=()
       
  6784 	cur=`_get_cword`
       
  6785 
       
  6786 	_ImageMagick
       
  6787 
       
  6788 	if [[ "$cur" == -* ]]; then
       
  6789 		COMPREPLY=( $( compgen -W '-authenticate -debug -density \
       
  6790 			-depth -extract -format -help -interlace -limit -list \
       
  6791 			-log -size -sampling-factor -verbose -version \
       
  6792 			-virtual-pixel' -- $cur ) )
       
  6793 	elif [[ "$cur" == +* ]]; then
       
  6794 		COMPREPLY=( $( compgen -W '+debug ' -- $cur ) ) 
       
  6795 	else
       
  6796 		_filedir
       
  6797 	fi
       
  6798 }
       
  6799 complete -F _identify $filenames identify
       
  6800 
       
  6801 _montage()
       
  6802 {
       
  6803 	local cur
       
  6804 
       
  6805 	COMPREPLY=()
       
  6806 	cur=`_get_cword`
       
  6807 
       
  6808 	_ImageMagick
       
  6809 
       
  6810 	if [[ "$cur" == -* ]]; then
       
  6811 		COMPREPLY=( $( compgen -W '-adjoin -affine -authenticate \
       
  6812 			-blue-primary -blur -colors -colorspace -comment \
       
  6813 			-compose -compress -crop -debug -density -depth \
       
  6814 			-display -dispose -dither -draw -encoding -endian \
       
  6815 			-extract -fill -filter -flip -flop -frame -gamma \
       
  6816 			-geometry -gravity -green-primary -interlace -help \
       
  6817 			-label -limit -log -matte -mode -monochrome -noop \
       
  6818 			-page -pointsize -quality -red-primary -resize \
       
  6819 			-rotate -sampling-factor -scene -shadow -size \
       
  6820 			-stroke -texture -thumbnail -tile -transform \
       
  6821 			-transparent -treedepth -trim -type -verbose \
       
  6822 			-version -virtual-pixel -white-point' -- $cur ) )
       
  6823 	elif [[ "$cur" == +* ]]; then
       
  6824 		COMPREPLY=( $( compgen -W '+adjoin +compress +debug +dither \
       
  6825 			+endian +gamma +label +matte +page' -- $cur ) ) 
       
  6826 	else
       
  6827 		_filedir
       
  6828 	fi
       
  6829 }
       
  6830 complete -F _montage $filenames montage
       
  6831 
       
  6832 _composite()
       
  6833 {
       
  6834 	local cur
       
  6835 
       
  6836 	COMPREPLY=()
       
  6837 	cur=`_get_cword`
       
  6838 
       
  6839 	_ImageMagick
       
  6840 
       
  6841 	if [[ "$cur" == -* ]]; then
       
  6842 		COMPREPLY=( $( compgen -W '-affine -authenticate \
       
  6843 			-blue-primary -colors -colorspace -comment -compose \
       
  6844 			-compress -debug -density -depth -displace -display \
       
  6845 			-dispose -dissolve -dither -encoding -endian -extract \
       
  6846 			-filter -font -geometry -gravity -green-primary -help \
       
  6847 			-interlace -label -limit -log -matte -monochrome \
       
  6848 			-negate -page -profile -quality -red-primary -rotate \
       
  6849 			-resize -sampling-factor -scene -sharpen -size \
       
  6850 			-stegano -stereo -thumbnail -tile -transform \
       
  6851 			-treedepth -type -units -unsharp -verbose -version \
       
  6852 			-virtual-pixel -watermark -white-point -write' \
       
  6853 			-- $cur ) )
       
  6854 	elif [[ "$cur" == +* ]]; then
       
  6855 		COMPREPLY=( $( compgen -W '+compress +debug +dither +endian +label \
       
  6856 			+matte +negate +page +write' -- $cur ) ) 
       
  6857 	else
       
  6858 		_filedir
       
  6859 	fi
       
  6860 }
       
  6861 complete -F _composite $filenames composite
       
  6862 }
       
  6863 
       
  6864 # dd(1) completion
       
  6865 #
       
  6866 have dd &&
       
  6867 _dd()
       
  6868 {
       
  6869 	 local cur
       
  6870 
       
  6871 	 COMPREPLY=()
       
  6872 	cur=`_get_cword`
       
  6873 
       
  6874 	 case "$cur" in
       
  6875 	 if=*|of=*)
       
  6876 		 cur=${cur#*=}
       
  6877 		 _filedir
       
  6878 		 return 0
       
  6879 		 ;;
       
  6880 	 conv=*)
       
  6881 		 cur=${cur#*=}
       
  6882 		 COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock \
       
  6883 				lcase notrunc ucase swab noerror sync' \
       
  6884 				-- $cur ) )
       
  6885 		 return 0
       
  6886 		 ;;
       
  6887 	 esac
       
  6888 
       
  6889 	 _expand || return 0
       
  6890 
       
  6891 	 COMPREPLY=( $( compgen -W '--help --version' -- $cur ) \
       
  6892 		     $( compgen -W 'bs cbs conv count ibs if obs of seek skip'\
       
  6893 				-S '=' -- $cur ) )
       
  6894 } &&
       
  6895 complete -F _dd $nospace $filenames dd
       
  6896 
       
  6897 # CUPS cancel(1) completion
       
  6898 #
       
  6899 have cancel &&
       
  6900 _cancel()
       
  6901 {
       
  6902 	local cur
       
  6903 
       
  6904 	COMPREPLY=()
       
  6905 	cur=`_get_cword`
       
  6906 
       
  6907 	COMPREPLY=( $( lpstat | cut -d' ' -f1 | grep "^$cur" ) )
       
  6908 } &&
       
  6909 complete -F _cancel $filenames cancel
       
  6910 
       
  6911 # aspell(1) completion
       
  6912 #
       
  6913 have aspell && {
       
  6914 _aspell_dictionary()
       
  6915 {
       
  6916 	local datadir
       
  6917 	datadir=/usr/lib/aspell
       
  6918 	COMPREPLY=( $( command ls $datadir/*.@(multi|alias) ) )
       
  6919 	COMPREPLY=( ${COMPREPLY[@]%.@(multi|alias)} )
       
  6920 	COMPREPLY=( $( compgen -W '${COMPREPLY[@]#$datadir/}' -- $cur ) )
       
  6921 }
       
  6922 
       
  6923 _aspell()
       
  6924 {
       
  6925 	local cur prev
       
  6926 
       
  6927 	COMPREPLY=()
       
  6928 	cur=`_get_cword`
       
  6929 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  6930 
       
  6931 	# --name value style option
       
  6932 	case "$prev" in
       
  6933 		@(-c|-p|check))
       
  6934 			_filedir
       
  6935 			return 0
       
  6936 			;;
       
  6937 		@(dump|create|merge))
       
  6938 			COMPREPLY=( $( compgen -W 'master personal repl' -- $cur ) )
       
  6939 			return 0
       
  6940 			;;
       
  6941 		-d)
       
  6942 			_aspell_dictionary
       
  6943 			return 0
       
  6944 			;;
       
  6945 	esac
       
  6946 
       
  6947 	# --name=value style option
       
  6948 	if [[ "$cur" == *=* ]]; then
       
  6949 		prev=${cur/=*/}
       
  6950 		cur=${cur/*=/}
       
  6951 		case "$prev" in
       
  6952 			--@(conf|personal|repl|per-conf))
       
  6953 				_filedir
       
  6954 				return 0
       
  6955 				;;
       
  6956 			--@(conf-dir|data-dir|dict-dir|home-dir|local-data-dir|prefix))
       
  6957 				_filedir -d
       
  6958 				return 0
       
  6959 				;;
       
  6960 			--master)
       
  6961 				_aspell_dictionary
       
  6962 				return 0
       
  6963 				;;
       
  6964 			--mode)
       
  6965 				COMPREPLY=( $( compgen -W 'none url email sgml tex' -- $cur ) )
       
  6966 				return 0
       
  6967 				;; 
       
  6968 			--sug-mode)
       
  6969 				COMPREPLY=( $( compgen -W 'ultra fast normal bad-speller' -- $cur ) )
       
  6970 				return 0
       
  6971 				;;
       
  6972 			--keymapping)
       
  6973 				COMPREPLY=( $( compgen -W 'aspell ispell' -- $cur ) )
       
  6974 				return 0
       
  6975 				;;
       
  6976 		esac
       
  6977 	fi
       
  6978 
       
  6979 	if [[ "$cur" == -* ]]; then
       
  6980 		COMPREPLY=( $( compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= \
       
  6981 			--encoding= --add-filter= --rem-filter= --mode= -e \
       
  6982 			-H -t --add-extra-dicts= --rem-extra-dicts= \
       
  6983 			--home-dir= -W --ignore= --ignore-accents \
       
  6984 			--dont-ignore-accents --ignore-case --dont-ignore-case \
       
  6985 			--ignore-repl --dont-ignore-repl --jargon= --keyboard= \
       
  6986 			--lang= --language-tag= --local-data-dir= -d --master= \
       
  6987 			--module= --add-module-search-order= \
       
  6988 			--rem-module-search-order= --per-conf= -p --personal= \
       
  6989 			--prefix= --repl= -C -B --run-together --dont-run-together \
       
  6990 			--run-together-limit= --run-together-min= --save-repl \
       
  6991 			--dont-save-repl --set-prefix --dont-set-prefix --size= \
       
  6992 			--spelling= --strip-accents --dont-strip-accents \
       
  6993 			--sug-mode= --add-word-list-path= --rem-word-list-path= \
       
  6994 			-b -x --backup -b|-x --dont-backup --reverse --dont-reverse \
       
  6995 			--time --dont-time --keymapping= --add-email-quote= \
       
  6996 			--rem-email-quote= --email-margin= --add-tex-command= \
       
  6997 			--rem-tex-command= --tex-check-comments \
       
  6998 			--dont-tex-check-comments --add-tex-extension= \
       
  6999 			--rem-tex-extension= --add-sgml-check= --rem-sgml-check= \
       
  7000 			--add-sgml-extension= --rem-sgml-extension=' -- $cur ) )
       
  7001 	else
       
  7002 		COMPREPLY=( $( compgen -W '-? help -c check -a pipe -l list \
       
  7003 			config config soundslike filter -v version dump \
       
  7004 			create merge' -- $cur ) )
       
  7005 	fi
       
  7006 
       
  7007 }
       
  7008 complete -F _aspell $filenames aspell
       
  7009 }
       
  7010 
       
  7011 # xmms(1) completion
       
  7012 #
       
  7013 have xmms &&
       
  7014 _xmms()
       
  7015 {
       
  7016 	local cur
       
  7017 
       
  7018 	COMPREPLY=()
       
  7019 	cur=`_get_cword`
       
  7020 
       
  7021 	if [[ "$cur" == -* ]]; then
       
  7022 		COMPREPLY=( $( compgen -W '-h --help -r --rew -p --play \
       
  7023 			-u --pause -s --stop -t --play-pause -f --fwd -e \
       
  7024 			--enqueue -m --show-main-window -i --sm-client-id \
       
  7025 			-v --version' -- $cur ) )
       
  7026 	else
       
  7027 		_filedir '@(mp[23]|MP[23]|ogg|OGG|wav|WAV|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)'
       
  7028 
       
  7029 	fi
       
  7030 
       
  7031 } &&
       
  7032 complete -F _xmms $filenames xmms
       
  7033 
       
  7034 # info(1) completion
       
  7035 #
       
  7036 have info &&
       
  7037 _info()
       
  7038 {
       
  7039 	local cur infopath UNAME
       
  7040 
       
  7041 	COMPREPLY=()
       
  7042 	cur=`_get_cword`
       
  7043 
       
  7044 	_expand || return 0
       
  7045 
       
  7046 	# default completion if parameter contains /
       
  7047 	if [[ "$cur" == */* ]]; then
       
  7048 		_filedir
       
  7049 		return 0
       
  7050 	fi
       
  7051 
       
  7052 	infopath='/usr/share/info'
       
  7053 
       
  7054 	if [ "${INFOPATH: -1:1}" == ':' ]; then
       
  7055 		infopath=${INFOPATH}${infopath}
       
  7056 	elif [ ${INFOPATH:+set} ]; then
       
  7057 		infopath=$INFOPATH
       
  7058 	fi
       
  7059 
       
  7060 	infopath=$infopath:
       
  7061 	if [ -n "$cur" ]; then
       
  7062 		infopath="${infopath//://$cur* }"
       
  7063 	else
       
  7064 		infopath="${infopath//:// }"
       
  7065 	fi
       
  7066 
       
  7067 	# redirect stderr for when path doesn't exist
       
  7068 	COMPREPLY=( $( eval command ls "$infopath" 2>/dev/null ) )
       
  7069 	# weed out directory path names and paths to info pages
       
  7070 	COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
       
  7071 	# weed out info dir file
       
  7072 	for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do
       
  7073 		if [ "${COMPREPLY[$i]}" == 'dir' ]; then
       
  7074 			unset COMPREPLY[$i];
       
  7075 		fi;
       
  7076 	done  
       
  7077 	# strip suffix from info pages
       
  7078 	COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2)} )
       
  7079 	COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
       
  7080 
       
  7081 	return 0
       
  7082 } &&
       
  7083 complete -F _info $filenames info
       
  7084 
       
  7085 # dhclient(1) completion
       
  7086 #
       
  7087 have dhclient && _dhclient()
       
  7088 {
       
  7089 	local cur prev
       
  7090 
       
  7091 	COMPREPLY=()
       
  7092 	cur=`_get_cword`
       
  7093 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7094 
       
  7095 	case "$prev" in
       
  7096 		-@(cf|lf|pf|sf))
       
  7097 			_filedir
       
  7098 			return 0
       
  7099 			;;
       
  7100 		-s)
       
  7101 			_known_hosts
       
  7102 			return 0
       
  7103 			;;
       
  7104 	esac
       
  7105 
       
  7106 	if [[ "$cur" == -* ]]; then
       
  7107 		COMPREPLY=( $( compgen -W '-p -d -q -1 -r -lf -pf \
       
  7108 			-cf -sf -s -g -n -nw -w' -- $cur ) )
       
  7109 	else
       
  7110 		_available_interfaces
       
  7111 	fi
       
  7112 } &&
       
  7113 complete -F _dhclient dhclient
       
  7114 
       
  7115 # lvm(8) completion
       
  7116 #
       
  7117 have lvm && {
       
  7118 _volumegroups()
       
  7119 {
       
  7120 	COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \
       
  7121 	    sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- $cur ) )
       
  7122 }
       
  7123 
       
  7124 _physicalvolumes()
       
  7125 {
       
  7126 	COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \
       
  7127 	    sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- $cur ) )
       
  7128 }
       
  7129 
       
  7130 _logicalvolumes()
       
  7131 {
       
  7132 	COMPREPLY=( $(compgen -W "$( lvscan 2>/dev/null | \
       
  7133 	    sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- $cur ) )
       
  7134 }
       
  7135 
       
  7136 _units()
       
  7137 {
       
  7138 	COMPREPLY=( $( compgen -W 'h s b k m g t H K M G T' -- $cur ) )
       
  7139 }
       
  7140 
       
  7141 _sizes()
       
  7142 {
       
  7143 	COMPREPLY=( $( compgen -W 'k K m M g G t T' -- $cur ) )
       
  7144 }
       
  7145 
       
  7146 _args()
       
  7147 {
       
  7148 	args=0
       
  7149 	if [[ "${COMP_WORDS[0]}" == lvm ]]; then
       
  7150 		offset=2
       
  7151 	else
       
  7152 		offset=1
       
  7153 	fi
       
  7154 	for (( i=$offset; i < COMP_CWORD; i++ )); do
       
  7155 		if [[ "${COMP_WORDS[i]}" != -* ]]; then
       
  7156 			args=$(($args + 1))
       
  7157 		fi
       
  7158 	done
       
  7159 }
       
  7160 
       
  7161 _lvmdiskscan()
       
  7162 {
       
  7163 	local cur
       
  7164 
       
  7165 	COMPREPLY=()
       
  7166 	cur=`_get_cword`
       
  7167 
       
  7168 	if [[ "$cur" == -* ]]; then
       
  7169 		COMPREPLY=( $( compgen -W '-d --debug -h -? --help -l \
       
  7170 			--lvmpartition -v --verbose --version' -- $cur ) )
       
  7171 	fi
       
  7172 }
       
  7173 complete -F _lvmdiskscan lvmdiskscan
       
  7174 
       
  7175 _pvscan()
       
  7176 {
       
  7177 	local cur
       
  7178 
       
  7179 	COMPREPLY=()
       
  7180 	cur=`_get_cword`
       
  7181 
       
  7182 	if [[ "$cur" == -* ]]; then
       
  7183 		COMPREPLY=( $( compgen -W '-d --debug -e \
       
  7184 			--exported -n --novolumegroup -h -? \
       
  7185 			--help --ignorelockingfailure -P \
       
  7186 			--partial -s --short -u --uuid -v \
       
  7187 			--verbose --version' -- $cur ) )
       
  7188 	fi
       
  7189 }
       
  7190 complete -F _pvscan pvscan
       
  7191 
       
  7192 _pvs()
       
  7193 {
       
  7194 	local cur prev
       
  7195 
       
  7196 	COMPREPLY=()
       
  7197 	cur=`_get_cword`
       
  7198 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7199 
       
  7200 	case "$prev" in
       
  7201 		-@(o|O|-options|-sort))
       
  7202 			COMPREPLY=( $( compgen -W 'pv_fmt pv_uuid \
       
  7203 				pv_size pv_free pv_used pv_name \
       
  7204 				pv_attr pv_pe_count \
       
  7205 				pv_pe_alloc_count' -- $cur ) )
       
  7206 			return 0
       
  7207 			;;
       
  7208 		--units)
       
  7209 			_units
       
  7210 			return 0
       
  7211 			;;
       
  7212 	esac
       
  7213 
       
  7214 	if [[ "$cur" == -* ]]; then
       
  7215 		COMPREPLY=( $( compgen -W '--aligned -a --all -d --debug \
       
  7216 			-h -? --help --ignorelockingfailure --noheadings \
       
  7217 			--nosuffix -o --options -O --sort \
       
  7218 			--separator --unbuffered --units \
       
  7219 			-v --verbose --version' -- $cur ) )
       
  7220 	else
       
  7221 		_physicalvolumes
       
  7222 	fi
       
  7223 }
       
  7224 complete -F _pvs pvs
       
  7225 
       
  7226 _pvdisplay()
       
  7227 {
       
  7228 	local cur prev
       
  7229 
       
  7230 	COMPREPLY=()
       
  7231 	cur=`_get_cword`
       
  7232 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7233 
       
  7234 	case "$prev" in
       
  7235 		--units)
       
  7236 			_units
       
  7237 			return 0
       
  7238 			;;
       
  7239 	esac
       
  7240 
       
  7241 	if [[ "$cur" == -* ]]; then
       
  7242 		COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
       
  7243 			-v --verbose -d --debug -h --help --version' -- $cur ) )
       
  7244 	else
       
  7245 		_physicalvolumes
       
  7246 	fi
       
  7247 }
       
  7248 complete -F _pvdisplay pvdisplay
       
  7249 
       
  7250 _pvchange()
       
  7251 {
       
  7252 	local cur prev
       
  7253 
       
  7254 	COMPREPLY=()
       
  7255 	cur=`_get_cword`
       
  7256 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7257 
       
  7258 	case "$prev" in
       
  7259 		-@(A|x|-autobackup|--allocatable))
       
  7260 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7261 			return 0
       
  7262 			;;
       
  7263 	esac
       
  7264 
       
  7265 	if [[ "$cur" == -* ]]; then
       
  7266 		COMPREPLY=( $( compgen -W '-a --all -A --autobackup \
       
  7267 			-d --debug -h --help -t --test -u --uuid -x \
       
  7268 			--allocatable -v --verbose --addtag --deltag \
       
  7269 			--version' -- $cur ) )
       
  7270 	else
       
  7271 		_physicalvolumes
       
  7272 	fi
       
  7273 }
       
  7274 complete -F _pvchange pvchange
       
  7275 
       
  7276 _pvcreate()
       
  7277 {
       
  7278 	local cur prev
       
  7279 
       
  7280 	COMPREPLY=()
       
  7281 	cur=`_get_cword`
       
  7282 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7283 
       
  7284 	case "$prev" in
       
  7285 		--restorefile)
       
  7286 			_filedir
       
  7287 			return 0
       
  7288 			;;
       
  7289 		-@(M|-metadatatype))
       
  7290 			COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
       
  7291 			return 0
       
  7292 			;;
       
  7293 		--metadatacopies)
       
  7294 			COMPREPLY=( $( compgen -W '0 1 2' -- $cur ) )
       
  7295 			return 0
       
  7296 			;;
       
  7297 		--@(metadatasize|setphysicalvolumesize))
       
  7298 			_sizes
       
  7299 			return 0
       
  7300 			;;
       
  7301 	esac
       
  7302 
       
  7303 	if [[ "$cur" == -* ]]; then
       
  7304 		COMPREPLY=( $( compgen -W '--restorefile -d --debug -f \
       
  7305 			--force -h -? --help --labelsector -M --metadatatype \
       
  7306 			--metadatacopies --metadatasize \
       
  7307 			--setphysicalvolumesize -t --test -u --uuid uuid -v \
       
  7308 			--verbose -y --yes --version' -- $cur ) )
       
  7309 	else
       
  7310 		_physicalvolumes
       
  7311 	fi
       
  7312 }
       
  7313 complete -F _pvcreate pvcreate
       
  7314 
       
  7315 _pvmove()
       
  7316 {
       
  7317 	local cur prev
       
  7318 
       
  7319 	COMPREPLY=()
       
  7320 	cur=`_get_cword`
       
  7321 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7322 
       
  7323 	case "$prev" in
       
  7324 		-@(A|-autobackup))
       
  7325 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7326 			return 0
       
  7327 			;;
       
  7328 		-@(n|-name))
       
  7329 			_logicalvolumes
       
  7330 			return 0
       
  7331 	esac
       
  7332 
       
  7333 	if [[ "$cur" == -* ]]; then
       
  7334 		COMPREPLY=( $( compgen -W '--abort -A --autobackup \
       
  7335 			-b --background -d --debug -f --force -h -? \
       
  7336 			--help -i --interval -t --test -v --verbose \
       
  7337 			--version -n --name' -- $cur ) )
       
  7338 	else
       
  7339 		_physicalvolumes
       
  7340 	fi
       
  7341 }
       
  7342 complete -F _pvmove pvmove
       
  7343 
       
  7344 _pvremove()
       
  7345 {
       
  7346 	local cur
       
  7347 
       
  7348 	COMPREPLY=()
       
  7349 	cur=`_get_cword`
       
  7350 
       
  7351 	if [[ "$cur" == -* ]]; then
       
  7352 		COMPREPLY=( $( compgen -W '-d --debug -f --force -h -? \
       
  7353 			--help -y --yes -t --test -v --verbose \
       
  7354 			--version' -- $cur ) )
       
  7355 	else
       
  7356 		_physicalvolumes
       
  7357 	fi
       
  7358 }
       
  7359 complete -F _pvremove pvremove
       
  7360 
       
  7361 _vgscan()
       
  7362 {
       
  7363 	local cur
       
  7364 
       
  7365 	COMPREPLY=()
       
  7366 	cur=`_get_cword`
       
  7367 
       
  7368 	if [[ "$cur" == -* ]]; then
       
  7369 		COMPREPLY=( $( compgen -W '-d --debug -h --help \
       
  7370 			--ignorelockingfailure --mknodes -P \
       
  7371 			--partial -v --verbose --version' -- $cur ) )
       
  7372 	fi
       
  7373 }
       
  7374 complete -F _vgscan vgscan
       
  7375 
       
  7376 _vgs()
       
  7377 {
       
  7378 	local cur prev
       
  7379 
       
  7380 	COMPREPLY=()
       
  7381 	cur=`_get_cword`
       
  7382 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7383 
       
  7384 	case "$prev" in
       
  7385 		-@(o|O|-options|-sort))
       
  7386 			COMPREPLY=( $( compgen -W 'vg_fmt vg_uuid vg_name \
       
  7387 				vg_attr vg_size vg_free vg_sysid \
       
  7388 				vg_extent_size vg_extent_count vg_free_count \
       
  7389 				max_lv max_pv pv_count lv_count snap_count \
       
  7390 				vg_seqno' -- $cur ) )
       
  7391 			return 0
       
  7392 			;;
       
  7393 		--units)
       
  7394 			_units
       
  7395 			return 0
       
  7396 			;;
       
  7397 	esac
       
  7398 
       
  7399 	if [[ "$cur" == -* ]]; then
       
  7400 		COMPREPLY=( $( compgen -W '--aligned -d --debug \
       
  7401 			-h --help --ignorelockingfailure --noheadings \
       
  7402 			--nosuffix -o --options -O --sort -P --partial \
       
  7403 			--separator --unbuffered --units \
       
  7404 			-v --verbose --version' -- $cur ) )
       
  7405 	else
       
  7406 		_volumegroups
       
  7407 	fi
       
  7408 }
       
  7409 complete -F _vgs vgs
       
  7410 
       
  7411 _vgdisplay()
       
  7412 {
       
  7413 	local cur prev
       
  7414 
       
  7415 	COMPREPLY=()
       
  7416 	cur=`_get_cword`
       
  7417 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7418 
       
  7419 	case "$prev" in
       
  7420 		--units)
       
  7421 			_units
       
  7422 			return 0
       
  7423 			;;
       
  7424 	esac
       
  7425 
       
  7426 	if [[ "$cur" == -* ]]; then
       
  7427 		COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
       
  7428 			-P --partial -A --activevolumegroups -v --verbose \
       
  7429 			-d --debug -h --help --version' -- $cur ) )
       
  7430 	else
       
  7431 		_volumegroups
       
  7432 	fi
       
  7433 }
       
  7434 complete -F _vgdisplay vgdisplay
       
  7435 
       
  7436 _vgchange()
       
  7437 {
       
  7438 	local cur prev
       
  7439 
       
  7440 	COMPREPLY=()
       
  7441 	cur=`_get_cword`
       
  7442 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7443 
       
  7444 	case "$prev" in
       
  7445 		-@(a|A|x|-available|-autobackup|-resizeable))
       
  7446 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7447 			return 0
       
  7448 			;;
       
  7449 	esac
       
  7450 
       
  7451 	if [[ "$cur" == -* ]]; then
       
  7452 		COMPREPLY=( $( compgen -W '-A --autobackup --alloc -P \
       
  7453 			--partial -d --debug -h --help --ignorelockingfailure \
       
  7454 			-t --test -u --uuid -v --verbose --version -a \
       
  7455 			--available -x --resizeable -l --logicalvolume \
       
  7456 			--addtag --deltag' -- $cur ) )
       
  7457 	else
       
  7458 		_volumegroups
       
  7459 	fi
       
  7460 }
       
  7461 complete -F _vgchange vgchange
       
  7462 
       
  7463 _vgcreate()
       
  7464 {
       
  7465 	local cur prev
       
  7466 
       
  7467 	COMPREPLY=()
       
  7468 	cur=`_get_cword`
       
  7469 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7470 
       
  7471 	case "$prev" in
       
  7472 		-@(A|-autobackup))
       
  7473 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7474 			return 0
       
  7475 			;;
       
  7476 		-@(M|-metadatatype))
       
  7477 			COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
       
  7478 			return 0
       
  7479 			;;
       
  7480 		-@(s|-physicalextentsize))
       
  7481 			_sizes
       
  7482 			return 0
       
  7483 			;;
       
  7484 	esac
       
  7485 
       
  7486 	if [[ "$cur" == -* ]]; then
       
  7487 		COMPREPLY=( $( compgen -W '-A --autobackup --addtag \
       
  7488 			--alloc -d --debug -h --help -l --maxlogicalvolumes \
       
  7489 			-M --metadatatype -p --maxphysicalvolumes -s \
       
  7490 			--physicalextentsize -t --test -v --verbose \
       
  7491 			--version' -- $cur ) )
       
  7492 	else
       
  7493 		_args
       
  7494 		if [ $args -eq 0 ]; then
       
  7495 			_volumegroups
       
  7496 		else
       
  7497 			_physicalvolumes
       
  7498 		fi
       
  7499 	fi
       
  7500 }
       
  7501 complete -F _vgcreate vgcreate
       
  7502 
       
  7503 _vgremove()
       
  7504 {
       
  7505 	local cur
       
  7506 
       
  7507 	COMPREPLY=()
       
  7508 	cur=`_get_cword`
       
  7509 
       
  7510 	if [[ "$cur" == -* ]]; then
       
  7511 		COMPREPLY=( $( compgen -W '-d --debug -h --help -t --test \
       
  7512 		-v --verbose --version' -- $cur ) )
       
  7513 	else
       
  7514 		_volumegroups
       
  7515 	fi
       
  7516 }
       
  7517 complete -F _vgremove vgremove
       
  7518 
       
  7519 _vgrename()
       
  7520 {
       
  7521 	local cur prev
       
  7522 
       
  7523 	COMPREPLY=()
       
  7524 	cur=`_get_cword`
       
  7525 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7526 
       
  7527 	case "$prev" in
       
  7528 		-@(A|-autobackup))
       
  7529 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7530 			return 0
       
  7531 			;;
       
  7532 	esac
       
  7533 
       
  7534 	if [[ "$cur" == -* ]]; then
       
  7535 		COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
       
  7536 			-? --help -t --test -v --verbose --version' -- $cur ) )
       
  7537 	else
       
  7538 		_volumegroups
       
  7539 	fi
       
  7540 }
       
  7541 complete -F _vgrename vgrename
       
  7542 
       
  7543 _vgreduce()
       
  7544 {
       
  7545 	local cur prev
       
  7546 
       
  7547 	COMPREPLY=()
       
  7548 	cur=`_get_cword`
       
  7549 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7550 
       
  7551 	case "$prev" in
       
  7552 		-@(A|-autobackup))
       
  7553 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7554 			return 0
       
  7555 			;;
       
  7556 	esac
       
  7557 
       
  7558 	if [[ "$cur" == -* ]]; then
       
  7559 		COMPREPLY=( $( compgen -W '-a --all -A --autobackup -d \
       
  7560 			--debug -h --help --removemissing -t --test -v \
       
  7561 			--verbose --version' -- $cur ) )
       
  7562 
       
  7563 	else
       
  7564 		_args
       
  7565 		if [ $args -eq 0 ]; then
       
  7566 			_volumegroups
       
  7567 		else
       
  7568 			_physicalvolumes
       
  7569 		fi
       
  7570 	fi
       
  7571 }
       
  7572 complete -F _vgreduce vgreduce
       
  7573 
       
  7574 _vgextend()
       
  7575 {
       
  7576 	local cur prev
       
  7577 
       
  7578 	COMPREPLY=()
       
  7579 	cur=`_get_cword`
       
  7580 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7581 
       
  7582 	case "$prev" in
       
  7583 		-@(A|-autobackup))
       
  7584 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7585 			return 0
       
  7586 			;;
       
  7587 		-@(L|-size))
       
  7588 			_sizes
       
  7589 			return 0
       
  7590 			;;
       
  7591 	esac
       
  7592 
       
  7593 	if [[ "$cur" == -* ]]; then
       
  7594 		COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
       
  7595 			-? --help -t --test -v --verbose --version' -- $cur ) )
       
  7596 	else
       
  7597 		_args
       
  7598 		if [ $args -eq 0 ]; then
       
  7599 			_volumegroups
       
  7600 		else
       
  7601 			_physicalvolumes
       
  7602 		fi
       
  7603 	fi
       
  7604 }
       
  7605 complete -F _vgextend vgextend
       
  7606 
       
  7607 _vgport()
       
  7608 {
       
  7609 	local cur prev
       
  7610 
       
  7611 	COMPREPLY=()
       
  7612 	cur=`_get_cword`
       
  7613 
       
  7614 	if [[ "$cur" == -* ]]; then
       
  7615 		COMPREPLY=( $( compgen -W '-a --all -d --debug -h \
       
  7616 			-? --help -v --verbose --version' -- $cur ) )
       
  7617 	else
       
  7618 		_volumegroups
       
  7619 	fi
       
  7620 }
       
  7621 complete -F _vgport vgimport vgexport
       
  7622 
       
  7623 _vgck()
       
  7624 {
       
  7625 	local cur prev
       
  7626 
       
  7627 	COMPREPLY=()
       
  7628 	cur=`_get_cword`
       
  7629 
       
  7630 	if [[ "$cur" == -* ]]; then
       
  7631 		COMPREPLY=( $( compgen -W '-d --debug -h \
       
  7632 			-? --help -v --verbose --version' -- $cur ) )
       
  7633 	else
       
  7634 		_volumegroups
       
  7635 	fi
       
  7636 }
       
  7637 complete -F _vgck vgck
       
  7638 
       
  7639 _vgconvert()
       
  7640 {
       
  7641 	local cur prev
       
  7642 
       
  7643 	COMPREPLY=()
       
  7644 	cur=`_get_cword`
       
  7645 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7646 
       
  7647 	case "$prev" in
       
  7648 		-@(M|-metadatatype))
       
  7649 			COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
       
  7650 			return 0
       
  7651 			;;
       
  7652 		--metadatacopies)
       
  7653 			COMPREPLY=( $( compgen -W '0 1 2' -- $cur ) )
       
  7654 			return 0
       
  7655 			;;
       
  7656 		--metadatasize)
       
  7657 			_sizes
       
  7658 			return 0
       
  7659 			;;
       
  7660 	esac
       
  7661 
       
  7662 	if [[ "$cur" == -* ]]; then
       
  7663 		COMPREPLY=( $( compgen -W '-d --debug -h --help --labelsector \ 
       
  7664 			-M --metadatatype --metadatacopies --metadatasize \
       
  7665 			-t --test -v --verbose --version' -- $cur ) )
       
  7666 	else
       
  7667 		_volumegroups
       
  7668 	fi
       
  7669 }
       
  7670 complete -F _vgconvert vgconvert
       
  7671 
       
  7672 _vgcfgbackup()
       
  7673 {
       
  7674 	local cur prev
       
  7675 
       
  7676 	COMPREPLY=()
       
  7677 	cur=`_get_cword`
       
  7678 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7679 
       
  7680 	case "$prev" in
       
  7681 		-@(f|-file))
       
  7682 			_filedir
       
  7683 			return 0
       
  7684 			;;
       
  7685 	esac
       
  7686 
       
  7687 	if [[ "$cur" == -* ]]; then
       
  7688 		COMPREPLY=( $( compgen -W '-d --debug -f --file -h --help \
       
  7689 			--ignorelockingfailure -P --partial -v --verbose \
       
  7690 			--version' -- $cur ) )
       
  7691 	else
       
  7692 		_volumegroups
       
  7693 	fi
       
  7694 }
       
  7695 complete -F _vgcfgbackup vgcfgbackup
       
  7696 
       
  7697 _vgcfgrestore()
       
  7698 {
       
  7699 	local cur prev
       
  7700 
       
  7701 	COMPREPLY=()
       
  7702 	cur=`_get_cword`
       
  7703 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7704 
       
  7705 	case "$prev" in
       
  7706 		-@(f|-file))
       
  7707 			_filedir
       
  7708 			return 0
       
  7709 			;;
       
  7710 		-@(M|-metadatatype))
       
  7711 			COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
       
  7712 			return 0
       
  7713 			;;
       
  7714 		-@(n|-name))
       
  7715 			_volumegroups
       
  7716 			return 0
       
  7717 			;;
       
  7718 	esac
       
  7719 
       
  7720 	if [[ "$cur" == -* ]]; then
       
  7721 		COMPREPLY=( $( compgen -W '-d --debug -f --file -l --list \
       
  7722 			-h --help -M --Metadatatype -n --name -t --test \
       
  7723 			-v --verbose --version' -- $cur ) )
       
  7724 	else
       
  7725 		_volumegroups
       
  7726 	fi
       
  7727 }
       
  7728 complete -F _vgcfgrestore vgcfgrestore
       
  7729 
       
  7730 _vgmerge()
       
  7731 {
       
  7732 	local cur prev
       
  7733 
       
  7734 	COMPREPLY=()
       
  7735 	cur=`_get_cword`
       
  7736 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7737 
       
  7738 	case "$prev" in
       
  7739 		-@(A|-autobackup))
       
  7740 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7741 			return 0
       
  7742 			;;
       
  7743 	esac
       
  7744 
       
  7745 	if [[ "$cur" == -* ]]; then
       
  7746 		COMPREPLY=( $( compgen -W '-A --autobackup -d --debug \
       
  7747 			-h --help -l --list -t --test -v --verbose \
       
  7748 			--version' -- $cur ) )
       
  7749 	else
       
  7750 		_volumegroups
       
  7751 	fi
       
  7752 }
       
  7753 complete -F _vgmerge vgmerge
       
  7754 
       
  7755 _vgsplit()
       
  7756 {
       
  7757 	local cur prev
       
  7758 
       
  7759 	COMPREPLY=()
       
  7760 	cur=`_get_cword`
       
  7761 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7762 
       
  7763 	case "$prev" in
       
  7764 		-@(A|-autobackup))
       
  7765 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7766 			return 0
       
  7767 			;;
       
  7768 		-@(M|-metadatatype))
       
  7769 			COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
       
  7770 			return 0
       
  7771 			;;
       
  7772 	esac
       
  7773 
       
  7774 	if [[ "$cur" == -* ]]; then
       
  7775 		COMPREPLY=( $( compgen -W '-A --autobackup -d --debug \
       
  7776 			-h --help -l --list -M --metadatatype -t --test \
       
  7777 			-v --verbose --version' -- $cur ) )
       
  7778 	else
       
  7779 		_args
       
  7780 		if [ $args -eq 0 -o $args -eq 1 ]; then
       
  7781 			_volumegroups
       
  7782 		else
       
  7783 			_physicalvolumes
       
  7784 		fi
       
  7785 	fi
       
  7786 }
       
  7787 complete -F _vgsplit vgsplit
       
  7788 
       
  7789 _vgmknodes()
       
  7790 {
       
  7791 	local cur
       
  7792 
       
  7793 	COMPREPLY=()
       
  7794 	cur=`_get_cword`
       
  7795 
       
  7796 	if [[ "$cur" == -* ]]; then
       
  7797 		COMPREPLY=( $( compgen -W '-d --debug -h --help -v --verbose \
       
  7798 			--version' -- $cur ) )
       
  7799 	else
       
  7800 		_volumegroups
       
  7801 	fi
       
  7802 }
       
  7803 complete -F _vgmknodes vgmknodes
       
  7804 
       
  7805 _lvscan()
       
  7806 {
       
  7807 	local cur
       
  7808 
       
  7809 	COMPREPLY=()
       
  7810 	cur=`_get_cword`
       
  7811 
       
  7812 	if [[ "$cur" == -* ]]; then
       
  7813 		COMPREPLY=( $( compgen -W '-b --blockdevice -d --debug \
       
  7814 			-h -? --help --ignorelockingfailure -P \
       
  7815 			--partial -v --verbose --version' -- $cur ) )
       
  7816 	fi
       
  7817 }
       
  7818 complete -F _lvscan lvscan
       
  7819 
       
  7820 _lvs()
       
  7821 {
       
  7822 	local cur prev
       
  7823 
       
  7824 	COMPREPLY=()
       
  7825 	cur=`_get_cword`
       
  7826 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7827 
       
  7828 	case "$prev" in
       
  7829 		-@(o|O|-options|-sort))
       
  7830 			COMPREPLY=( $( compgen -W 'lv_uuid lv_name \
       
  7831 				lv_attr lv_minor lv_size seg_count \
       
  7832 				origin snap_percent segtype stripes \
       
  7833 				stripesize chunksize seg_start \
       
  7834 				seg_size' -- $cur ) )
       
  7835 			return 0
       
  7836 			;;
       
  7837 		--units)
       
  7838 			_units
       
  7839 			return 0
       
  7840 			;;
       
  7841 	esac
       
  7842 
       
  7843 	if [[ "$cur" == -* ]]; then
       
  7844 		COMPREPLY=( $( compgen -W '--aligned -d --debug \
       
  7845 			-h --help --ignorelockingfailure --noheadings \
       
  7846 			--nosuffix -o --options -O --sort -P --partial \
       
  7847 			--segments --separator --unbuffered --units \
       
  7848 			-v --verbose --version' -- $cur ) )
       
  7849 	else
       
  7850 		_logicalvolumes
       
  7851 	fi
       
  7852 }
       
  7853 complete -F _lvs lvs
       
  7854 
       
  7855 _lvdisplay()
       
  7856 {
       
  7857 	local cur prev
       
  7858 
       
  7859 	COMPREPLY=()
       
  7860 	cur=`_get_cword`
       
  7861 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7862 
       
  7863 	case "$prev" in
       
  7864 		--units)
       
  7865 			_units
       
  7866 			return 0
       
  7867 			;;
       
  7868 	esac
       
  7869 
       
  7870 	if [[ "$cur" == -* ]]; then
       
  7871 		COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
       
  7872 			-P --partial -m --maps -v --verbose -d --debug -h \
       
  7873 			--help --version' -- $cur ) )
       
  7874 	else
       
  7875 		_logicalvolumes
       
  7876 	fi
       
  7877 }
       
  7878 complete -F _lvdisplay lvdisplay
       
  7879 
       
  7880 _lvchange()
       
  7881 {
       
  7882 	local cur prev
       
  7883 
       
  7884 	COMPREPLY=()
       
  7885 	cur=`_get_cword`
       
  7886 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7887 
       
  7888 	case "$prev" in
       
  7889 		-@(a|A|C|M|-available|-autobackup|-continguous|-persistent))
       
  7890 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7891 			return 0
       
  7892 			;;
       
  7893 		-@(p|-permission))
       
  7894 			COMPREPLY=( $( compgen -W 'r rw' -- $cur ) )
       
  7895 			return 0
       
  7896 			;;
       
  7897 	esac
       
  7898 
       
  7899 	if [[ "$cur" == -* ]]; then
       
  7900 		COMPREPLY=( $( compgen -W '-A --autobackup -a --available \
       
  7901 			--addtag --alloc -C --contiguous -d --debug --deltag \
       
  7902 			-f --force -h --help --ignorelockingfailure -M \
       
  7903 			--persistent --major major --minor minor -P --partial \
       
  7904 			-p --permission -r --readahead --refresh -t --test \
       
  7905 			-v --verbose --version' -- $cur ) )
       
  7906 	else
       
  7907 		_logicalvolumes
       
  7908 	fi
       
  7909 }
       
  7910 complete -F _lvchange lvchange
       
  7911 
       
  7912 _lvcreate()
       
  7913 {
       
  7914 	local cur prev
       
  7915 
       
  7916 	COMPREPLY=()
       
  7917 	cur=`_get_cword`
       
  7918 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7919 
       
  7920 	case "$prev" in
       
  7921 		-@(A|C|M|Z|-autobackup|-continguous|-persistent|-zero))
       
  7922 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7923 			return 0
       
  7924 			;;
       
  7925 		-@(L|-size))
       
  7926 			_sizes
       
  7927 			return 0
       
  7928 			;;
       
  7929 		-@(p|-permission))
       
  7930 			COMPREPLY=( $( compgen -W 'r rw' -- $cur ) )
       
  7931 			return 0
       
  7932 			;;
       
  7933 		-@(n|-name))
       
  7934 			_logicalvolumes
       
  7935 			return 0
       
  7936 			;;
       
  7937 	esac
       
  7938 
       
  7939 	if [[ "$cur" == -* ]]; then
       
  7940 		COMPREPLY=( $( compgen -W '-A --autobackup --addtag --alloc \
       
  7941 			-C --contiguous -d --debug -h -? --help -i --stripes \
       
  7942 			-I --stripesize -l --extents -L --size -M --persistent \
       
  7943 			--major --minor -n --name -p --permission -r \
       
  7944 			--readahead -t --test --type -v --verbose -Z --zero \
       
  7945 			--version' -- $cur ) )
       
  7946 	else
       
  7947 		_args
       
  7948 		if [ $args -eq 0 ]; then
       
  7949 			_volumegroups
       
  7950 		else
       
  7951 			_physicalvolumes
       
  7952 		fi
       
  7953 	fi
       
  7954 }
       
  7955 complete -F _lvcreate lvcreate
       
  7956 
       
  7957 _lvremove()
       
  7958 {
       
  7959 	local cur prev
       
  7960 
       
  7961 	COMPREPLY=()
       
  7962 	cur=`_get_cword`
       
  7963 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7964 
       
  7965 	case "$prev" in
       
  7966 		-@(A|-autobackup))
       
  7967 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7968 			return 0
       
  7969 			;;
       
  7970 	esac
       
  7971 
       
  7972 	if [[ "$cur" == -* ]]; then
       
  7973 		COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -f \
       
  7974 			--force -h -?  --help -t --test -v --verbose \
       
  7975 			--version' -- $cur ) )
       
  7976 	else
       
  7977 		_logicalvolumes
       
  7978 	fi
       
  7979 }
       
  7980 complete -F _lvremove lvremove
       
  7981 
       
  7982 _lvrename()
       
  7983 {
       
  7984 	local cur prev
       
  7985 
       
  7986 	COMPREPLY=()
       
  7987 	cur=`_get_cword`
       
  7988 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  7989 
       
  7990 	case "$prev" in
       
  7991 		-@(A|-autobackup))
       
  7992 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  7993 			return 0
       
  7994 			;;
       
  7995 	esac
       
  7996 
       
  7997 	if [[ "$cur" == -* ]]; then
       
  7998 		COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
       
  7999 			-? --help -t --test -v --verbose --version' -- $cur ) )
       
  8000 	else
       
  8001 		_logicalvolumes
       
  8002 	fi
       
  8003 }
       
  8004 complete -F _lvrename lvrename
       
  8005 
       
  8006 _lvreduce()
       
  8007 {
       
  8008 	local cur prev
       
  8009 
       
  8010 	COMPREPLY=()
       
  8011 	cur=`_get_cword`
       
  8012 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8013 
       
  8014 	case "$prev" in
       
  8015 		-@(A|-autobackup))
       
  8016 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  8017 			return 0
       
  8018 			;;
       
  8019 		-@(L|-size))
       
  8020 			_sizes
       
  8021 			return 0
       
  8022 			;;
       
  8023 	esac
       
  8024 
       
  8025 	if [[ "$cur" == -* ]]; then
       
  8026 		COMPREPLY=( $( compgen -W '-A --autobackup -d \
       
  8027 			--debug -f --force -h --help -l --extents \
       
  8028 			-L --size -n --nofsck -r --resizefs -t --test \
       
  8029 			-v --verbose --version' -- $cur ) )
       
  8030 	else
       
  8031 		_logicalvolumes
       
  8032 	fi
       
  8033 }
       
  8034 complete -F _lvreduce lvreduce
       
  8035 
       
  8036 _lvresize()
       
  8037 {
       
  8038 	local cur prev
       
  8039 
       
  8040 	COMPREPLY=()
       
  8041 	cur=`_get_cword`
       
  8042 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8043 
       
  8044 	case "$prev" in
       
  8045 		-@(A|-autobackup))
       
  8046 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  8047 			return 0
       
  8048 			;;
       
  8049 		-@(L|-size))
       
  8050 			_sizes
       
  8051 			return 0
       
  8052 			;;
       
  8053 	esac
       
  8054 
       
  8055 	if [[ "$cur" == -* ]]; then
       
  8056 		COMPREPLY=( $( compgen -W '-A --autobackup --alloc -d \
       
  8057 			--debug -h --help -i --stripes -I --stripesize \
       
  8058 			-l --extents -L --size -n --nofsck -r --resizefs \
       
  8059 			-t --test --type -v --verbose --version' -- $cur ) )
       
  8060 	else
       
  8061 		_args
       
  8062 		if [ $args -eq 0 ]; then
       
  8063 			_logicalvolumes
       
  8064 		else
       
  8065 			_physicalvolumes
       
  8066 		fi
       
  8067 	fi
       
  8068 }
       
  8069 complete -F _lvresize lvresize
       
  8070 
       
  8071 _lvextend()
       
  8072 {
       
  8073 	local cur prev
       
  8074 
       
  8075 	COMPREPLY=()
       
  8076 	cur=`_get_cword`
       
  8077 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8078 
       
  8079 	case "$prev" in
       
  8080 		-@(A|-autobackup))
       
  8081 			COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
       
  8082 			return 0
       
  8083 			;;
       
  8084 		-@(L|-size))
       
  8085 			_sizes
       
  8086 			return 0
       
  8087 			;;
       
  8088 	esac
       
  8089 
       
  8090 	if [[ "$cur" == -* ]]; then
       
  8091 		COMPREPLY=( $( compgen -W '-A --autobackup --alloc -d \
       
  8092 			--debug -h --help -i --stripes -I --stripesize \
       
  8093 			-l --extents -L --size -n --nofsck -r --resizefs \
       
  8094 			-t --test --type -v --verbose --version' -- $cur ) )
       
  8095 	else
       
  8096 		_args
       
  8097 		if [ $args -eq 0 ]; then
       
  8098 			_logicalvolumes
       
  8099 		else
       
  8100 			_physicalvolumes
       
  8101 		fi
       
  8102 	fi
       
  8103 }
       
  8104 complete -F _lvextend lvextend
       
  8105 
       
  8106 _lvm()
       
  8107 {
       
  8108 	local prev
       
  8109 
       
  8110 	COMPREPLY=()
       
  8111 	cur=`_get_cword`
       
  8112 
       
  8113 	if [ $COMP_CWORD -eq 1 ]; then
       
  8114 		COMPREPLY=( $( compgen -W 'dumpconfig help lvchange \
       
  8115 			lvcreate lvdisplay lvextend lvmchange \
       
  8116 			lvmdiskscan lvmsadc lvmsar lvreduce \
       
  8117 			lvremove lvrename lvresize lvs lvscan \
       
  8118 			pvchange pvcreate pvdata pvdisplay pvmove \
       
  8119 			pvremove pvresize pvs pvscan vgcfgbackup \
       
  8120 			vgcfgrestore vgchange vgck vgconvert \
       
  8121 			vgcreate vgdisplay vgexport vgextend \
       
  8122 			vgimport vgmerge vgmknodes vgreduce \
       
  8123 			vgremove vgrename vgs vgscan vgsplit \
       
  8124 			version' -- $cur ) )
       
  8125 	else
       
  8126 		case ${COMP_WORDS[1]} in
       
  8127 			pvchange)
       
  8128 				_pvchange
       
  8129 				;;
       
  8130 			pvcreate)
       
  8131 				_pvcreate
       
  8132 				;;
       
  8133 			pvdisplay)
       
  8134 				_pvdisplay
       
  8135 				;;
       
  8136 			pvmove)
       
  8137 				_pvmove
       
  8138 				;;
       
  8139 			pvremove)
       
  8140 				_pvremove
       
  8141 				;;
       
  8142 			pvresize)
       
  8143 				_pvresize
       
  8144 				;;
       
  8145 			pvs)
       
  8146 				_pvs
       
  8147 				;;
       
  8148 			pvscan)
       
  8149 				_pvscan
       
  8150 				;;
       
  8151 			vgcfgbackup)
       
  8152 				_vgcfgbackup
       
  8153 				;;
       
  8154 			vgcfgrestore)
       
  8155 				_vgcfgrestore
       
  8156 				;;
       
  8157 			vgchange)
       
  8158 				_vgchange
       
  8159 				;;
       
  8160 			vgck)
       
  8161 				_vgck
       
  8162 				;;
       
  8163 			vgconvert)
       
  8164 				_vgconvert
       
  8165 				;;
       
  8166 			vgcreate)
       
  8167 				_vgcreate
       
  8168 				;;
       
  8169 			vgdisplay)
       
  8170 				_vgdisplay
       
  8171 				;;
       
  8172 			vgexport)
       
  8173 				_vgexport
       
  8174 				;;
       
  8175 			vgextend)
       
  8176 				_vgextend
       
  8177 				;;
       
  8178 			vgimport)
       
  8179 				_vgimport
       
  8180 				;;
       
  8181 			vgmerge)
       
  8182 				_vgmerge
       
  8183 				;;
       
  8184 			vgmknodes)
       
  8185 				_vgmknodes
       
  8186 				;;
       
  8187 			vgreduce)
       
  8188 				_vgreduce
       
  8189 				;;
       
  8190 			vgremove)
       
  8191 				_vgremove
       
  8192 				;;
       
  8193 			vgrename)
       
  8194 				_vgrename
       
  8195 				;;
       
  8196 			vgs)
       
  8197 				_vgs
       
  8198 				;;
       
  8199 			vgscan)
       
  8200 				_vgscan
       
  8201 				;;
       
  8202 			vgsplit)
       
  8203 				_vgsplit
       
  8204 				;;
       
  8205 			lvchange)
       
  8206 				_lvchange
       
  8207 				;;
       
  8208 			lvcreate)
       
  8209 				_lvcreate
       
  8210 				;;
       
  8211 			lvdisplay)
       
  8212 				_lvdisplay
       
  8213 				;;
       
  8214 			lvextend)
       
  8215 				_lvextend
       
  8216 				;;
       
  8217 			lvreduce)
       
  8218 				_lvreduce
       
  8219 				;;
       
  8220 			lvremove)
       
  8221 				_lvremove
       
  8222 				;;
       
  8223 			lvrename)
       
  8224 				_lvrename
       
  8225 				;;
       
  8226 			lvresize)
       
  8227 				_lvresize
       
  8228 				;;
       
  8229 			lvs)
       
  8230 				_lvs
       
  8231 				;;
       
  8232 			lvscan)
       
  8233 				_lvscan
       
  8234 				;;
       
  8235 		esac
       
  8236 	fi
       
  8237 }
       
  8238 complete -F _lvm lvm
       
  8239 }
       
  8240 
       
  8241 # mkinitrd(8) completion
       
  8242 #
       
  8243 have mkinitrd &&
       
  8244 _mkinitrd()
       
  8245 {
       
  8246 	local cur args
       
  8247 
       
  8248 	COMPREPLY=()
       
  8249 	cur=`_get_cword`
       
  8250 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8251 
       
  8252 	# --name value style option
       
  8253 	case "$prev" in
       
  8254 		--preload)
       
  8255 			_modules
       
  8256 			return 0
       
  8257 			;;
       
  8258 	esac
       
  8259 
       
  8260 	# --name=value style option
       
  8261 	if [[ "$cur" == *=* ]]; then
       
  8262 		prev=${cur/=*/}
       
  8263 		cur=${cur/*=/}
       
  8264 		case "$prev" in
       
  8265 			--@(with|builtin))
       
  8266 				_modules
       
  8267 				return 0
       
  8268 				;;
       
  8269 			--@(fstab|dsdt))
       
  8270 				_filedir
       
  8271 				return 0
       
  8272 				;;
       
  8273 			--tmpdir)
       
  8274 				_filedir -d
       
  8275 				return 0
       
  8276 				;;
       
  8277 		esac
       
  8278 	fi
       
  8279 
       
  8280 
       
  8281 	if [[ "$cur" == -* ]]; then
       
  8282 		COMPREPLY=( $( compgen -W '--version -v -f --preload \
       
  8283 			--with= --omit-scsi-modules --omit-raid-modules \
       
  8284 			--images-version --fstab= --nocompress --builtin= \
       
  8285 			--nopivot --noudev --allow-missing --tmpdir= \
       
  8286 			--initrdfs= --dsdt= --lvm-version= --froce-usb' \
       
  8287 			-- $cur ) )
       
  8288 	else
       
  8289 		_count_args
       
  8290 
       
  8291 		case $args in
       
  8292 			1)
       
  8293 				_filedir
       
  8294 				;;
       
  8295 			2)
       
  8296 				COMPREPLY=( $( command ls /lib/modules | grep "^$cur" ) )
       
  8297 				;;
       
  8298 		esac
       
  8299 	fi
       
  8300 
       
  8301 } &&
       
  8302 complete -F _mkinitrd mkinitrd
       
  8303 
       
  8304 # pkgconfig(1) completion
       
  8305 #
       
  8306 have pkg-config &&
       
  8307 _pkg_config()
       
  8308 {
       
  8309 	local cur
       
  8310 
       
  8311 	COMPREPLY=()
       
  8312 	cur=`_get_cword`
       
  8313 
       
  8314 	if [[ "$cur" == -* ]]; then
       
  8315 		# return list of available options
       
  8316 		COMPREPLY=( $( compgen -W '-version --modversion \
       
  8317 		      --atleast-pkgconfig-version= --libs --libs-only-l \
       
  8318 		      --libs-only-other --libs-only-L --cflags \
       
  8319 		      --cflags-only-I --cflags-only-other --variable= \
       
  8320 		      --define-variable= --exists --uninstalled \
       
  8321 		      --atleast-version= --exact-version= --max-version= \
       
  8322 		      --list-all --debug --print-errors --silence-errors \
       
  8323 		      --errors-to-stdout -? --help --usage' -- $cur))
       
  8324 	else
       
  8325 		COMPREPLY=( $( pkg-config --list-all 2>/dev/null | \
       
  8326 				    awk '{print $1}' | grep "^$cur" ) )
       
  8327 	fi
       
  8328 } &&
       
  8329 complete -F _pkg_config pkg-config
       
  8330 
       
  8331 
       
  8332 # cpio(1) completion
       
  8333 #
       
  8334 have cpio && {
       
  8335 _cpio_format()
       
  8336 {
       
  8337 	COMPREPLY=( $( compgen -W 'bin odc newc crc tar ustar hpbin hpodc' -- $cur ) )
       
  8338 }
       
  8339 
       
  8340 _cpio()
       
  8341 {
       
  8342 	local cur
       
  8343 
       
  8344 	COMPREPLY=()
       
  8345 	cur=`_get_cword`
       
  8346 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8347 
       
  8348 	# --name value style option
       
  8349 	case $prev in
       
  8350 		-H)
       
  8351 			_cpio_format
       
  8352 			return 0
       
  8353 			;;
       
  8354 		-@(E|F|I))
       
  8355 			_filedir
       
  8356 			return 0
       
  8357 			;;
       
  8358 		-R)
       
  8359 			_usergroup
       
  8360 			return 0
       
  8361 			;;
       
  8362 	esac
       
  8363 
       
  8364 	# --name=value style option
       
  8365 	if [[ "$cur" == *=* ]]; then
       
  8366 		prev=${cur/=*/}
       
  8367 		cur=${cur/*=/}
       
  8368 		case $prev in
       
  8369 			--format)
       
  8370 				_cpio_format
       
  8371 				return 0
       
  8372 				;;
       
  8373 			--@(file|pattern-file))
       
  8374 				_filedir
       
  8375 				return 0
       
  8376 				;;
       
  8377 			--owner)
       
  8378 				_usergroup
       
  8379 				return 0
       
  8380 				;;
       
  8381 			--rsh-command)
       
  8382 				COMPREPLY=( $( compgen -c -- $cur ) )
       
  8383 				return 0
       
  8384 				;;
       
  8385 		esac
       
  8386 	fi
       
  8387 
       
  8388 	if [ $COMP_CWORD -eq 1 ]; then
       
  8389 		COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through' -- $cur) ) 
       
  8390 	else
       
  8391 		case ${COMP_WORDS[1]} in
       
  8392 			-@(o|-create))
       
  8393 				if [[ "$cur" == -* ]]; then
       
  8394 					COMPREPLY=( $( compgen -W '-0 -a -c -v -A -B\
       
  8395 						-L -V -C -H -M -O -F --file= --format=\
       
  8396 						--message= --null --reset-access-time\
       
  8397 						--verbose --dot --append --block-size=\
       
  8398 						--dereference --io-size= --quiet\
       
  8399 						--force-local --rsh-command= --help\
       
  8400 						--version' -- $cur ) )
       
  8401 				fi
       
  8402 				;;
       
  8403 			-@(i|-extract))
       
  8404 				if [[ "$cur" == -* ]]; then
       
  8405 					COMPREPLY=( $( compgen -W '-b -c -d -f -m -n -r\
       
  8406 						-t -s -u -v -B -S -V -C -E -H -M -R -I\
       
  8407 						-F --file= --make-directories\
       
  8408 						--nonmatching\
       
  8409 						--preserve-modification-time\
       
  8410 						--numeric-uid-gid --rename -t --list\
       
  8411 						--swap-bytes --swap --dot\
       
  8412 						--unconditional --verbose --block-size=\
       
  8413 						--swap-halfwords --io-size=\
       
  8414 						--pattern-file= --format= --owner=\
       
  8415 						--no-preserve-owner --message=\
       
  8416 						--force-local --no-absolute-filenames\
       
  8417 						--sparse --only-verify-crc --quiet\
       
  8418 						--rsh-command= --help\
       
  8419 						--version' -- $cur ) )
       
  8420 				fi
       
  8421 				;;
       
  8422 			-@(p|-pass-through))
       
  8423 				if [[ "$cur" == -* ]]; then
       
  8424 					COMPREPLY=( $( compgen -W '-0 -a -d -l -m -u -v\
       
  8425 						-L -V -R --null --reset-access-time\
       
  8426 						--make-directories --link --quiet\
       
  8427 						--preserve-modification-time\
       
  8428 						--unconditional --verbose --dot\
       
  8429 						--dereference --owner=\
       
  8430 						--no-preserve-owner --sparse --help\
       
  8431 						--version' -- $cur ) )
       
  8432 				else
       
  8433 					_filedir -d
       
  8434 				fi
       
  8435 				;;
       
  8436 		esac
       
  8437 	fi
       
  8438 }
       
  8439 complete -F _cpio cpio
       
  8440 }
       
  8441 
       
  8442 # id(1) completion
       
  8443 #
       
  8444 have id &&
       
  8445 _id()
       
  8446 {
       
  8447 	local cur
       
  8448 
       
  8449 	COMPREPLY=()
       
  8450 	cur=`_get_cword`
       
  8451 
       
  8452 	if [[ "$cur" == -* ]]; then
       
  8453 		COMPREPLY=( $( compgen -W '-a -g --group -G --groups -n --name\
       
  8454 			-r --real -u --user --help --version' -- $cur ) )
       
  8455 	else
       
  8456 		COMPREPLY=( $( compgen -u $cur  ) )
       
  8457 	fi
       
  8458 } &&
       
  8459 complete -F _id id
       
  8460 
       
  8461 # getent(1) completion
       
  8462 #
       
  8463 have getent &&
       
  8464 _getent()
       
  8465 {
       
  8466 	local cur prev
       
  8467 
       
  8468 	COMPREPLY=()
       
  8469 	cur=`_get_cword`
       
  8470 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8471 
       
  8472 	case $prev in
       
  8473 		passwd)
       
  8474 			COMPREPLY=( $( compgen -u $cur  ) )
       
  8475 			return 0
       
  8476 			;;
       
  8477 		group)
       
  8478 			COMPREPLY=( $( compgen -g $cur  ) )
       
  8479 			return 0
       
  8480 			;;
       
  8481 		services)
       
  8482 			COMPREPLY=( $( compgen -s $cur  ) )
       
  8483 			return 0
       
  8484 			;;
       
  8485 		hosts)
       
  8486 			COMPREPLY=( $( compgen -A hostname $cur  ) )
       
  8487 			return 0
       
  8488 			;;
       
  8489 		protocols)
       
  8490 			COMPREPLY=( $( getent protocols | awk '{print $1}' | grep "^$cur" ) )
       
  8491 			return 0
       
  8492 			;;
       
  8493 		networks)
       
  8494 			COMPREPLY=( $( getent networks | awk '{print $1}' | grep "^$cur" ) )
       
  8495 			return 0
       
  8496 			;;
       
  8497 	esac
       
  8498 
       
  8499 
       
  8500 	if [ $COMP_CWORD -eq 1 ]; then
       
  8501 		COMPREPLY=( $( compgen -W 'passwd group hosts services protocols networks' -- $cur ) )
       
  8502 	fi
       
  8503 } &&
       
  8504 complete -F _getent getent
       
  8505 
       
  8506 # ntpdate(1) completion
       
  8507 #
       
  8508 have ntpdate &&
       
  8509 _ntpdate()
       
  8510 {
       
  8511 	local cur prev
       
  8512 
       
  8513 	COMPREPLY=()
       
  8514 	cur=`_get_cword`
       
  8515 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8516 
       
  8517 	case $prev in
       
  8518 		-k)
       
  8519 			_filedir
       
  8520 			return 0
       
  8521 			;;
       
  8522 		-U)
       
  8523 			COMPREPLY=( $( compgen -u $cur  ) )
       
  8524 			return 0
       
  8525 			;;
       
  8526 	esac
       
  8527 
       
  8528 	if [[ "$cur" == -* ]]; then
       
  8529 		COMPREPLY=( $( compgen -W '-4 -6 -b -B -d -Q -q -s -u -v -a\
       
  8530 			-e -k -p -o -r -t' -- $cur ) )
       
  8531 	else
       
  8532 		_known_hosts
       
  8533 	fi
       
  8534 } &&
       
  8535 complete -F _ntpdate ntpdate
       
  8536 
       
  8537 # smartctl(8) completion
       
  8538 #
       
  8539 have smartctl && {
       
  8540 _smartctl_quietmode()
       
  8541 {
       
  8542 	COMPREPLY=( $( compgen -W 'errorsonly silent' -- $cur ) )
       
  8543 }
       
  8544 _smartctl_device()
       
  8545 {
       
  8546 	COMPREPLY=( $( compgen -W 'ata scsi 3ware' -- $cur ) )
       
  8547 }
       
  8548 _smartctl_tolerance()
       
  8549 {
       
  8550 	COMPREPLY=( $( compgen -W 'warn exit ignore' -- $cur ) )
       
  8551 }
       
  8552 _smartctl_badsum()
       
  8553 {
       
  8554 	COMPREPLY=( $( compgen -W 'normal conservative permissive verypermissive' -- $cur ) )
       
  8555 }
       
  8556 _smartctl_report()
       
  8557 {
       
  8558 	COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- $cur ) )
       
  8559 }
       
  8560 _smartctl_feature()
       
  8561 {
       
  8562 	COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
       
  8563 }
       
  8564 _smartctl_log()
       
  8565 {
       
  8566 	COMPREPLY=( $( compgen -W 'error selftest selective directory' -- $cur ) )
       
  8567 }
       
  8568 _smartctl_vendorattribute()
       
  8569 {
       
  8570 	COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \
       
  8571 		9,temp 192,emergencyretractcyclect 193,loadunload \
       
  8572 		194,10xCelsius 194,unknown 198,offlinescanuncsectorct \
       
  8573 		200,writeerrorcount 201,detectedtacount 220,temp' -- $cur ) )
       
  8574 }
       
  8575 _smartctl_firmwarebug()
       
  8576 {
       
  8577 	COMPREPLY=( $( compgen -W 'none samsung samsung2' -- $cur ) )
       
  8578 }
       
  8579 _smartctl_presets()
       
  8580 {
       
  8581 	COMPREPLY=( $( compgen -W 'use ignore show showall' -- $cur ) )
       
  8582 }
       
  8583 _smartctl_test()
       
  8584 {
       
  8585 	COMPREPLY=( $( compgen -W 'offline short long conveyance select afterselect,on afterselect,off pending' -- $cur ) )
       
  8586 }
       
  8587 
       
  8588 _smartctl()
       
  8589 {
       
  8590 	local cur prev
       
  8591 
       
  8592 	COMPREPLY=()
       
  8593 	cur=`_get_cword`
       
  8594 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8595 
       
  8596 	# --name value style option
       
  8597 	case "$prev" in
       
  8598 		-q)
       
  8599 			_smartctl_quietmode
       
  8600 			;;
       
  8601 		-d)
       
  8602 			_smartctl_device
       
  8603 			return 0
       
  8604 			;;
       
  8605 		-t)
       
  8606 			_smartctl_tolerance
       
  8607 			return 0
       
  8608 			;;
       
  8609 		-b)
       
  8610 			_smartctl_badsum
       
  8611 			return 0
       
  8612 			;;
       
  8613 		-r)
       
  8614 			_smartctl_report
       
  8615 			return 0
       
  8616 			;;
       
  8617 		-s)
       
  8618 			_smartctl_feature
       
  8619 			return 0
       
  8620 			;;
       
  8621 		-o)
       
  8622 			_smartctl_feature
       
  8623 			return 0
       
  8624 			;;
       
  8625 		-S)
       
  8626 			_smartctl_feature
       
  8627 			return 0
       
  8628 			;;
       
  8629 		-l)
       
  8630 			_smartctl_log
       
  8631 			return 0
       
  8632 			;;
       
  8633 		-v)
       
  8634 			_smartctl_vendorattribute
       
  8635 			return 0
       
  8636 			;;
       
  8637 		-F)
       
  8638 			_smartctl_firmwarebug
       
  8639 			return 0
       
  8640 			;;
       
  8641 		-P)
       
  8642 			_smartctl_presets
       
  8643 			return 0
       
  8644 			;;
       
  8645 		-t)
       
  8646 			_smartctl_test
       
  8647 			return 0
       
  8648 			;;
       
  8649 	esac
       
  8650 
       
  8651 	# --name=value style option
       
  8652 	if [[ "$cur" == *=* ]]; then
       
  8653 		prev=${cur/=*/}
       
  8654 		cur=${cur/*=/}
       
  8655 		case "$prev" in
       
  8656 			--quietmode)
       
  8657 				_smartctl_quietmode
       
  8658 				return 0
       
  8659 				;;
       
  8660 			--device)
       
  8661 				_smartctl_device
       
  8662 				return 0
       
  8663 				;;
       
  8664 			--tolerance)
       
  8665 				_smartctl_tolerance
       
  8666 				return 0
       
  8667 				;;
       
  8668 			--badsum)
       
  8669 				_smartctl_badsum
       
  8670 				return 0
       
  8671 				;;
       
  8672 			--report)
       
  8673 				_smartctl_report
       
  8674 				return 0
       
  8675 				;;
       
  8676 			--smart)
       
  8677 				_smartctl_feature
       
  8678 				return 0
       
  8679 				;;
       
  8680 			--offlineauto)
       
  8681 				_smartctl_feature
       
  8682 				return 0
       
  8683 				;;
       
  8684 			--saveauto)
       
  8685 				_smartctl_feature
       
  8686 				return 0
       
  8687 				;;
       
  8688 			--log)
       
  8689 				_smartctl_log
       
  8690 				return 0
       
  8691 				;;
       
  8692 			--vendorattribute)
       
  8693 				_smartctl_vendorattribute
       
  8694 				return 0
       
  8695 				;;
       
  8696 			--firmwarebug)
       
  8697 				_smartctl_firmwarebug
       
  8698 				return 0
       
  8699 				;;
       
  8700 			--presets)
       
  8701 				_smartctl_presets
       
  8702 				return 0
       
  8703 				;;
       
  8704 			--test)
       
  8705 				_smartctl_test
       
  8706 				return 0
       
  8707 				;;
       
  8708 		esac
       
  8709 	fi
       
  8710 
       
  8711 
       
  8712 	if [[ "$cur" == -* ]]; then
       
  8713 		COMPREPLY=( $( compgen -W '-h --help --usage -V --version \
       
  8714 			--copyright --license-i --info -a --all -q \
       
  8715 			--quietmode= -d --device= -T --tolerance= -b --badsum= \
       
  8716 			-r --report= -s --smart= -o --offlineauto= -S \
       
  8717 			--saveauto= -H --health -c --capabilities -A \
       
  8718 			--attributes -l --log= -v --vendorattribute= -F \
       
  8719 			--firmwarebug= -P --presets= -t --test= -C \
       
  8720 			--captive -X --abort' -- $cur ) )
       
  8721 	else
       
  8722 		cur=${cur:=/dev/}
       
  8723 		_filedir
       
  8724 	fi
       
  8725 }
       
  8726 complete -F _smartctl smartctl
       
  8727 }
       
  8728 
       
  8729 # vncviewer(1) completion
       
  8730 #
       
  8731 have vncviewer &&
       
  8732 _vncviewer()
       
  8733 {
       
  8734 	local cur prev
       
  8735 	local -a config
       
  8736     
       
  8737 	COMPREPLY=()
       
  8738 	cur=`_get_cword`
       
  8739 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8740 
       
  8741 	case "$prev" in
       
  8742 	-via)
       
  8743 	   _known_hosts -a
       
  8744 	   ;;
       
  8745 	*)
       
  8746 	   # ssh into the the server, find and ping the broadcast address, then
       
  8747 	   # sort and show the results.
       
  8748 	   COMPREPLY=( $( ssh -o 'Batchmode yes' $prev \
       
  8749 			  "ping -bnc 4 255.255.255.255" 2>/dev/null | \
       
  8750 			  awk -F ' ' '{print $4}' | \
       
  8751 			  sort -n | uniq | egrep '[0-9]+\.[0-9]+\.' 2>/dev/null ) )
       
  8752 	esac
       
  8753 								   
       
  8754 	return 0
       
  8755 } &&
       
  8756 complete -F _vncviewer vncviewer
       
  8757 
       
  8758 # sysctl(8) completion
       
  8759 #
       
  8760 have sysctl &&
       
  8761 _sysctl()
       
  8762 {
       
  8763 	local cur
       
  8764 
       
  8765 	COMPREPLY=()
       
  8766 	cur=`_get_cword`
       
  8767 
       
  8768 	COMPREPLY=( $( compgen -W "$(sysctl -N -a 2>/dev/null)" -- $cur ) )
       
  8769 
       
  8770 	return 0
       
  8771 } &&
       
  8772 complete -F _sysctl sysctl
       
  8773 
       
  8774 # update-rc.d(8) completion
       
  8775 #
       
  8776 # Copyright (C) 2004 Servilio Afre Puentes <[email protected]>
       
  8777 #
       
  8778 have update-rc.d &&
       
  8779 _update_rc_d()
       
  8780 {
       
  8781     local cur prev sysvdir services options valid_options
       
  8782 
       
  8783     cur=`_get_cword`
       
  8784     prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8785 
       
  8786     [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
       
  8787 	|| sysvdir=/etc/init.d
       
  8788 
       
  8789     services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)) )
       
  8790     services=( ${services[@]#$sysvdir/} )
       
  8791     options=( -f -n )
       
  8792 
       
  8793     if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
       
  8794 	valid_options=( $( \
       
  8795 	    echo "${COMP_WORDS[@]} ${options[@]}" \
       
  8796 	    | tr " " "\n" \
       
  8797 	    | sed -ne "/$( echo "${options[@]}" | sed "s/ /\\|/g" )/p" \
       
  8798 	    | sort | uniq -u \
       
  8799 	    ) )
       
  8800 	COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \
       
  8801 	    -X '$( echo ${COMP_WORDS[@]} | tr " " "|" )' -- $cur ) )
       
  8802     elif [[ "$prev" == ?($( echo ${services[@]} | tr " " "|" )) ]]; then
       
  8803 	COMPREPLY=( $( compgen -W 'remove defaults start stop' -- $cur ) )
       
  8804     elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then
       
  8805 	COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
       
  8806     elif [[ "$prev" == defaults && "$cur" == [sk]?([0-9]) ]]; then
       
  8807 	COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
       
  8808     elif [[ "$prev" == defaults && -z "$cur" ]]; then
       
  8809 	COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 s k )
       
  8810     elif [[ "$prev" == ?(start|stop) ]]; then
       
  8811 	if [[ "$cur" == [0-9] || -z "$cur" ]]; then 
       
  8812 	    COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
       
  8813 	elif [[ "$cur" == [0-9][0-9] ]]; then 
       
  8814 	    COMPREPLY=( $cur )
       
  8815 	else
       
  8816 	    COMPREPLY=()
       
  8817 	fi
       
  8818     elif [[ "$prev" == ?([0-9][0-9]|[0-6S]) ]]; then
       
  8819 	if [[ -z "$cur" ]]; then
       
  8820 	    if [[ $prev == [0-9][0-9] ]]; then
       
  8821 		COMPREPLY=( 0 1 2 3 4 5 6 S )
       
  8822 	    else
       
  8823 		COMPREPLY=( 0 1 2 3 4 5 6 S . )
       
  8824 	    fi
       
  8825 	elif [[ "$cur" == [0-6S.] ]]; then 
       
  8826 	    COMPREPLY=( $cur )
       
  8827 	else
       
  8828 	    COMPREPLY=()
       
  8829 	fi
       
  8830     elif [[ "$prev" == "." ]]; then
       
  8831 	COMPREPLY=( $(compgen -W "start stop" -- $cur) )
       
  8832     else
       
  8833 	COMPREPLY=()
       
  8834     fi
       
  8835 
       
  8836     return 0
       
  8837 } &&
       
  8838 complete -F _update_rc_d update-rc.d
       
  8839 
       
  8840 # invoke-rc.d(8) completion
       
  8841 #
       
  8842 # Copyright (C) 2004 Servilio Afre Puentes <[email protected]>
       
  8843 #
       
  8844 have invoke-rc.d &&
       
  8845 _invoke_rc_d()
       
  8846 {
       
  8847     local cur prev sysvdir services options valid_options
       
  8848 
       
  8849     cur=`_get_cword`
       
  8850     prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8851 
       
  8852     [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
       
  8853 	|| sysvdir=/etc/init.d
       
  8854 
       
  8855     services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)) )
       
  8856     services=( ${services[@]#$sysvdir/} )
       
  8857     options=( --help --quiet --force --try-anyway --disclose-deny --query --no-fallback )
       
  8858 
       
  8859     if [[ ($COMP_CWORD -eq 1) || ("$prev" == --* ) ]]; then
       
  8860 	valid_options=( $( \
       
  8861 	    echo ${COMP_WORDS[@]} ${options[@]} \
       
  8862 	    | tr " " "\n" \
       
  8863 	    | sed -ne "/$( echo ${options[@]} | sed "s/ /\\\\|/g" )/p" \
       
  8864 	    | sort | uniq -u \
       
  8865 	    ) )
       
  8866 	COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- \
       
  8867 	    $cur ) )
       
  8868     elif [ -x $sysvdir/$prev ]; then
       
  8869 	COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
       
  8870 					    s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \
       
  8871 					    $sysvdir/$prev`' -- \
       
  8872 	    $cur ) )
       
  8873     else
       
  8874 	COMPREPLY=()
       
  8875     fi
       
  8876 
       
  8877     return 0
       
  8878 } &&
       
  8879 complete -F _invoke_rc_d invoke-rc.d
       
  8880 
       
  8881 # minicom(1) completion
       
  8882 #
       
  8883 have minicom &&
       
  8884 _minicom()
       
  8885 {
       
  8886 	local cur prev
       
  8887 
       
  8888 	COMPREPLY=()
       
  8889 	cur=`_get_cword`
       
  8890 	prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8891 
       
  8892 	case $prev in
       
  8893 		-@(a|c))
       
  8894 			COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
       
  8895 			return 0
       
  8896 			;;
       
  8897 		-@(S|C))
       
  8898 			_filedir
       
  8899 			return 0
       
  8900 			;;
       
  8901 		-P)
       
  8902 			COMPREPLY=( $( command ls /dev/tty* ) )
       
  8903 			COMPREPLY=( $( compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' -- $cur ) )
       
  8904 			return 0
       
  8905 			;;
       
  8906 	esac
       
  8907 
       
  8908 
       
  8909 	if [[ "$cur" == -* ]]; then
       
  8910 		COMPREPLY=( $( compgen -W '-s -o -m -M -z -l -L -w -a -t \
       
  8911 			-c -S -d -p -C -T -8' -- $cur ) )
       
  8912 	else
       
  8913 		COMPREPLY=( $( command ls /etc/minicom/minirc.* 2>/dev/null | sed -e 's|/etc/minicom/minirc.||' | grep "^$cur" ) )
       
  8914 	fi
       
  8915 } &&
       
  8916 complete -F _minicom minicom
       
  8917 
       
  8918 # svn completion
       
  8919 #
       
  8920 have svn &&
       
  8921 {
       
  8922 _svn()
       
  8923 {
       
  8924 	local cur prev commands options command
       
  8925 
       
  8926 	COMPREPLY=()
       
  8927 	cur=`_get_cword`
       
  8928 
       
  8929 	commands='add blame praise annotate ann cat checkout co cleanup commit \
       
  8930 		ci copy cp delete del remove rm diff di export help ? h import \
       
  8931 		info list ls lock log merge mkdir move mv rename ren \
       
  8932 		propdel pdel pd propedit pedit pe propget pget pg \
       
  8933 		proplist plist pl propset pset ps resolved revert \
       
  8934 		status stat st switch sw unlock update up'
       
  8935 
       
  8936 	if [[ $COMP_CWORD -eq 1 ]] ; then
       
  8937 		if [[ "$cur" == -* ]]; then
       
  8938 			COMPREPLY=( $( compgen -W '--version' -- $cur ) )
       
  8939 		else
       
  8940 			COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
       
  8941 		fi
       
  8942 	else
       
  8943 
       
  8944 		prev=${COMP_WORDS[COMP_CWORD-1]}
       
  8945 		case $prev in
       
  8946 			--config-dir)
       
  8947 				_filedir -d
       
  8948 				return 0;
       
  8949 				;;
       
  8950 			-@(F|-file|-targets))
       
  8951 				_filedir
       
  8952 				return 0;
       
  8953 				;;
       
  8954 			--encoding)
       
  8955 				COMPREPLY=( $( compgen -W \
       
  8956 					'$( iconv --list | sed -e "s@//@@;" )' \
       
  8957 					-- "$cur" ) )
       
  8958 				return 0;
       
  8959 				;;
       
  8960 			--@(editor|diff|diff3)-cmd)
       
  8961 				COMP_WORDS=(COMP_WORDS[0] $cur)
       
  8962 				COMP_CWORD=1
       
  8963 				_command
       
  8964 				return 0;
       
  8965 				;;
       
  8966 		esac
       
  8967 
       
  8968 		command=${COMP_WORDS[1]}
       
  8969 
       
  8970 		if [[ "$cur" == -* ]]; then
       
  8971 			# possible options for the command
       
  8972 			case $command in
       
  8973 				add)
       
  8974 					options='--auto-props --no-auto-props \
       
  8975 						--force --targets --no-ignore \
       
  8976 						--non-recursive -N -q --quiet'
       
  8977 					;;
       
  8978 				@(blame|annotate|ann|praise))
       
  8979 					options='-r --revisions --username \
       
  8980 						--password --no-auth-cache \
       
  8981 						--non-interactive -v \
       
  8982 						--verbose --incremental --xml'
       
  8983 					;;
       
  8984 				cat)
       
  8985 					options='-r --revision --username \
       
  8986 						--password --no-auth-cache \
       
  8987 						--non-interactive'
       
  8988 					;;
       
  8989 				@(checkout|co))
       
  8990 					options='-r --revision -q --quiet -N \
       
  8991 						--non-recursive --username \
       
  8992 						--password --no-auth-cache \
       
  8993 						--non-interactive \
       
  8994 						--ignore-externals'
       
  8995 					;;
       
  8996 				cleanup)
       
  8997 					options='--diff3-cmd'
       
  8998 					;;
       
  8999 				@(commit|ci))
       
  9000 					options='-m --message -F --file \
       
  9001 						--encoding --force-log -q \
       
  9002 						--quiet --non-recursive -N \
       
  9003 						--targets --editor-cmd \
       
  9004 						--username --password \
       
  9005 						--no-auth-cache \
       
  9006 						--non-interactive --no-unlock'
       
  9007 					;;
       
  9008 				@(copy|cp))
       
  9009 					options='-m --message -F --file \
       
  9010 						--encoding --force-log -r \
       
  9011 						--revision -q --quiet \
       
  9012 						--editor-cmd -username \
       
  9013 						--password --no-auth-cache \
       
  9014 						--non-interactive'
       
  9015 					;;
       
  9016 				@(delete|del|remove|rm))
       
  9017 					options='--force -m --message -F \
       
  9018 						--file --encoding --force-log \
       
  9019 						-q --quiet --targets \
       
  9020 						--editor-cmd -username \
       
  9021 						--password --no-auth-cache \
       
  9022 						--non-interactive'
       
  9023 					;;
       
  9024 				@(diff|di))
       
  9025 					options='-r --revision -x --extensions \
       
  9026 						--diff-cmd --no-diff-deleted \
       
  9027 						-N --non-recursive --username \
       
  9028 						--password --no-auth-cache \
       
  9029 						--non-interactive --force \
       
  9030 						--old --new --notice-ancestry'
       
  9031 					;;
       
  9032 				export)
       
  9033 					options='-r --revision -q --quiet \
       
  9034 						--username --password \
       
  9035 						--no-auth-cache \
       
  9036 						--non-interactive -N \
       
  9037 						--non-recursive --force \
       
  9038 						--native-eol --ignore-externals'
       
  9039 					;;
       
  9040 				import)
       
  9041 					options='--auto-props --no-auto-props \
       
  9042 						-m --message -F --file \
       
  9043 						--encoding --force-log -q \
       
  9044 						--quiet --non-recursive \
       
  9045 						--no-ignore --editor-cmd \
       
  9046 						--username --password \
       
  9047 						--no-auth-cache \
       
  9048 						--non-interactive'
       
  9049 					;; 
       
  9050 				info)
       
  9051 					options='--username --password \
       
  9052 						--no-auth-cache \
       
  9053 						--non-interactive -r \
       
  9054 						--revision --xml --targets \
       
  9055 						-R --recursive --incremental'
       
  9056 					;;
       
  9057 				@(list|ls))
       
  9058 					options='-r --revision -v --verbose -R \
       
  9059 						--recursive --username \
       
  9060 						--password --no-auth-cache \
       
  9061 						--non-interactive \
       
  9062 						--incremental --xml'
       
  9063 					;;
       
  9064 				lock)
       
  9065 					options='-m --message -F --file \
       
  9066 						--encoding --force-log \
       
  9067 						--targets --force --username \
       
  9068 						--password --no-auth-cache \
       
  9069 						--non-interactive'
       
  9070 					;;
       
  9071 				log)
       
  9072 					options='-r --revision -v --verbose \
       
  9073 						--targets --username \
       
  9074 						--password --no-auth-cache \
       
  9075 						--non-interactive \
       
  9076 						--stop-on-copy --incremental \
       
  9077 						--xml -q --quiet --limit'
       
  9078 					;;
       
  9079 				merge)
       
  9080 					options='-r --revision -N \
       
  9081 						--non-recursive -q --quiet \
       
  9082 						--force --dry-run --diff3-cmd \
       
  9083 						--username --password \
       
  9084 						--no-auth-cache \
       
  9085 						--non-interactive \
       
  9086 						--ignore-ancestry'
       
  9087 					;;
       
  9088 				mkdir)
       
  9089 					options='-m --message -F --file \
       
  9090 						--encoding --force-log -q \
       
  9091 						--quiet --editor-cmd \
       
  9092 						--username --password \
       
  9093 						--no-auth-cache \
       
  9094 						--non-interactive'
       
  9095 					;;
       
  9096 				@(move|mv|rename|ren))
       
  9097 					options='-m --message -F --file \
       
  9098 						--encoding --force-log -r \
       
  9099 						--revision -q --quiet \
       
  9100 						--force --editor-cmd \
       
  9101 						--username --password \
       
  9102 						--no-auth-cache \
       
  9103 						--non-interactive'
       
  9104 					;;
       
  9105 				@(propdel|pdel|pd))
       
  9106 					options='-q --quiet -R --recursive -r \
       
  9107 						--revision --revprop \
       
  9108 						--username --password \
       
  9109 						--no-auth-cache \
       
  9110 						--non-interactive'
       
  9111 					;;
       
  9112 				@(propedit|pedit|pe))
       
  9113 					options='-r --revision --revprop \
       
  9114 						--encoding --editor-cmd \
       
  9115 						--username --password \
       
  9116 						--no-auth-cache \
       
  9117 						--non-interactive --force'
       
  9118 					;;
       
  9119 				@(propget|pget|pg))
       
  9120 					options='-R --recursive -r --revision \
       
  9121 						--revprop --strict --username \
       
  9122 						--password --no-auth-cache \
       
  9123 						--non-interactive'
       
  9124 					;;
       
  9125 				@(proplist|plist|pl))
       
  9126 					options='-v --verbose -R --recursive \
       
  9127 						-r --revision --revprop -q \
       
  9128 						--quiet --username --password \
       
  9129 						--no-auth-cache \
       
  9130 						--non-interactive'
       
  9131 					;;
       
  9132 				@(propset|pset|ps))
       
  9133 					options='-F --file -q --quiet \
       
  9134 						--targets -R --recursive \
       
  9135 						--revprop --encoding \
       
  9136 						--username --password \
       
  9137 						--no-auth-cache \
       
  9138 						--non-interactive -r \
       
  9139 						--revision --force'
       
  9140 					;;
       
  9141 				resolved)
       
  9142 					options='--targets -R --recursive -q \
       
  9143 						--quiet'
       
  9144 					;;
       
  9145 				revert)
       
  9146 					options='--targets -R --recursive -q \
       
  9147 						--quiet'
       
  9148 					;;
       
  9149 				@(status|stat|st))
       
  9150 					options='-u --show-updates -v \
       
  9151 						--verbose -N --non-recursive \
       
  9152 						-q --quiet --username \
       
  9153 						--password --no-auth-cache \
       
  9154 						--non-interactive --no-ignore \
       
  9155 						--ignore-externals \
       
  9156 						--incremental --xml'
       
  9157 					;;
       
  9158 				@(switch|sw))
       
  9159 					options='--relocate -r --revision -N \
       
  9160 						--non-recursive -q --quiet \
       
  9161 						--username --password \
       
  9162 						--no-auth-cache \
       
  9163 						--non-interactive --diff3-cmd'
       
  9164 					;;
       
  9165 				unlock)
       
  9166 					options='--targets --force --username \
       
  9167 						--password --no-auth-cache \
       
  9168 						--non-interactive'
       
  9169 					;;
       
  9170 				@(update|up))
       
  9171 					options='-r --revision -N \
       
  9172 						--non-recursive -q --quiet \
       
  9173 						--username --password \
       
  9174 						--no-auth-cache \
       
  9175 						--non-interactive \
       
  9176 						--diff3-cmd --ignore-externals'
       
  9177 					;;
       
  9178 			esac
       
  9179 			options="$options --help -h --config-dir"
       
  9180 
       
  9181 			COMPREPLY=( $( compgen -W "$options" -- $cur ) )
       
  9182 		else
       
  9183 			if [[ "$command" == @(help|h|\?) ]]; then
       
  9184 				COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
       
  9185 			else
       
  9186 				_filedir
       
  9187 			fi
       
  9188 		fi
       
  9189 	fi
       
  9190 
       
  9191 	return 0
       
  9192 }
       
  9193 complete -F _svn $default svn
       
  9194 
       
  9195 _svnadmin()
       
  9196 {
       
  9197 	local cur prev commands options mode
       
  9198 
       
  9199 	COMPREPLY=()
       
  9200 	cur=`_get_cword`
       
  9201 
       
  9202 	commands='create deltify dump help ? hotcopy list-dblogs \
       
  9203 		list-unused-dblogs load lslocks lstxns recover rmlocks \
       
  9204 		rmtxns setlog verify'
       
  9205 
       
  9206 	if [[ $COMP_CWORD -eq 1 ]] ; then
       
  9207 		if [[ "$cur" == -* ]]; then
       
  9208 			COMPREPLY=( $( compgen -W '--version' -- $cur ) )
       
  9209 		else
       
  9210 			COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
       
  9211 		fi
       
  9212 	else
       
  9213 		prev=${COMP_WORDS[COMP_CWORD-1]}
       
  9214 		case $prev in
       
  9215 			--config-dir)
       
  9216 				_filedir -d
       
  9217 				return 0;
       
  9218 				;;
       
  9219 			--fs-type)
       
  9220 				COMPREPLY=( $( compgen -W 'fsfs bdb' -- $cur ) )
       
  9221 				return 0;
       
  9222 				;;
       
  9223 		esac
       
  9224 
       
  9225 		command=${COMP_WORDS[1]}
       
  9226 
       
  9227 		if [[ "$cur" == -* ]]; then
       
  9228 			# possible options for the command
       
  9229 			case $command in
       
  9230 				create)
       
  9231 					options='--bdb-txn-nosync \
       
  9232 						--bdb-log-keep --config-dir \
       
  9233 						--fs-type'
       
  9234 					;;
       
  9235 				deltify)
       
  9236 					options='-r --revision -q --quiet'
       
  9237 					;;
       
  9238 				dump)
       
  9239 					options='-r --revision --incremental \
       
  9240 						-q --quiet --deltas'
       
  9241 					;;
       
  9242 				hotcopy)
       
  9243 					options='--clean-logs'
       
  9244 					;;
       
  9245 				load)
       
  9246 					options='--ignore-uuid --force-uuid \
       
  9247 						--parent-dir -q --quiet \
       
  9248 						--use-pre-commit-hook \
       
  9249 						--use-post-commit-hook'
       
  9250 					;;
       
  9251 				rmtxns)
       
  9252 					options='-q --quiet'
       
  9253 					;;
       
  9254 				setlog)
       
  9255 					options='-r --revision --bypass-hooks'
       
  9256 					;;
       
  9257 			esac
       
  9258 
       
  9259 			options="$options --help -h"
       
  9260 			COMPREPLY=( $( compgen -W "$options" -- $cur ) )
       
  9261 		else
       
  9262 			if [[ "$command" == @(help|h|\?) ]]; then
       
  9263 				COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
       
  9264 			else
       
  9265 				_filedir
       
  9266 			fi
       
  9267 		fi
       
  9268 	fi
       
  9269 
       
  9270 	return 0
       
  9271 }
       
  9272 complete -F _svnadmin $default svnadmin
       
  9273 
       
  9274 _svnlook()
       
  9275 {
       
  9276 	local cur prev commands options mode
       
  9277 
       
  9278 	COMPREPLY=()
       
  9279 	cur=`_get_cword`
       
  9280 
       
  9281 	commands='author cat changed date diff dirs-changed help ? h history \
       
  9282 		info lock log propget pget pg proplist plist pl tree uuid \
       
  9283 		youngest'
       
  9284 
       
  9285 	if [[ $COMP_CWORD -eq 1 ]] ; then
       
  9286 		if [[ "$cur" == -* ]]; then
       
  9287 			COMPREPLY=( $( compgen -W '--version' -- $cur ) )
       
  9288 		else
       
  9289 			COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
       
  9290 		fi
       
  9291 	else
       
  9292 		command=${COMP_WORDS[1]}
       
  9293 
       
  9294 		if [[ "$cur" == -* ]]; then
       
  9295 			# possible options for the command
       
  9296 			case $command in
       
  9297 				@(author|cat|date|dirs-changed|info|log))
       
  9298 					options='-r --revision -t \
       
  9299 						--transaction'
       
  9300 					;;
       
  9301 				changed)
       
  9302 					options='-r --revision -t \
       
  9303 						--transaction --copy-info'
       
  9304 					;;
       
  9305 				diff)
       
  9306 					options='-r --revision -t \
       
  9307 						--transaction \
       
  9308 						--no-diff-deleted \
       
  9309 						--no-diff-added \
       
  9310 						--diff-copy-from'
       
  9311 					;;
       
  9312 				history)
       
  9313 					options='-r --revision --show-ids'
       
  9314 					;;
       
  9315 				prop@(get|list))
       
  9316 					options='-r --revision -t \
       
  9317 						--transaction --revprop'
       
  9318 					;;
       
  9319 				tree)
       
  9320 					options='-r --revision -t \
       
  9321 						--transaction --show-ids \
       
  9322 						--full-paths'
       
  9323 					;;
       
  9324 			esac
       
  9325 
       
  9326 			options="$options --help -h"
       
  9327 			COMPREPLY=( $( compgen -W "$options" -- $cur ) )
       
  9328 		else
       
  9329 			if [[ "$command" == @(help|h|\?) ]]; then
       
  9330 				COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
       
  9331 			else
       
  9332 				_filedir
       
  9333 			fi
       
  9334 		fi
       
  9335 	fi
       
  9336 
       
  9337 	return 0
       
  9338 }
       
  9339 complete -F _svnlook $default svnlook
       
  9340 }
       
  9341 
       
  9342 _filedir_xspec()
       
  9343 {
       
  9344 	local IFS cur xspec
       
  9345 
       
  9346 	IFS=$'\t\n'
       
  9347 	COMPREPLY=()
       
  9348 	cur=`_get_cword`
       
  9349 
       
  9350 	_expand || return 0
       
  9351 
       
  9352 	# get first exclusion compspec that matches this command
       
  9353 	xspec=$( sed -ne $'/^complete .*[ \t]'${1##*/}$'\([ \t]\|$\)/{p;q;}' \
       
  9354 		  $BASH_COMPLETION )
       
  9355 	# prune to leave nothing but the -X spec
       
  9356 	xspec=${xspec#*-X }
       
  9357 	xspec=${xspec%% *}
       
  9358 
       
  9359 	local toks=( ) tmp
       
  9360 
       
  9361 	while read -r tmp; do
       
  9362 		[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
       
  9363 	done < <( compgen -d -- "$(quote_readline "$cur")" )
       
  9364 
       
  9365 	while read -r tmp; do
       
  9366 		[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
       
  9367 	done < <( eval compgen -f -X $xspec -- "\$(quote_readline "\$cur")" )
       
  9368 
       
  9369 	COMPREPLY=( "${toks[@]}" )
       
  9370 }
       
  9371 list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' \
       
  9372 	  $BASH_COMPLETION | \
       
  9373 	# read exclusion compspecs
       
  9374 	(
       
  9375 	while read line
       
  9376 	do
       
  9377 		# ignore compspecs that are commented out
       
  9378 		if [ "${line#\#}" != "$line" ]; then continue; fi
       
  9379 		line=${line%# START exclude*}
       
  9380 		line=${line%# FINISH exclude*}
       
  9381 		line=${line##*\'}
       
  9382 		list=( "${list[@]}" $line )
       
  9383 	done
       
  9384 	echo "${list[@]}"
       
  9385 	)
       
  9386      ) )
       
  9387 # remove previous compspecs
       
  9388 if [ ${#list[@]} -gt 0 ]; then
       
  9389     eval complete -r ${list[@]}
       
  9390     # install new compspecs
       
  9391     eval complete -F _filedir_xspec $filenames "${list[@]}"
       
  9392 fi
       
  9393 unset list
       
  9394 
       
  9395 # source completion directory definitions
       
  9396 if [ -d $BASH_COMPLETION_DIR -a -r $BASH_COMPLETION_DIR -a \
       
  9397      -x $BASH_COMPLETION_DIR ]; then
       
  9398 	for i in $BASH_COMPLETION_DIR/*; do
       
  9399 		[[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|.rpm*) ]] &&
       
  9400 			[ \( -f $i -o -h $i \) -a -r $i ] && . $i
       
  9401 	done
       
  9402 fi
       
  9403 unset i
       
  9404 
       
  9405 # source user completion file
       
  9406 [ $BASH_COMPLETION != ~/.bash_completion -a -r ~/.bash_completion ] \
       
  9407 	&& . ~/.bash_completion
       
  9408 unset -f have
       
  9409 unset UNAME RELEASE default dirnames filenames have nospace bashdefault \
       
  9410       plusdirs
       
  9411 
       
  9412 set $BASH_COMPLETION_ORIGINAL_V_VALUE
       
  9413 unset BASH_COMPLETION_ORIGINAL_V_VALUE
       
  9414 
       
  9415 ###  Local Variables:
       
  9416 ###  mode: shell-script
       
  9417 ###  End: