Guest User

Untitled

a guest
Feb 8th, 2011
586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 288.53 KB | None | 0 0
  1. 1,2d0
  2. < # bash_completion - programmable completion functions for bash 3.x
  3. < # (backwards compatible with bash 2.05b)
  4. 4c2
  5. < # $Id: bash_completion,v 1.872 2006/03/01 16:20:18 ianmacd Exp $
  6. ---
  7. > # bash_completion - programmable completion functions for bash 3.2+
  8. 6c4,6
  9. < # Copyright (C) Ian Macdonald <[email protected]>
  10. ---
  11. > # Copyright © 2006-2008, Ian Macdonald <[email protected]>
  12. > # © 2009-2010, Bash Completion Maintainers
  13. 24c24
  14. < # http://www.caliban.org/bash/index.shtml#completion
  15. ---
  16. > # http://bash-completion.alioth.debian.org/
  17. 26c26
  18. < # RELEASE: 20060301
  19. ---
  20. > # RELEASE: 1.1
  21. 28c28,38
  22. < [ -n "${BASH_COMPLETION_DEBUG:-}" ] && set -v || set +v
  23. ---
  24. > if [[ $- == *v* ]]; then
  25. > BASH_COMPLETION_ORIGINAL_V_VALUE="-v"
  26. > else
  27. > BASH_COMPLETION_ORIGINAL_V_VALUE="+v"
  28. > fi
  29. >
  30. > if [[ -n $BASH_COMPLETION_DEBUG ]]; then
  31. > set -v
  32. > else
  33. > set +v
  34. > fi
  35. 34c44,45
  36. < readonly BASH_COMPLETION BASH_COMPLETION_DIR
  37. ---
  38. > [ -n "$BASH_COMPLETION_COMPAT_DIR" ] || BASH_COMPLETION_COMPAT_DIR=/etc/bash_completion.d
  39. > readonly BASH_COMPLETION BASH_COMPLETION_DIR BASH_COMPLETION_COMPAT_DIR
  40. 41d51
  41. < RELEASE=$( uname -r )
  42. 43,62c53,56
  43. < # features supported by bash 2.05 and higher
  44. < if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} > 04 ]] ||
  45. < [ ${BASH_VERSINFO[0]} -gt 2 ]; then
  46. < declare -r bash205=$BASH_VERSION 2>/dev/null || :
  47. < default="-o default"
  48. < dirnames="-o dirnames"
  49. < filenames="-o filenames"
  50. < fi
  51. < # features supported by bash 2.05b and higher
  52. < if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] ||
  53. < [ ${BASH_VERSINFO[0]} -gt 2 ]; then
  54. < declare -r bash205b=$BASH_VERSION 2>/dev/null || :
  55. < nospace="-o nospace"
  56. < fi
  57. < # features supported by bash 3.0 and higher
  58. < if [ ${BASH_VERSINFO[0]} -gt 2 ]; then
  59. < declare -r bash3=$BASH_VERSION 2>/dev/null || :
  60. < bashdefault="-o bashdefault"
  61. < plusdirs="-o plusdirs"
  62. < fi
  63. ---
  64. > case ${UNAME} in
  65. > Linux|GNU|GNU/*) USERLAND=GNU ;;
  66. > *) USERLAND=${UNAME} ;;
  67. > esac
  68. 77,78c71,73
  69. < complete -f -X '!*.?(t)bz?(2)' bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
  70. < complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo|xpi|sxw|ott)' unzip zipinfo
  71. ---
  72. > # bzcmp, bzdiff, bz*grep, bzless, bzmore intentionally not here, see Debian: #455510
  73. > complete -f -X '!*.?(t)bz?(2)' bunzip2 bzcat pbunzip2 pbzcat
  74. > complete -f -X '!*.@(zip|ZIP|[ejw]ar|[EJW]AR|exe|EXE|pk3|wsz|zargo|xpi|sxw|o[tx]t|od[fgpst]|epub)' unzip zipinfo
  75. 80c75,76
  76. < complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
  77. ---
  78. > # zcmp, zdiff, z*grep, zless, zmore intentionally not here, see Debian: #455510
  79. > complete -f -X '!*.@(Z|[gGd]z|t[ag]z)' gunzip zcat unpigz
  80. 82c78,81
  81. < 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
  82. ---
  83. > # lzcmp, lzdiff intentionally not here, see Debian: #455510
  84. > complete -f -X '!*.lzma' lzcat lzegrep lzfgrep lzgrep lzless lzmore unlzma
  85. > complete -f -X '!*.@(xz|lzma)' unxz xzcat
  86. > 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
  87. 86c85
  88. < complete -f -X '!*.@(dvi|DVI)?(.@(gz|bz2))' kdvi
  89. ---
  90. > complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' kdvi
  91. 90,91c89,91
  92. < 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
  93. < complete -f -X '!*.@(?(e)ps|?(E)PS)' ps2pdf
  94. ---
  95. > complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF|dvi|DVI)?(.gz|.GZ|.bz2|.BZ2)|cb[rz]|CB[RZ]|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|fdf|FDF)' evince
  96. > complete -f -X '!*.@(okular|@(?(e|x)ps|?(E|X)PS|pdf|PDF|dvi|DVI|cb[rz]|CB[RZ]|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|epub|EPUB|odt|ODT|fb|FB|mobi|MOBI|g3|G3|chm|CHM|fdf|FDF)?(.?(gz|GZ|bz2|BZ2)))' okular
  97. > complete -f -X '!*.@(?(e)ps|?(E)PS|pdf|PDF)' ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 ps2pdfwr
  98. 93c93
  99. < complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
  100. ---
  101. > complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS|ltx|LTX)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
  102. 95c95
  103. < 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|m4p|M4P|m4v|M4V|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV|asx|ASX|mng|MNG|srt)' xine aaxine fbxine kaffeine
  104. ---
  105. > 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|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|og[gmv]|OG[GMV]|t[ps]|T[PS]|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))' xine aaxine fbxine kaffeine dragon
  106. 102,106c102,106
  107. < complete -f -X '!*.@(mid?(i)|MID?(I))' playmidi
  108. < 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
  109. < 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
  110. < 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
  111. < complete -f -X '!*.@(exe|EXE|com|COM|scr|SCR|exe.so)' wine
  112. ---
  113. > complete -f -X '!*.@(mid?(i)|MID?(I)|cmf|CMF)' playmidi
  114. > 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|s[3t]m|S[3T]M|kar|KAR)' timidity
  115. > complete -f -X '!*.@(m[eo]d|M[EO]D|s[3t]m|S[3T]M|xm|XM|it|IT)' modplugplay modplug123
  116. > 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 emacs xemacs sxemacs kate kwrite
  117. > complete -f -X '!*.@([eE][xX][eE]?(.[sS][oO])|[cC][oO][mM]|[sS][cC][rR])' wine
  118. 108,111c108,112
  119. < complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera galeon curl dillo elinks amaya
  120. < complete -f -X '!*.@(sxw|stw|sxg|sgl|doc|dot|rtf|txt|htm|html|odt|ott|odm)' oowriter
  121. < complete -f -X '!*.@(sxi|sti|pps|ppt|pot|odp|otp)' ooimpress
  122. < complete -f -X '!*.@(sxc|stc|xls|xlw|xlt|csv|ods|ots)' oocalc
  123. ---
  124. > # konqueror not here on purpose, it's more than a web/html browser
  125. > complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera galeon dillo elinks amaya firefox mozilla-firefox iceweasel google-chrome chromium-browser epiphany
  126. > complete -f -X '!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|odt|ott|odm)' oowriter
  127. > complete -f -X '!*.@(sxi|sti|pps?(x)|ppt?([mx])|pot?([mx])|odp|otp)' ooimpress
  128. > complete -f -X '!*.@(sxc|stc|xls?([bmx])|xlw|xlt?([mx])|[ct]sv|ods|ots)' oocalc
  129. 115a117,125
  130. > complete -f -X '!*.s@(qlite?(3)|?(3)db)' sqlite3
  131. > complete -f -X '!*.aux' bibtex
  132. > complete -f -X '!*.po' poedit gtranslator kbabel lokalize
  133. > complete -f -X '!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])' harbour gharbour hbpp
  134. > complete -f -X '!*.[Hh][Rr][Bb]' hbrun
  135. > complete -f -X '!*.ly' lilypond ly2dvi
  136. > complete -f -X '!*.@(dif?(f)|?(d)patch)?(.@([gx]z|bz2|lzma))' cdiff
  137. > complete -f -X '!*.@(dif?(f)|?(d)patch)' kompare
  138. > complete -f -X '!*.lyx' lyx
  139. 121,124c131
  140. < complete -u su usermod userdel passwd chage write chfn groups slay w sux
  141. <
  142. < # group commands see only groups
  143. < [ -n "$bash205" ] && complete -g groupmod groupdel newgrp 2>/dev/null
  144. ---
  145. > complete -u su passwd write chfn groups slay w sux
  146. 127c134
  147. < complete -A stopped -P '%' bg
  148. ---
  149. > complete -A stopped -P '"%' -S '"' bg
  150. 130c137
  151. < complete -j -P '%' fg jobs disown
  152. ---
  153. > complete -j -P '"%' -S '"' fg jobs disown
  154. 163,165c170,174
  155. < unset -v have
  156. < PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null &&
  157. < have="yes"
  158. ---
  159. > unset -v have
  160. > # Completions for system administrator commands are installed as well in
  161. > # case completion is attempted via `sudo command ...'.
  162. > PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null &&
  163. > have="yes"
  164. 168,171d176
  165. < # use GNU sed if we have it, since its extensions are still used in our code
  166. < #
  167. < [ $UNAME != Linux ] && have gsed && alias sed=gsed
  168. <
  169. 175c180
  170. < _rl_enabled()
  171. ---
  172. > _rl_enabled()
  173. 180c185,373
  174. < # Get the word to complete
  175. ---
  176. > # This function shell-quotes the argument
  177. > quote()
  178. > {
  179. > echo \'${1//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
  180. > }
  181. >
  182. > # @see _quote_readline_by_ref()
  183. > quote_readline()
  184. > {
  185. > local quoted
  186. > _quote_readline_by_ref "$1" ret
  187. > printf %s "$ret"
  188. > } # quote_readline()
  189. >
  190. >
  191. > # This function shell-dequotes the argument
  192. > dequote()
  193. > {
  194. > eval echo "$1" 2> /dev/null
  195. > }
  196. >
  197. >
  198. > # Assign variable one scope above the caller
  199. > # Usage: local "$1" && _upvar $1 "value(s)"
  200. > # Param: $1 Variable name to assign value to
  201. > # Param: $* Value(s) to assign. If multiple values, an array is
  202. > # assigned, otherwise a single value is assigned.
  203. > # NOTE: For assigning multiple variables, use '_upvars'. Do NOT
  204. > # use multiple '_upvar' calls, since one '_upvar' call might
  205. > # reassign a variable to be used by another '_upvar' call.
  206. > # See: http://fvue.nl/wiki/Bash:_Passing_variables_by_reference
  207. > _upvar() {
  208. > if unset -v "$1"; then # Unset & validate varname
  209. > if (( $# == 2 )); then
  210. > eval $1=\"\$2\" # Return single value
  211. > else
  212. > eval $1=\(\"\${@:2}\"\) # Return array
  213. > fi
  214. > fi
  215. > }
  216. >
  217. >
  218. > # Assign variables one scope above the caller
  219. > # Usage: local varname [varname ...] &&
  220. > # _upvars [-v varname value] | [-aN varname [value ...]] ...
  221. > # Available OPTIONS:
  222. > # -aN Assign next N values to varname as array
  223. > # -v Assign single value to varname
  224. > # Return: 1 if error occurs
  225. > # See: http://fvue.nl/wiki/Bash:_Passing_variables_by_reference
  226. > _upvars() {
  227. > if ! (( $# )); then
  228. > echo "${FUNCNAME[0]}: usage: ${FUNCNAME[0]} [-v varname"\
  229. > "value] | [-aN varname [value ...]] ..." 1>&2
  230. > return 2
  231. > fi
  232. > while (( $# )); do
  233. > case $1 in
  234. > -a*)
  235. > # Error checking
  236. > [[ ${1#-a} ]] || { echo "bash: ${FUNCNAME[0]}: \`$1': missing"\
  237. > "number specifier" 1>&2; return 1; }
  238. > printf %d "${1#-a}" &> /dev/null || { echo "bash:"\
  239. > "${FUNCNAME[0]}: \`$1': invalid number specifier" 1>&2
  240. > return 1; }
  241. > # Assign array of -aN elements
  242. > [[ "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) &&
  243. > shift $((${1#-a} + 2)) || { echo "bash: ${FUNCNAME[0]}:"\
  244. > "\`$1${2+ }$2': missing argument(s)" 1>&2; return 1; }
  245. > ;;
  246. > -v)
  247. > # Assign single value
  248. > [[ "$2" ]] && unset -v "$2" && eval $2=\"\$3\" &&
  249. > shift 3 || { echo "bash: ${FUNCNAME[0]}: $1: missing"\
  250. > "argument(s)" 1>&2; return 1; }
  251. > ;;
  252. > *)
  253. > echo "bash: ${FUNCNAME[0]}: $1: invalid option" 1>&2
  254. > return 1 ;;
  255. > esac
  256. > done
  257. > }
  258. >
  259. >
  260. > # Reassemble command line words, excluding specified characters from the
  261. > # list of word completion separators (COMP_WORDBREAKS).
  262. > # @param $1 chars Characters out of $COMP_WORDBREAKS which should
  263. > # NOT be considered word breaks. This is useful for things like scp where
  264. > # we want to return host:path and not only path, so we would pass the
  265. > # colon (:) as $1 here.
  266. > # @param $2 words Name of variable to return words to
  267. > # @param $3 cword Name of variable to return cword to
  268. > #
  269. > __reassemble_comp_words_by_ref() {
  270. > local exclude i j ref
  271. > # Exclude word separator characters?
  272. > if [[ $1 ]]; then
  273. > # Yes, exclude word separator characters;
  274. > # Exclude only those characters, which were really included
  275. > exclude="${1//[^$COMP_WORDBREAKS]}"
  276. > fi
  277. >
  278. > # Default to cword unchanged
  279. > eval $3=$COMP_CWORD
  280. > # Are characters excluded which were former included?
  281. > if [[ $exclude ]]; then
  282. > # Yes, list of word completion separators has shrunk;
  283. > # Re-assemble words to complete
  284. > for (( i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
  285. > # Is current word not word 0 (the command itself) and is word not
  286. > # empty and is word made up of just word separator characters to be
  287. > # excluded?
  288. > while [[ $i -gt 0 && ${COMP_WORDS[$i]} &&
  289. > ${COMP_WORDS[$i]//[^$exclude]} == ${COMP_WORDS[$i]}
  290. > ]]; do
  291. > [ $j -ge 2 ] && ((j--))
  292. > # Append word separator to current word
  293. > ref="$2[$j]"
  294. > eval $2[$j]=\${!ref}\${COMP_WORDS[i]}
  295. > # Indicate new cword
  296. > [ $i = $COMP_CWORD ] && eval $3=$j
  297. > # Indicate next word if available, else end *both* while and for loop
  298. > (( $i < ${#COMP_WORDS[@]} - 1)) && ((i++)) || break 2
  299. > done
  300. > # Append word to current word
  301. > ref="$2[$j]"
  302. > eval $2[$j]=\${!ref}\${COMP_WORDS[i]}
  303. > # Indicate new cword
  304. > [ $i = $COMP_CWORD ] && [[ ${COMP_WORDS[i]} ]] && eval $3=$j
  305. > done
  306. > else
  307. > # No, list of word completions separators hasn't changed;
  308. > eval $2=\( \"\${COMP_WORDS[@]}\" \)
  309. > fi
  310. > } # __reassemble_comp_words_by_ref()
  311. >
  312. >
  313. > # @param $1 exclude Characters out of $COMP_WORDBREAKS which should NOT be
  314. > # considered word breaks. This is useful for things like scp where
  315. > # we want to return host:path and not only path, so we would pass the
  316. > # colon (:) as $1 in this case. Bash-3 doesn't do word splitting, so this
  317. > # ensures we get the same word on both bash-3 and bash-4.
  318. > # @param $2 words Name of variable to return words to
  319. > # @param $3 cword Name of variable to return cword to
  320. > # @param $4 cur Name of variable to return current word to complete to
  321. > # @see ___get_cword_at_cursor_by_ref()
  322. > __get_cword_at_cursor_by_ref() {
  323. > local cword words=()
  324. > __reassemble_comp_words_by_ref "$1" words cword
  325. >
  326. > local i cur2
  327. > local cur="$COMP_LINE"
  328. > local index="$COMP_POINT"
  329. > for (( i = 0; i <= cword; ++i )); do
  330. > while [[
  331. > # Current word fits in $cur?
  332. > "${#cur}" -ge ${#words[i]} &&
  333. > # $cur doesn't match cword?
  334. > "${cur:0:${#words[i]}}" != "${words[i]}"
  335. > ]]; do
  336. > # Strip first character
  337. > cur="${cur:1}"
  338. > # Decrease cursor position
  339. > ((index--))
  340. > done
  341. >
  342. > # Does found word matches cword?
  343. > if [[ "$i" -lt "$cword" ]]; then
  344. > # No, cword lies further;
  345. > local old_size="${#cur}"
  346. > cur="${cur#${words[i]}}"
  347. > local new_size="${#cur}"
  348. > index=$(( index - old_size + new_size ))
  349. > fi
  350. > done
  351. >
  352. > if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then
  353. > # We messed up. At least return the whole word so things keep working
  354. > cur2=${words[cword]}
  355. > else
  356. > cur2=${cur:0:$index}
  357. > fi
  358. >
  359. > local "$2" "$3" "$4" &&
  360. > _upvars -a${#words[@]} $2 "${words[@]}" -v $3 "$cword" -v $4 "$cur2"
  361. > }
  362. >
  363. >
  364. > # Get the word to complete and optional previous words.
  365. 185,189c378,457
  366. < # it will complete just "foo", not "foobar", which is what the user wants.)
  367. < #
  368. < # Accepts an optional parameter indicating which characters out of
  369. < # $COMP_WORDBREAKS should NOT be considered word breaks. This is useful
  370. < # for things like scp where we want to return host:path and not only path.
  371. ---
  372. > # Also one is able to cross over possible wordbreak characters.
  373. > # Usage: _get_comp_words_by_ref [OPTIONS] [VARNAMES]
  374. > # Available VARNAMES:
  375. > # cur Return cur via $cur
  376. > # prev Return prev via $prev
  377. > # words Return words via $words
  378. > # cword Return cword via $cword
  379. > #
  380. > # Available OPTIONS:
  381. > # -n EXCLUDE Characters out of $COMP_WORDBREAKS which should NOT be
  382. > # considered word breaks. This is useful for things like scp
  383. > # where we want to return host:path and not only path, so we
  384. > # would pass the colon (:) as -n option in this case. Bash-3
  385. > # doesn't do word splitting, so this ensures we get the same
  386. > # word on both bash-3 and bash-4.
  387. > # -c VARNAME Return cur via $VARNAME
  388. > # -p VARNAME Return prev via $VARNAME
  389. > # -w VARNAME Return words via $VARNAME
  390. > # -i VARNAME Return cword via $VARNAME
  391. > #
  392. > # Example usage:
  393. > #
  394. > # $ _get_comp_words_by_ref -n : cur prev
  395. > #
  396. > _get_comp_words_by_ref()
  397. > {
  398. > local exclude flag i OPTIND=1
  399. > local cur cword words=()
  400. > local upargs=() upvars=() vcur vcword vprev vwords
  401. >
  402. > while getopts "c:i:n:p:w:" flag "$@"; do
  403. > case $flag in
  404. > c) vcur=$OPTARG ;;
  405. > i) vcword=$OPTARG ;;
  406. > n) exclude=$OPTARG ;;
  407. > p) vprev=$OPTARG ;;
  408. > w) vwords=$OPTARG ;;
  409. > esac
  410. > done
  411. > while [[ $# -ge $OPTIND ]]; do
  412. > case ${!OPTIND} in
  413. > cur) vcur=cur ;;
  414. > prev) vprev=prev ;;
  415. > cword) vcword=cword ;;
  416. > words) vwords=words ;;
  417. > *) echo "bash: $FUNCNAME(): \`${!OPTIND}': unknown argument" \
  418. > 1>&2; return 1
  419. > esac
  420. > let "OPTIND += 1"
  421. > done
  422. >
  423. > __get_cword_at_cursor_by_ref "$exclude" words cword cur
  424. >
  425. > [[ $vcur ]] && { upvars+=("$vcur" ); upargs+=(-v $vcur "$cur" ); }
  426. > [[ $vcword ]] && { upvars+=("$vcword"); upargs+=(-v $vcword "$cword"); }
  427. > [[ $vprev ]] && { upvars+=("$vprev" ); upargs+=(-v $vprev
  428. > "${words[cword - 1]}"); }
  429. > [[ $vwords ]] && { upvars+=("$vwords"); upargs+=(-a${#words[@]} $vwords
  430. > "${words[@]}"); }
  431. >
  432. > (( ${#upvars[@]} )) && local "${upvars[@]}" && _upvars "${upargs[@]}"
  433. > }
  434. >
  435. >
  436. > # Get the word to complete.
  437. > # This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases
  438. > # where the user is completing in the middle of a word.
  439. > # (For example, if the line is "ls foobar",
  440. > # and the cursor is here --------> ^
  441. > # @param $1 string Characters out of $COMP_WORDBREAKS which should NOT be
  442. > # considered word breaks. This is useful for things like scp where
  443. > # we want to return host:path and not only path, so we would pass the
  444. > # colon (:) as $1 in this case. Bash-3 doesn't do word splitting, so this
  445. > # ensures we get the same word on both bash-3 and bash-4.
  446. > # @param $2 integer Index number of word to return, negatively offset to the
  447. > # current word (default is 0, previous is 1), respecting the exclusions
  448. > # given at $1. For example, `_get_cword "=:" 1' returns the word left of
  449. > # the current word, respecting the exclusions "=:".
  450. > # @deprecated Use `_get_comp_words_by_ref cur' instead
  451. > # @see _get_comp_words_by_ref()
  452. 192,210c460,504
  453. < local i
  454. < local WORDBREAKS=${COMP_WORDBREAKS}
  455. < if [ -n $1 ]; then
  456. < for (( i=0; i<${#1}; ++i )); do
  457. < local char=${1:$i:1}
  458. < WORDBREAKS=${WORDBREAKS//$char/}
  459. < done
  460. < fi
  461. < local cur=${COMP_LINE:0:$COMP_POINT}
  462. < local tmp="${cur}"
  463. < local word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
  464. < while [ "$word_start" -ge 2 ]; do
  465. < local char=${cur:$(( $word_start - 2 )):1}
  466. < if [ "$char" != "\\" ]; then
  467. < break
  468. < fi
  469. < tmp=${COMP_LINE:0:$(( $word_start - 2 ))}
  470. < word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
  471. < done
  472. ---
  473. > local LC_CTYPE=C
  474. > local cword words
  475. > __reassemble_comp_words_by_ref "$1" words cword
  476. >
  477. > # return previous word offset by $2
  478. > if [[ ${2//[^0-9]/} ]]; then
  479. > printf "%s" "${words[cword-$2]}"
  480. > elif [[ "${#words[cword]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then
  481. > printf "%s" "${words[cword]}"
  482. > else
  483. > local i
  484. > local cur="$COMP_LINE"
  485. > local index="$COMP_POINT"
  486. > for (( i = 0; i <= cword; ++i )); do
  487. > while [[
  488. > # Current word fits in $cur?
  489. > "${#cur}" -ge ${#words[i]} &&
  490. > # $cur doesn't match cword?
  491. > "${cur:0:${#words[i]}}" != "${words[i]}"
  492. > ]]; do
  493. > # Strip first character
  494. > cur="${cur:1}"
  495. > # Decrease cursor position
  496. > ((index--))
  497. > done
  498. >
  499. > # Does found word matches cword?
  500. > if [[ "$i" -lt "$cword" ]]; then
  501. > # No, cword lies further;
  502. > local old_size="${#cur}"
  503. > cur="${cur#${words[i]}}"
  504. > local new_size="${#cur}"
  505. > index=$(( index - old_size + new_size ))
  506. > fi
  507. > done
  508. >
  509. > if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then
  510. > # We messed up! At least return the whole word so things
  511. > # keep working
  512. > printf "%s" "${words[cword]}"
  513. > else
  514. > printf "%s" "${cur:0:$index}"
  515. > fi
  516. > fi
  517. > } # _get_cword()
  518. 213,214c507,518
  519. < cur=${cur:$word_start}
  520. < echo $cur
  521. ---
  522. > # Get word previous to the current word.
  523. > # This is a good alternative to `prev=${COMP_WORDS[COMP_CWORD-1]}' because bash4
  524. > # will properly return the previous word with respect to any given exclusions to
  525. > # COMP_WORDBREAKS.
  526. > # @deprecated Use `_get_comp_words_by_ref cur prev' instead
  527. > # @see _get_comp_words_by_ref()
  528. > #
  529. > _get_pword()
  530. > {
  531. > if [ $COMP_CWORD -ge 1 ]; then
  532. > _get_cword "${@:-}" 1;
  533. > fi
  534. 217a522,595
  535. > # If the word-to-complete contains a colon (:), left-trim COMPREPLY items with
  536. > # word-to-complete.
  537. > # On bash-3, and bash-4 with a colon in COMP_WORDBREAKS, words containing
  538. > # colons are always completed as entire words if the word to complete contains
  539. > # a colon. This function fixes this, by removing the colon-containing-prefix
  540. > # from COMPREPLY items.
  541. > # The preferred solution is to remove the colon (:) from COMP_WORDBREAKS in
  542. > # your .bashrc:
  543. > #
  544. > # # Remove colon (:) from list of word completion separators
  545. > # COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
  546. > #
  547. > # See also: Bash FAQ - E13) Why does filename completion misbehave if a colon
  548. > # appears in the filename? - http://tiswww.case.edu/php/chet/bash/FAQ
  549. > # @param $1 current word to complete (cur)
  550. > # @modifies global array $COMPREPLY
  551. > #
  552. > __ltrim_colon_completions() {
  553. > # If word-to-complete contains a colon,
  554. > # and bash-version < 4,
  555. > # or bash-version >= 4 and COMP_WORDBREAKS contains a colon
  556. > if [[
  557. > "$1" == *:* && (
  558. > ${BASH_VERSINFO[0]} -lt 4 ||
  559. > (${BASH_VERSINFO[0]} -ge 4 && "$COMP_WORDBREAKS" == *:*)
  560. > )
  561. > ]]; then
  562. > # Remove colon-word prefix from COMPREPLY items
  563. > local colon_word=${1%${1##*:}}
  564. > local i=${#COMPREPLY[*]}
  565. > while [ $((--i)) -ge 0 ]; do
  566. > COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
  567. > done
  568. > fi
  569. > } # __ltrim_colon_completions()
  570. >
  571. >
  572. > # This function quotes the argument in a way so that readline dequoting
  573. > # results in the original argument. This is necessary for at least
  574. > # `compgen' which requires its arguments quoted/escaped:
  575. > #
  576. > # $ ls "a'b/"
  577. > # c
  578. > # $ compgen -f "a'b/" # Wrong, doesn't return output
  579. > # $ compgen -f "a\'b/" # Good (bash-4)
  580. > # a\'b/c
  581. > # $ compgen -f "a\\\\\'b/" # Good (bash-3)
  582. > # a\'b/c
  583. > #
  584. > # See also: http://lists.gnu.org/archive/html/bug-bash/2009-03/msg00155.html
  585. > # @param $1 Argument to quote
  586. > # @param $2 Name of variable to return result to
  587. > _quote_readline_by_ref()
  588. > {
  589. > if [[ ${1:0:1} == "'" ]]; then
  590. > # Quote word, leaving out first character
  591. > printf -v $2 %q "${1:1}"
  592. > if [[ ${BASH_VERSINFO[0]} -le 3 ]]; then
  593. > # Double-quote word on bash-3
  594. > printf -v $2 %q ${!2}
  595. > fi
  596. > elif [[ ${BASH_VERSINFO[0]} -le 3 && ${1:0:1} == '"' ]]; then
  597. > printf -v $2 %q "${1:1}"
  598. > else
  599. > printf -v $2 %q "$1"
  600. > fi
  601. >
  602. > # If result becomes quoted like this: $'string', re-evaluate in order to
  603. > # drop the additional quoting. See also: http://www.mail-archive.com/
  604. > # [email protected]/msg01942.html
  605. > [[ ${!2:0:1} == '$' ]] && eval $2=${!2}
  606. > } # _quote_readline_by_ref()
  607. >
  608. >
  609. 220,221c598,599
  610. < # If passed -d, it completes only on directories. If passed anything else,
  611. < # it's assumed to be a file glob to complete on.
  612. ---
  613. > # @param $1 If `-d', complete only on directories. Otherwise filter/pick only
  614. > # completions with `.$1' as file extension.
  615. 225c603,688
  616. < local IFS=$'\t\n' xspec #glob
  617. ---
  618. > local i IFS=$'\t\n' xspec
  619. >
  620. > __expand_tilde_by_ref cur
  621. >
  622. > local -a toks
  623. > local quoted tmp
  624. >
  625. > _quote_readline_by_ref "$cur" quoted
  626. > toks=( ${toks[@]-} $(
  627. > compgen -d -- "$quoted" | {
  628. > while read -r tmp; do
  629. > # TODO: I have removed a "[ -n $tmp ] &&" before 'printf ..',
  630. > # and everything works again. If this bug suddenly
  631. > # appears again (i.e. "cd /b<TAB>" becomes "cd /"),
  632. > # remember to check for other similar conditionals (here
  633. > # and _filedir_xspec()). --David
  634. > printf '%s\n' $tmp
  635. > done
  636. > }
  637. > ))
  638. >
  639. > # On bash-3, special characters need to be escaped extra. This is
  640. > # unless the first character is a single quote ('). If the single
  641. > # quote appears further down the string, bash default completion also
  642. > # fails, e.g.:
  643. > #
  644. > # $ ls 'a&b/'
  645. > # f
  646. > # $ foo 'a&b/<TAB> # Becomes: foo 'a&b/f'
  647. > # $ foo a'&b/<TAB> # Nothing happens
  648. > #
  649. > if [[ "$1" != -d ]]; then
  650. > xspec=${1:+"!*.$1"}
  651. > if [[ ${cur:0:1} == "'" && ${BASH_VERSINFO[0]} -ge 4 ]]; then
  652. > toks=( ${toks[@]-} $(
  653. > eval compgen -f -X \"\$xspec\" -- $quoted
  654. > ) )
  655. > else
  656. > toks=( ${toks[@]-} $(
  657. > compgen -f -X "$xspec" -- $quoted
  658. > ) )
  659. > fi
  660. > if [ ${#toks[@]} -ne 0 ]; then
  661. > # If `compopt' is available, set `-o filenames'
  662. > compopt &>/dev/null && compopt -o filenames ||
  663. > # No, `compopt' isn't available;
  664. > # Is `-o filenames' set?
  665. > [[ (
  666. > ${COMP_WORDS[0]} &&
  667. > "$(complete -p ${COMP_WORDS[0]})" == *"-o filenames"*
  668. > ) ]] || {
  669. > # No, `-o filenames' isn't set;
  670. > # Emulate `-o filenames'
  671. > # NOTE: A side-effect of emulating `-o filenames' is that
  672. > # backslash escape characters are visible within the list
  673. > # of presented completions, e.g. the completions look
  674. > # like:
  675. > #
  676. > # $ foo a<TAB>
  677. > # a\ b/ a\$b/
  678. > #
  679. > # whereas with `-o filenames' active the completions look
  680. > # like:
  681. > #
  682. > # $ ls a<TAB>
  683. > # a b/ a$b/
  684. > #
  685. > for ((i=0; i < ${#toks[@]}; i++)); do
  686. > # If directory exists, append slash (/)
  687. > if [[ ${cur:0:1} != "'" ]]; then
  688. > [[ -d ${toks[i]} ]] && toks[i]="${toks[i]}"/
  689. > if [[ ${cur:0:1} == '"' ]]; then
  690. > toks[i]=${toks[i]//\\/\\\\}
  691. > toks[i]=${toks[i]//\"/\\\"}
  692. > toks[i]=${toks[i]//\$/\\\$}
  693. > else
  694. > toks[i]=$(printf %q ${toks[i]})
  695. > fi
  696. > fi
  697. > done
  698. > }
  699. > fi
  700. > fi
  701. >
  702. > COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
  703. > } # _filedir()
  704. 227d689
  705. < _expand || return 0
  706. 229,230c691,703
  707. < #glob=$(set +o|grep noglob) # save glob setting.
  708. < #set -f # disable pathname expansion (globbing)
  709. ---
  710. > # This function splits $cur=--foo=bar into $prev=--foo, $cur=bar, making it
  711. > # easier to support both "--foo bar" and "--foo=bar" style completions.
  712. > # Returns 0 if current option was split, 1 otherwise.
  713. > #
  714. > _split_longopt()
  715. > {
  716. > if [[ "$cur" == --?*=* ]]; then
  717. > # Cut also backslash before '=' in case it ended up there
  718. > # for some reason.
  719. > prev="${cur%%?(\\)=*}"
  720. > cur="${cur#*=}"
  721. > return 0
  722. > fi
  723. 232,241c705,714
  724. < if [ "${1:-}" = -d ]; then
  725. < COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -d -- $cur ) )
  726. < #eval "$glob" # restore glob setting.
  727. < return 0
  728. < fi
  729. <
  730. < xspec=${1:+"!*.$1"} # set only if glob passed in as $1
  731. < COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -f -X "$xspec" -- "$cur" ) \
  732. < $( compgen -d -- "$cur" ) )
  733. < #eval "$glob" # restore glob setting.
  734. ---
  735. > return 1
  736. > }
  737. >
  738. > # This function tries to parse the output of $command --help
  739. > #
  740. > _parse_help() {
  741. > local cmd
  742. > cmd=$1
  743. > $cmd --help 2>&1 | command grep -- "^[[:space:]]*-" | tr "," " " | \
  744. > awk '{print $1; if ($2 ~ /-.*/) { print $2 } }' | sed -e "s:=.*::g"
  745. 248c721,738
  746. < local i
  747. ---
  748. > local i
  749. >
  750. > # standard signal completion is rather braindead, so we need
  751. > # to hack around to get what we want here, which is to
  752. > # complete on a dash, followed by the signal name minus
  753. > # the SIG prefix
  754. > COMPREPLY=( $( compgen -A signal SIG${cur#-} ))
  755. > for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
  756. > COMPREPLY[i]=-${COMPREPLY[i]#SIG}
  757. > done
  758. > }
  759. >
  760. > # This function completes on known mac addresses
  761. > #
  762. > _mac_addresses()
  763. > {
  764. > local re='\([A-Fa-f0-9]\{2\}:\)\{5\}[A-Fa-f0-9]\{2\}'
  765. > local PATH="$PATH:/sbin:/usr/sbin"
  766. 250,257c740,750
  767. < # standard signal completion is rather braindead, so we need
  768. < # to hack around to get what we want here, which is to
  769. < # complete on a dash, followed by the signal name minus
  770. < # the SIG prefix
  771. < COMPREPLY=( $( compgen -A signal SIG${cur#-} ))
  772. < for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
  773. < COMPREPLY[i]=-${COMPREPLY[i]#SIG}
  774. < done
  775. ---
  776. > # Local interfaces (Linux only?)
  777. > COMPREPLY=( "${COMPREPLY[@]}" $( ifconfig -a 2>/dev/null | sed -ne \
  778. > "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" ) )
  779. >
  780. > # ARP cache
  781. > COMPREPLY=( "${COMPREPLY[@]}" $( arp -an 2>/dev/null | sed -ne \
  782. > "s/.*[[:space:]]\($re\)[[:space:]].*/\1/p" -ne \
  783. > "s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p" ) )
  784. >
  785. > COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
  786. > __ltrim_colon_completions "$cur"
  787. 264,283c757,783
  788. < if [ -f /etc/debian_version ]; then
  789. < # Debian system
  790. < COMPREPLY=( $( sed -ne 's|^iface \([^ ]\+\).*$|\1|p' \
  791. < /etc/network/interfaces ) )
  792. < elif [ -f /etc/SuSE-release ]; then
  793. < # SuSE system
  794. < COMPREPLY=( $( command ls \
  795. < /etc/sysconfig/network/ifcfg-* | \
  796. < sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
  797. < elif [ -f /etc/pld-release ]; then
  798. < # PLD Linux
  799. < COMPREPLY=( $( command ls -B \
  800. < /etc/sysconfig/interfaces | \
  801. < sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
  802. < else
  803. < # Assume Red Hat
  804. < COMPREPLY=( $( command ls \
  805. < /etc/sysconfig/network-scripts/ifcfg-* | \
  806. < sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
  807. < fi
  808. ---
  809. > if [ -f /etc/debian_version ]; then
  810. > # Debian system
  811. > COMPREPLY=( $( compgen -W "$( sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p'\
  812. > /etc/network/interfaces )" -- "$cur" ) )
  813. > elif [ -f /etc/SuSE-release ]; then
  814. > # SuSE system
  815. > COMPREPLY=( $( compgen -W "$( printf '%s\n' \
  816. > /etc/sysconfig/network/ifcfg-* | \
  817. > sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) )
  818. > elif [ -f /etc/pld-release ]; then
  819. > # PLD Linux
  820. > COMPREPLY=( $( compgen -W "$( command ls -B \
  821. > /etc/sysconfig/interfaces | \
  822. > sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) )
  823. > else
  824. > # Assume Red Hat
  825. > COMPREPLY=( $( compgen -W "$( printf '%s\n' \
  826. > /etc/sysconfig/network-scripts/ifcfg-* | \
  827. > sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) )
  828. > fi
  829. > }
  830. >
  831. > # This function completes on available kernels
  832. > #
  833. > _kernel_versions()
  834. > {
  835. > COMPREPLY=( $( compgen -W '$( command ls /lib/modules )' -- "$cur" ) )
  836. 292c792
  837. < local cmd
  838. ---
  839. > local cmd
  840. 294,300c794,800
  841. < if [ "${1:-}" = -w ]; then
  842. < cmd="iwconfig"
  843. < elif [ "${1:-}" = -a ]; then
  844. < cmd="ifconfig"
  845. < else
  846. < cmd="ifconfig -a"
  847. < fi
  848. ---
  849. > if [ "${1:-}" = -w ]; then
  850. > cmd="iwconfig"
  851. > elif [ "${1:-}" = -a ]; then
  852. > cmd="ifconfig"
  853. > else
  854. > cmd="ifconfig -a"
  855. > fi
  856. 302,303c802,804
  857. < COMPREPLY=( $( eval $cmd 2>/dev/null | \
  858. < sed -ne 's|^\('$cur'[^[:space:][:punct:]]\{1,\}\).*$|\1|p') )
  859. ---
  860. > COMPREPLY=( $( eval PATH="$PATH:/sbin" $cmd 2>/dev/null | \
  861. > awk '/^[^ \t]/ { print $1 }' ) )
  862. > COMPREPLY=( $( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" ) )
  863. 305a807,846
  864. >
  865. > # Expand variable starting with tilde (~)
  866. > # Only the first portion of the variable from the tilde up to the first slash
  867. > # (~../) is expanded. The remainder of the variable, containing for example
  868. > # a dollar sign variable ($) or asterisk (*) is not expanded.
  869. > # Example usage:
  870. > #
  871. > # $ v="~"; __expand_tilde_by_ref v; echo "$v"
  872. > #
  873. > # Example output:
  874. > #
  875. > # v output
  876. > # -------- ----------------
  877. > # ~ /home/user
  878. > # ~foo/bar /home/foo/bar
  879. > # ~foo/$HOME /home/foo/$HOME
  880. > # ~foo/a b /home/foo/a b
  881. > # ~foo/* /home/foo/*
  882. > #
  883. > # @param $1 Name of variable (not the value of the variable) to expand
  884. > __expand_tilde_by_ref() {
  885. > # Does $1 start with tilde (~)?
  886. > if [ "${!1:0:1}" = "~" ]; then
  887. > # Does $1 contain slash (/)?
  888. > if [ "${!1}" != "${!1//\/}" ]; then
  889. > # Yes, $1 contains slash;
  890. > # 1: Remove * including and after first slash (/), i.e. "~a/b"
  891. > # becomes "~a". Double quotes allow eval.
  892. > # 2: Remove * before the first slash (/), i.e. "~a/b"
  893. > # becomes "b". Single quotes prevent eval.
  894. > # +-----1----+ +---2----+
  895. > eval $1="${!1/%\/*}"/'${!1#*/}'
  896. > else
  897. > # No, $1 doesn't contain slash
  898. > eval $1="${!1}"
  899. > fi
  900. > fi
  901. > } # __expand_tilde_by_ref()
  902. >
  903. >
  904. 310c851,852
  905. < [ "$cur" != "${cur%\\}" ] && cur="$cur\\"
  906. ---
  907. > # FIXME: Why was this here?
  908. > #[ "$cur" != "${cur%\\}" ] && cur="$cur\\"
  909. 312,320c854,865
  910. < # expand ~username type directory specifications
  911. < if [[ "$cur" == \~*/* ]]; then
  912. < eval cur=$cur
  913. <
  914. < elif [[ "$cur" == \~* ]]; then
  915. < cur=${cur#\~}
  916. < COMPREPLY=( $( compgen -P '~' -u $cur ) )
  917. < return ${#COMPREPLY[@]}
  918. < fi
  919. ---
  920. > # Expand ~username type directory specifications. We want to expand
  921. > # ~foo/... to /home/foo/... to avoid problems when $cur starting with
  922. > # a tilde is fed to commands and ending up quoted instead of expanded.
  923. >
  924. > if [[ "$cur" == \~*/* ]]; then
  925. > eval cur=$cur
  926. > elif [[ "$cur" == \~* ]]; then
  927. > cur=${cur#\~}
  928. > COMPREPLY=( $( compgen -P '~' -u "$cur" ) )
  929. > [ ${#COMPREPLY[@]} -eq 1 ] && eval COMPREPLY[0]=${COMPREPLY[0]}
  930. > return ${#COMPREPLY[@]}
  931. > fi
  932. 325c870
  933. < [ $UNAME = SunOS -o $UNAME = AIX ] &&
  934. ---
  935. > [[ $UNAME == SunOS || $UNAME == AIX ]] &&
  936. 328c873
  937. < COMPREPLY=( $( compgen -W '$( command ps -efo pid | sed 1d )' -- $cur ))
  938. ---
  939. > COMPREPLY=( $( compgen -W '$( command ps -efo pid | sed 1d )' -- "$cur" ))
  940. 332c877
  941. < COMPREPLY=( $( compgen -W '$( command ps axo pid | sed 1d )' -- $cur ) )
  942. ---
  943. > COMPREPLY=( $( compgen -W '$( command ps axo pid= )' -- "$cur" ) )
  944. 337c882
  945. < [ $UNAME = SunOS -o $UNAME = AIX ] &&
  946. ---
  947. > [[ $UNAME == SunOS || $UNAME == AIX ]] &&
  948. 340c885
  949. < COMPREPLY=( $( compgen -W '$( command ps -efo pgid | sed 1d )' -- $cur ))
  950. ---
  951. > COMPREPLY=( $( compgen -W '$( command ps -efo pgid | sed 1d )' -- "$cur" ))
  952. 344c889,912
  953. < COMPREPLY=( $( compgen -W '$( command ps axo pgid | sed 1d )' -- $cur ))
  954. ---
  955. > COMPREPLY=( $( compgen -W '$( command ps axo pgid= )' -- "$cur" ))
  956. > }
  957. >
  958. > # This function completes on process names.
  959. > # AIX and SunOS prefer X/Open, all else should be BSD.
  960. > [[ $UNAME == SunOS || $UNAME == AIX ]] &&
  961. > _pnames()
  962. > {
  963. > COMPREPLY=( $( compgen -X '<defunct>' -W '$( command ps -efo comm | \
  964. > sed -e 1d -e "s:.*/::" -e "s/^-//" | sort -u )' -- "$cur" ) )
  965. > } ||
  966. > _pnames()
  967. > {
  968. > # FIXME: completes "[kblockd/0]" to "0". Previously it was completed
  969. > # to "kblockd" which isn't correct either. "kblockd/0" would be
  970. > # arguably most correct, but killall from psmisc 22 treats arguments
  971. > # containing "/" specially unless -r is given so that wouldn't quite
  972. > # work either. Perhaps it'd be best to not complete these to anything
  973. > # for now.
  974. > # Not using "ps axo comm" because under some Linux kernels, it
  975. > # truncates command names (see e.g. http://bugs.debian.org/497540#19)
  976. > COMPREPLY=( $( compgen -X '<defunct>' -W '$( command ps axo command= | \
  977. > sed -e "s/ .*//" -e "s:.*/::" -e "s/:$//" -e "s/^[[(-]//" \
  978. > -e "s/[])]$//" | sort -u )' -- "$cur" ) )
  979. 351,360c919,926
  980. < if type getent &>/dev/null; then
  981. < COMPREPLY=( $( getent passwd | \
  982. < awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) )
  983. < elif type perl &>/dev/null; then
  984. < COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- $cur ) )
  985. < else
  986. < # make do with /etc/passwd
  987. < COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\
  988. < /etc/passwd ) )
  989. < fi
  990. ---
  991. > if type getent &>/dev/null; then
  992. > COMPREPLY=( $( compgen -W '$( getent passwd | cut -d: -f3 )' -- "$cur" ) )
  993. > elif type perl &>/dev/null; then
  994. > COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- "$cur" ) )
  995. > else
  996. > # make do with /etc/passwd
  997. > COMPREPLY=( $( compgen -W '$( cut -d: -f3 /etc/passwd )' -- "$cur" ) )
  998. > fi
  999. 367,376c933,941
  1000. < if type getent &>/dev/null; then
  1001. < COMPREPLY=( $( getent group | \
  1002. < awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) )
  1003. < elif type perl &>/dev/null; then
  1004. < COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- $cur ) )
  1005. < else
  1006. < # make do with /etc/group
  1007. < COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\
  1008. < /etc/group ) )
  1009. < fi
  1010. ---
  1011. > if type getent &>/dev/null; then
  1012. > COMPREPLY=( $( compgen -W '$( getent group | cut -d: -f3 )' \
  1013. > -- "$cur" ) )
  1014. > elif type perl &>/dev/null; then
  1015. > COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- "$cur" ) )
  1016. > else
  1017. > # make do with /etc/group
  1018. > COMPREPLY=( $( compgen -W '$( cut -d: -f3 /etc/group )' -- "$cur" ) )
  1019. > fi
  1020. 383,390c948,957
  1021. < local sysvdir famdir
  1022. < [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
  1023. < famdir=/etc/xinetd.d
  1024. < COMPREPLY=( $( builtin echo $sysvdir/!(*.rpmsave|*.rpmorig|*~|functions)) )
  1025. <
  1026. < if [ -d $famdir ]; then
  1027. < COMPREPLY=( ${COMPREPLY[@]} $( builtin echo $famdir/!(*.rpmsave|*.rpmorig|*~)) )
  1028. < fi
  1029. ---
  1030. > local sysvdir famdir
  1031. > [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
  1032. > famdir=/etc/xinetd.d
  1033. > COMPREPLY=( $( printf '%s\n' \
  1034. > $sysvdir/!(*.rpm@(orig|new|save)|*~|functions) ) )
  1035. >
  1036. > if [ -d $famdir ]; then
  1037. > COMPREPLY=( "${COMPREPLY[@]}" $( printf '%s\n' \
  1038. > $famdir/!(*.rpm@(orig|new|save)|*~) ) )
  1039. > fi
  1040. 392c959
  1041. < COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- $cur ) )
  1042. ---
  1043. > COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- "$cur" ) )
  1044. 395c962
  1045. < # This function complete on modules
  1046. ---
  1047. > # This function completes on modules
  1048. 399,402c966,969
  1049. < local modpath
  1050. < modpath=/lib/modules/$1
  1051. < COMPREPLY=( $( command ls -R $modpath | \
  1052. < sed -ne 's/^\('$cur'.*\)\.k\?o\(\|.gz\)$/\1/p') )
  1053. ---
  1054. > local modpath
  1055. > modpath=/lib/modules/$1
  1056. > COMPREPLY=( $( compgen -W "$( command ls -R $modpath | \
  1057. > sed -ne 's/^\(.*\)\.k\{0,1\}o\(\.gz\)\{0,1\}$/\1/p' )" -- "$cur" ) )
  1058. 405c972
  1059. < # this function complete on user:group format
  1060. ---
  1061. > # This function completes on installed modules
  1062. 407c974
  1063. < _usergroup()
  1064. ---
  1065. > _installed_modules()
  1066. 409,418c976,977
  1067. < local IFS=$'\n'
  1068. < cur=${cur//\\\\ / }
  1069. < if [[ $cur = *@(\\:|.)* ]] && [ -n "$bash205" ]; then
  1070. < user=${cur%%*([^:.])}
  1071. < COMPREPLY=( $(compgen -P ${user/\\\\} -g -- ${cur##*[.:]}) )
  1072. < elif [[ $cur = *:* ]] && [ -n "$bash205" ]; then
  1073. < COMPREPLY=( $( compgen -g -- ${cur##*[.:]} ) )
  1074. < else
  1075. < COMPREPLY=( $( compgen -S : -u -- $cur ) )
  1076. < fi
  1077. ---
  1078. > COMPREPLY=( $( compgen -W "$( PATH="$PATH:/sbin" lsmod | \
  1079. > awk '{if (NR != 1) print $1}' )" -- "$1" ) )
  1080. 421c980
  1081. < # this function count the number of mandatory args
  1082. ---
  1083. > # This function completes on user or user:group format; as for chown and cpio.
  1084. 423c982,986
  1085. < _count_args()
  1086. ---
  1087. > # The : must be added manually; it will only complete usernames initially.
  1088. > # The legacy user.group format is not supported.
  1089. > #
  1090. > # It assumes compopt -o filenames; but doesn't touch it.
  1091. > _usergroup()
  1092. 425,558c988,1012
  1093. < args=1
  1094. < for (( i=1; i < COMP_CWORD; i++ )); do
  1095. < if [[ "${COMP_WORDS[i]}" != -* ]]; then
  1096. < args=$(($args+1))
  1097. < fi
  1098. < done
  1099. < }
  1100. <
  1101. < # start of section containing completion functions for bash built-ins
  1102. <
  1103. < # bash alias completion
  1104. < #
  1105. < _alias()
  1106. < {
  1107. < local cur
  1108. <
  1109. < COMPREPLY=()
  1110. < cur=${COMP_WORDS[$COMP_CWORD]}
  1111. <
  1112. < case "$COMP_LINE" in
  1113. < *[^=])
  1114. < COMPREPLY=( $( compgen -A alias -S '=' -- $cur ) )
  1115. < ;;
  1116. < *=)
  1117. < COMPREPLY=( "$( alias ${cur%=} 2>/dev/null | \
  1118. < sed -e 's|^alias '$cur'\(.*\)$|\1|' )" )
  1119. < ;;
  1120. < esac
  1121. < }
  1122. < complete -F _alias $nospace alias
  1123. <
  1124. < # bash export completion
  1125. < #
  1126. < _export()
  1127. < {
  1128. < local cur
  1129. <
  1130. < COMPREPLY=()
  1131. < cur=${COMP_WORDS[$COMP_CWORD]}
  1132. <
  1133. < case "$COMP_LINE" in
  1134. < *=\$*)
  1135. < COMPREPLY=( $( compgen -v -P '$' -- ${cur#*=\$} ) )
  1136. < ;;
  1137. < *[^=])
  1138. < COMPREPLY=( $( compgen -v -S '=' -- $cur ) )
  1139. < ;;
  1140. < *=)
  1141. < COMPREPLY=( "$( eval echo -n \"$`echo ${cur%=}`\" |
  1142. < ( echo -n \'
  1143. < sed -e 's/'\''/'\''\\\'\'''\''/g'
  1144. < echo -n \' ) )" )
  1145. < ;;
  1146. < esac
  1147. < }
  1148. < complete -F _export $default $nospace export
  1149. <
  1150. < # bash shell function completion
  1151. < #
  1152. < _function()
  1153. < {
  1154. < local cur prev
  1155. <
  1156. < COMPREPLY=()
  1157. < cur=`_get_cword`
  1158. < prev=${COMP_WORDS[COMP_CWORD-1]}
  1159. <
  1160. < if [[ $1 == @(declare|typeset) ]]; then
  1161. < if [ "$prev" = -f ]; then
  1162. < COMPREPLY=( $( compgen -A function -- $cur ) )
  1163. < elif [[ "$cur" == -* ]]; then
  1164. < COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- \
  1165. < $cur ) )
  1166. < fi
  1167. < elif [ $COMP_CWORD -eq 1 ]; then
  1168. < COMPREPLY=( $( compgen -A function -- $cur ) )
  1169. < else
  1170. < COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" )
  1171. < fi
  1172. < }
  1173. < complete -F _function function declare typeset
  1174. <
  1175. < # bash complete completion
  1176. < #
  1177. < _complete()
  1178. < {
  1179. < local cur prev options
  1180. <
  1181. < COMPREPLY=()
  1182. < cur=`_get_cword`
  1183. < prev=${COMP_WORDS[COMP_CWORD-1]}
  1184. <
  1185. < case $prev in
  1186. < -o)
  1187. < options="default dirnames filenames"
  1188. < [ -n "$bash205b" ] && options="$options nospace"
  1189. < [ -n "$bash3" ] && options="$options bashdefault plusdirs"
  1190. < COMPREPLY=( $( compgen -W "$options" -- $cur ) )
  1191. < return 0
  1192. < ;;
  1193. <
  1194. < -A)
  1195. < COMPREPLY=( $( compgen -W 'alias arrayvar binding \
  1196. < builtin command directory disabled enabled \
  1197. < export file function group helptopic hostname \
  1198. < job keyword running service setopt shopt \
  1199. < signal stopped user variable' -- $cur ) )
  1200. < return 0
  1201. < ;;
  1202. <
  1203. < -C)
  1204. < COMPREPLY=( $( compgen -A command -- $cur ) )
  1205. < return 0
  1206. < ;;
  1207. < -F)
  1208. < COMPREPLY=( $( compgen -A function -- $cur ) )
  1209. < return 0
  1210. < ;;
  1211. < -@(p|r))
  1212. < COMPREPLY=( $( complete -p | sed -e 's|.* ||' | \
  1213. < grep "^$cur" ) )
  1214. < return 0
  1215. < ;;
  1216. <
  1217. < esac
  1218. <
  1219. < if [[ "$cur" == -* ]]; then
  1220. < # relevant options completion
  1221. < options="-a -b -c -d -e -f -g -j -k -s -v -u -A -G -W -P -S -X -F -C"
  1222. < [ -n "$bash205" ] && options="$options -o"
  1223. < COMPREPLY=( $( compgen -W "$options" -- $cur ) )
  1224. < else
  1225. < COMPREPLY=( $( compgen -A command -- $cur ) )
  1226. < fi
  1227. ---
  1228. > local IFS=$'\n'
  1229. > if [[ $cur = *\\\\* || $cur = *:*:* ]]; then
  1230. > # Give up early on if something seems horribly wrong.
  1231. > return
  1232. > elif [[ $cur = *\\:* ]]; then
  1233. > # Completing group after 'user\:gr<TAB>'.
  1234. > # Reply with a list of groups prefixed with 'user:', readline will
  1235. > # escape to the colon.
  1236. > local prefix
  1237. > prefix=${cur%%*([^:])}
  1238. > prefix=${prefix//\\}
  1239. > COMPREPLY=( $( compgen -P "$prefix" -g -- "${cur#*[:]}" ) )
  1240. > elif [[ $cur = *:* ]]; then
  1241. > # Completing group after 'user:gr<TAB>'.
  1242. > # Reply with a list of unprefixed groups since readline with split on :
  1243. > # and only replace the 'gr' part
  1244. > COMPREPLY=( $( compgen -g -- "${cur#*:}" ) )
  1245. > else
  1246. > # Completing a partial 'usernam<TAB>'.
  1247. > #
  1248. > # Don't suffix with a : because readline will escape it and add a
  1249. > # slash. It's better to complete into 'chown username ' than 'chown
  1250. > # username\:'.
  1251. > COMPREPLY=( $( compgen -u -- "$cur" ) )
  1252. > fi
  1253. 560,562d1013
  1254. < complete -F _complete complete
  1255. <
  1256. < # start of section containing completion functions for external programs
  1257. 564,2428c1015,1022
  1258. < # a little help for FreeBSD ports users
  1259. < [ $UNAME = FreeBSD ] && complete -W 'index search fetch fetch-list \
  1260. < extract patch configure build install reinstall \
  1261. < deinstall clean clean-depends kernel buildworld' make
  1262. <
  1263. < # This completes on a list of all available service scripts for the
  1264. < # 'service' command and/or the SysV init.d directory, followed by
  1265. < # that script's available commands
  1266. < #
  1267. < { have service || [ -d /etc/init.d/ ]; } &&
  1268. < _service()
  1269. < {
  1270. < local cur sysvdir
  1271. <
  1272. < COMPREPLY=()
  1273. < prev=${COMP_WORDS[COMP_CWORD-1]}
  1274. < cur=`_get_cword`
  1275. <
  1276. < # don't complete for things like killall, ssh and mysql if it's
  1277. < # the standalone command, rather than the init script
  1278. < [[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|service) ]] && return 0
  1279. <
  1280. < # don't complete past 2nd token
  1281. < [ $COMP_CWORD -gt 2 ] && return 0
  1282. <
  1283. < [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
  1284. < || sysvdir=/etc/init.d
  1285. <
  1286. < if [[ $COMP_CWORD -eq 1 ]] && [[ $prev == "service" ]]; then
  1287. < _services
  1288. < else
  1289. < COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
  1290. < s/^.*Usage.*{\(.*\)}.*$/\1/p" \
  1291. < $sysvdir/${prev##*/} 2>/dev/null`' -- $cur ) )
  1292. < fi
  1293. <
  1294. < return 0
  1295. < } &&
  1296. < complete -F _service service
  1297. < [ -d /etc/init.d/ ] && complete -F _service $default \
  1298. < $(for i in /etc/init.d/*; do echo ${i##*/}; done)
  1299. <
  1300. < # chown(1) completion
  1301. < #
  1302. < _chown()
  1303. < {
  1304. < local cur
  1305. < cur=`_get_cword`
  1306. <
  1307. < # options completion
  1308. < if [[ "$cur" == -* ]]; then
  1309. < COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \
  1310. < --dereference --no-dereference --from= --silent --quiet \
  1311. < --reference= --recursive --verbose --help --version' -- $cur ) )
  1312. < else
  1313. < _count_args
  1314. <
  1315. < case $args in
  1316. < 1)
  1317. < _usergroup
  1318. < ;;
  1319. < *)
  1320. < _filedir
  1321. < ;;
  1322. < esac
  1323. < fi
  1324. < }
  1325. < complete -F _chown $filenames chown
  1326. <
  1327. < # chgrp(1) completion
  1328. < #
  1329. < _chgrp()
  1330. < {
  1331. < local cur prev
  1332. <
  1333. < COMPREPLY=()
  1334. < cur=`_get_cword`
  1335. < cur=${cur//\\\\/}
  1336. < prev=${COMP_WORDS[COMP_CWORD-1]}
  1337. <
  1338. < # options completion
  1339. < if [[ "$cur" == -* ]]; then
  1340. < COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \
  1341. < --dereference --no-dereference --silent --quiet \
  1342. < --reference= --recursive --verbose --help --version' -- $cur ) )
  1343. < return 0
  1344. < fi
  1345. <
  1346. < # first parameter on line or first since an option?
  1347. < if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || \
  1348. < [[ "$prev" == -* ]] && [ -n "$bash205" ]; then
  1349. < local IFS=$'\n'
  1350. < COMPREPLY=( $( compgen -g $cur 2>/dev/null ) )
  1351. < else
  1352. < _filedir || return 0
  1353. < fi
  1354. <
  1355. < return 0
  1356. < }
  1357. < complete -F _chgrp $filenames chgrp
  1358. <
  1359. < # umount(8) completion. This relies on the mount point being the third
  1360. < # space-delimited field in the output of mount(8)
  1361. < #
  1362. < _umount()
  1363. < {
  1364. < local cur
  1365. <
  1366. < COMPREPLY=()
  1367. < cur=`_get_cword`
  1368. <
  1369. < OLDIFS="$IFS"
  1370. < IFS="\n"
  1371. < COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- $cur ) )
  1372. < IFS="$OLDIFS"
  1373. <
  1374. < return 0
  1375. < }
  1376. < complete -F _umount $dirnames umount
  1377. <
  1378. < # mount(8) completion. This will pull a list of possible mounts out of
  1379. < # /etc/{,v}fstab, unless the word being completed contains a ':', which
  1380. < # would indicate the specification of an NFS server. In that case, we
  1381. < # query the server for a list of all available exports and complete on
  1382. < # that instead.
  1383. < #
  1384. < _mount()
  1385. < { local cur i sm host
  1386. <
  1387. < COMPREPLY=()
  1388. < cur=`_get_cword`
  1389. < [[ "$cur" == \\ ]] && cur="/"
  1390. <
  1391. < for i in {,/usr}/{,s}bin/showmount; do [ -x $i ] && sm=$i && break; done
  1392. <
  1393. < if [ -n "$sm" ] && [[ "$cur" == *:* ]]; then
  1394. < COMPREPLY=( $( $sm -e ${cur%%:*} | sed 1d | \
  1395. < grep ^${cur#*:} | awk '{print $1}' ) )
  1396. < elif [[ "$cur" == //* ]]; then
  1397. < host=${cur#//}
  1398. < host=${host%%/*}
  1399. < if [ -n "$host" ]; then
  1400. < COMPREPLY=( $( compgen -W "$( echo $( smbclient -d 0 -NL $host 2>/dev/null|
  1401. < sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' |
  1402. < sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|//'$host'/\1|p' ) )" -- "$cur" ) )
  1403. < fi
  1404. < elif [ -r /etc/vfstab ]; then
  1405. < # Solaris
  1406. < COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \
  1407. < /etc/vfstab | grep "^$cur" ) )
  1408. < elif [ ! -e /etc/fstab ]; then
  1409. < # probably Cygwin
  1410. < COMPREPLY=( $( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \
  1411. < | grep "^$cur" ) )
  1412. < else
  1413. < # probably Linux
  1414. < COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' \
  1415. < /etc/fstab | grep "^$cur" ) )
  1416. < fi
  1417. <
  1418. < return 0
  1419. < }
  1420. < complete -F _mount $default $filenames mount
  1421. <
  1422. < # Linux rmmod(8) completion. This completes on a list of all currently
  1423. < # installed kernel modules.
  1424. < #
  1425. < have rmmod && {
  1426. < _rmmod()
  1427. < {
  1428. < local cur
  1429. <
  1430. < COMPREPLY=()
  1431. < cur=`_get_cword`
  1432. <
  1433. < COMPREPLY=( $( /sbin/lsmod | \
  1434. < awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' 2>/dev/null ))
  1435. < return 0
  1436. < }
  1437. < complete -F _rmmod rmmod
  1438. <
  1439. < # Linux insmod(8), modprobe(8) and modinfo(8) completion. This completes on a
  1440. < # list of all available modules for the version of the kernel currently
  1441. < # running.
  1442. < #
  1443. < _insmod()
  1444. < {
  1445. < local cur prev modpath
  1446. <
  1447. < COMPREPLY=()
  1448. < cur=`_get_cword`
  1449. < prev=${COMP_WORDS[COMP_CWORD-1]}
  1450. <
  1451. < # behave like lsmod for modprobe -r
  1452. < if [ $1 = "modprobe" ] &&
  1453. < [ "${COMP_WORDS[1]}" = "-r" ]; then
  1454. < COMPREPLY=( $( /sbin/lsmod | \
  1455. < awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' ) )
  1456. < return 0
  1457. < fi
  1458. <
  1459. < # do filename completion if we're giving a path to a module
  1460. < if [[ "$cur" == */* ]]; then
  1461. < _filedir '@(?(k)o?(.gz))'
  1462. < return 0
  1463. < fi
  1464. <
  1465. < if [ $COMP_CWORD -gt 1 ] &&
  1466. < [[ "${COMP_WORDS[COMP_CWORD-1]}" != -* ]]; then
  1467. < # do module parameter completion
  1468. < COMPREPLY=( $( /sbin/modinfo -p ${COMP_WORDS[1]} 2>/dev/null | \
  1469. < awk '{if ($1 ~ /^parm:/ && $2 ~ /^'$cur'/) { print $2 } \
  1470. < else if ($1 !~ /:/ && $1 ~ /^'$cur'/) { print $1 }}' ) )
  1471. < else
  1472. < _modules $(uname -r)
  1473. < fi
  1474. <
  1475. < return 0
  1476. < }
  1477. < complete -F _insmod $filenames insmod modprobe modinfo
  1478. < }
  1479. <
  1480. < # man(1) completion
  1481. < #
  1482. < [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
  1483. < -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
  1484. < -o $UNAME = OpenBSD ] &&
  1485. < _man()
  1486. < {
  1487. < local cur prev sect manpath UNAME
  1488. <
  1489. < COMPREPLY=()
  1490. < cur=`_get_cword`
  1491. < prev=${COMP_WORDS[COMP_CWORD-1]}
  1492. <
  1493. < _expand || return 0
  1494. <
  1495. < # default completion if parameter contains /
  1496. < if [[ "$cur" == */* ]]; then
  1497. < _filedir
  1498. < return 0
  1499. < fi
  1500. <
  1501. < UNAME=$( uname -s )
  1502. < # strip OS type and version under Cygwin
  1503. < UNAME=${UNAME/CYGWIN_*/Cygwin}
  1504. < if [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = FreeBSD \
  1505. < -o $UNAME = Cygwin ]; then
  1506. < manpath=$( manpath 2>/dev/null || command man --path )
  1507. < else
  1508. < manpath=$MANPATH
  1509. < fi
  1510. <
  1511. < if [ -z "$manpath" ]; then
  1512. < COMPREPLY=( $( compgen -c -- $cur ) )
  1513. < return 0
  1514. < fi
  1515. <
  1516. < # determine manual section to search
  1517. < [[ "$prev" == [0-9ln] ]] && sect=$prev || sect='*'
  1518. <
  1519. < manpath=$manpath:
  1520. < if [ -n "$cur" ]; then
  1521. < manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }"
  1522. < else
  1523. < manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"
  1524. < fi
  1525. <
  1526. < # redirect stderr for when path doesn't exist
  1527. < COMPREPLY=( $( eval command ls "$manpath" 2>/dev/null ) )
  1528. < # weed out directory path names and paths to man pages
  1529. < COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
  1530. < # strip suffix from man pages
  1531. < COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2)} )
  1532. < COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
  1533. <
  1534. < [[ "$prev" != [0-9ln] ]] && _filedir '[0-9ln]'
  1535. <
  1536. < return 0
  1537. < }
  1538. < [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
  1539. < -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
  1540. < -o $UNAME = OpenBSD ] && \
  1541. < complete -F _man $filenames man apropos whatis
  1542. <
  1543. < # renice(8) completion
  1544. < #
  1545. < _renice()
  1546. < {
  1547. < local command cur curopt i
  1548. <
  1549. < COMPREPLY=()
  1550. < cur=`_get_cword`
  1551. < command=$1
  1552. <
  1553. < i=0
  1554. < # walk back through command line and find last option
  1555. < while [ $i -le $COMP_CWORD -a ${#COMPREPLY[@]} -eq 0 ]; do
  1556. < curopt=${COMP_WORDS[COMP_CWORD-$i]}
  1557. < case "$curopt" in
  1558. < -u)
  1559. < COMPREPLY=( $( compgen -u -- $cur ) )
  1560. < ;;
  1561. < -g)
  1562. < _pgids
  1563. < ;;
  1564. < -p|$command)
  1565. < _pids
  1566. < ;;
  1567. < esac
  1568. < i=$(( ++i ))
  1569. < done
  1570. < }
  1571. < complete -F _renice renice
  1572. <
  1573. < # kill(1) completion
  1574. < #
  1575. < _kill()
  1576. < {
  1577. < local cur
  1578. <
  1579. < COMPREPLY=()
  1580. < cur=`_get_cword`
  1581. <
  1582. < if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
  1583. < # return list of available signals
  1584. < _signals
  1585. < else
  1586. < # return list of available PIDs
  1587. < _pids
  1588. < fi
  1589. < }
  1590. < complete -F _kill kill
  1591. <
  1592. < # Linux and FreeBSD killall(1) completion.
  1593. < #
  1594. < [ $UNAME = Linux -o $UNAME = FreeBSD ] &&
  1595. < _killall()
  1596. < {
  1597. < local cur
  1598. <
  1599. < COMPREPLY=()
  1600. < cur=`_get_cword`
  1601. <
  1602. < if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
  1603. < _signals
  1604. < else
  1605. < COMPREPLY=( $( compgen -W '$( command ps axo command | \
  1606. < sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \
  1607. < sed -e "s/.*\///" )' -- $cur ) )
  1608. < fi
  1609. <
  1610. < return 0
  1611. < }
  1612. < [ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _killall killall pkill
  1613. <
  1614. < # Linux and FreeBSD pgrep(1) completion.
  1615. < #
  1616. < [ $UNAME = Linux -o $UNAME = FreeBSD ] &&
  1617. < _pgrep()
  1618. < {
  1619. < local cur
  1620. <
  1621. < COMPREPLY=()
  1622. < cur=`_get_cword`
  1623. <
  1624. < COMPREPLY=( $( compgen -W '$( command ps axo command | \
  1625. < sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \
  1626. < sed -e "s/.*\///" )' -- $cur ) )
  1627. <
  1628. < return 0
  1629. < }
  1630. < [ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _pgrep pgrep
  1631. < # Linux pidof(8) completion.
  1632. < [ $UNAME = Linux ] && complete -F _pgrep pidof
  1633. <
  1634. < # GNU find(1) completion. This makes heavy use of ksh style extended
  1635. < # globs and contains Linux specific code for completing the parameter
  1636. < # to the -fstype option.
  1637. < #
  1638. < _find()
  1639. < {
  1640. < local cur prev i exprfound onlyonce
  1641. <
  1642. < COMPREPLY=()
  1643. < cur=`_get_cword`
  1644. < prev=${COMP_WORDS[COMP_CWORD-1]}
  1645. <
  1646. < case "$prev" in
  1647. < -@(max|min)depth)
  1648. < COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- $cur ) )
  1649. < return 0
  1650. < ;;
  1651. < -?(a|c)newer|-fls|-fprint?(0|f)|-?(i)?(l)name|-?(i)wholename)
  1652. < _filedir
  1653. < return 0
  1654. < ;;
  1655. < -fstype)
  1656. < # this is highly non-portable
  1657. < [ -e /proc/filesystems ] &&
  1658. < COMPREPLY=( $( cut -d$'\t' -f 2 /proc/filesystems | \
  1659. < grep "^$cur" ) )
  1660. < return 0
  1661. < ;;
  1662. < -gid)
  1663. < _gids
  1664. < return 0
  1665. < ;;
  1666. < -group)
  1667. < if [ -n "$bash205" ]; then
  1668. < COMPREPLY=( $( compgen -g -- $cur 2>/dev/null) )
  1669. < fi
  1670. < return 0
  1671. < ;;
  1672. < -?(x)type)
  1673. < COMPREPLY=( $( compgen -W 'b c d p f l s' -- $cur ) )
  1674. < return 0
  1675. < ;;
  1676. < -uid)
  1677. < _uids
  1678. < return 0
  1679. < ;;
  1680. < -user)
  1681. < COMPREPLY=( $( compgen -u -- $cur ) )
  1682. < return 0
  1683. < ;;
  1684. < -exec|-ok)
  1685. < COMP_WORDS=(COMP_WORDS[0] $cur)
  1686. < COMP_CWORD=1
  1687. < _command
  1688. < return 0
  1689. < ;;
  1690. < -[acm]min|-[acm]time|-?(i)?(l)name|-inum|-?(i)path|-?(i)regex| \
  1691. < -links|-perm|-size|-used|-printf)
  1692. < # do nothing, just wait for a parameter to be given
  1693. < return 0
  1694. < ;;
  1695. < esac
  1696. <
  1697. < _expand || return 0
  1698. <
  1699. < # set exprfound to 1 if there is already an expression present
  1700. < for i in ${COMP_WORDS[@]}; do
  1701. < [[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break
  1702. < done
  1703. <
  1704. < # handle case where first parameter is not a dash option
  1705. < if [ "$exprfound" != 1 ] && [[ "$cur" != [-\(\),\!]* ]]; then
  1706. < _filedir -d
  1707. < return 0
  1708. < fi
  1709. <
  1710. < # complete using basic options
  1711. < COMPREPLY=( $( compgen -W '-daystart -depth -follow -help -maxdepth \
  1712. < -mindepth -mount -noleaf -version -xdev -amin -anewer \
  1713. < -atime -cmin -cnewer -ctime -empty -false -fstype \
  1714. < -gid -group -ilname -iname -inum -ipath -iregex \
  1715. < -wholename \
  1716. < -links -lname -mmin -mtime -name -newer -nouser \
  1717. < -nogroup -perm -regex -size -true -type -uid -used \
  1718. < -user -xtype -exec -fls -fprint -fprint0 -fprintf -ok \
  1719. < -print -print0 -printf -prune -ls' -- $cur ) )
  1720. <
  1721. < # this removes any options from the list of completions that have
  1722. < # already been specified somewhere on the command line, as long as
  1723. < # these options can only be used once (in a word, "options", in
  1724. < # opposition to "tests" and "actions", as in the find(1) manpage).
  1725. < onlyonce=' -daystart -depth -follow -help -maxdepth -mindepth -mount \
  1726. < -noleaf -version -xdev '
  1727. < COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \
  1728. < (while read -d ' ' i; do
  1729. < [ "$i" == "" ] ||
  1730. < [ "${onlyonce/ ${i%% *} / }" == "$onlyonce" ] &&
  1731. < continue
  1732. < # flatten array with spaces on either side,
  1733. < # otherwise we cannot grep on word boundaries of
  1734. < # first and last word
  1735. < COMPREPLY=" ${COMPREPLY[@]} "
  1736. < # remove word from list of completions
  1737. < COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
  1738. < done
  1739. < echo ${COMPREPLY[@]})
  1740. < ) )
  1741. <
  1742. < _filedir
  1743. <
  1744. < return 0
  1745. < }
  1746. < complete -F _find $filenames find
  1747. <
  1748. < # Linux iwconfig(8) completion
  1749. < #
  1750. < [ $UNAME = Linux ] && have iwconfig &&
  1751. < _iwconfig()
  1752. < {
  1753. < local cur prev
  1754. <
  1755. < COMPREPLY=()
  1756. < cur=`_get_cword`
  1757. < prev=${COMP_WORDS[COMP_CWORD-1]}
  1758. <
  1759. < case $prev in
  1760. < mode)
  1761. < COMPREPLY=( $( compgen -W 'managed ad-hoc master \
  1762. < repeater secondary monitor' -- $cur ) )
  1763. < return 0
  1764. < ;;
  1765. < essid)
  1766. < COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
  1767. < if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
  1768. < COMPREPLY=( ${COMPREPLY[@]:-} \
  1769. < $( iwlist ${COMP_WORDS[1]} scan | \
  1770. < awk -F '"' '/ESSID/ {print $2}' | \
  1771. < grep "^$cur" ))
  1772. < fi
  1773. < return 0
  1774. < ;;
  1775. < nwid)
  1776. < COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
  1777. < return 0
  1778. < ;;
  1779. < channel)
  1780. < COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \
  1781. < awk '/^[[:space:]]*Channel/ {print $2}' | \
  1782. < grep "^$cur" ) )
  1783. < return 0
  1784. < ;;
  1785. <
  1786. < freq)
  1787. < COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \
  1788. < awk '/^[[:space:]]*Channel/ {print $4"G"}' | \
  1789. < grep "^$cur" ) )
  1790. < return 0
  1791. < ;;
  1792. < ap)
  1793. < COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
  1794. < if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
  1795. < COMPREPLY=( ${COMPREPLY[@]:-} \
  1796. < $( iwlist ${COMP_WORDS[1]} scan | \
  1797. < awk -F ': ' '/Address/ {print $2}' | \
  1798. < grep "^$cur" ) )
  1799. < fi
  1800. < return 0
  1801. < ;;
  1802. < rate)
  1803. < COMPREPLY=( $( compgen -W 'auto fixed' -- $cur ) )
  1804. < COMPREPLY=( ${COMPREPLY[@]:-} \
  1805. < $( iwlist ${COMP_WORDS[1]} rate | \
  1806. < awk '/^[[:space:]]*[0-9]/ {print $1"M"}' | \
  1807. < grep "^$cur" ) )
  1808. < return 0
  1809. < ;;
  1810. < rts)
  1811. < COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) )
  1812. < return 0
  1813. < ;;
  1814. < frag)
  1815. < COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) )
  1816. < return 0
  1817. < ;;
  1818. < key)
  1819. < COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) )
  1820. < return 0
  1821. < ;;
  1822. < enc)
  1823. < COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) )
  1824. < return 0
  1825. < ;;
  1826. < power)
  1827. < COMPREPLY=( $( compgen -W 'period timeout off on' -- $cur ) )
  1828. < return 0
  1829. < ;;
  1830. < txpower)
  1831. < COMPREPLY=( $( compgen -W 'off on auto' -- $cur ) )
  1832. < return 0
  1833. < ;;
  1834. < retry)
  1835. < COMPREPLY=( $( compgen -W 'limit lifetime' -- $cur ) )
  1836. < return 0
  1837. < ;;
  1838. < esac
  1839. <
  1840. < if [ $COMP_CWORD -eq 1 ]; then
  1841. < if [[ "$cur" == -* ]]; then
  1842. < COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
  1843. < else
  1844. < _available_interfaces -w
  1845. < fi
  1846. < else
  1847. < COMPREPLY=( $( compgen -W 'essid nwid mode freq channel sens mode \
  1848. < ap nick rate rts frag enc key power txpower commit' -- $cur ) )
  1849. < fi
  1850. <
  1851. < } &&
  1852. < complete -F _iwconfig iwconfig
  1853. <
  1854. < # Linux iwlist(8) completion
  1855. < #
  1856. < [ $UNAME = Linux ] && have iwlist &&
  1857. < _iwlist()
  1858. < {
  1859. < local cur prev
  1860. <
  1861. < COMPREPLY=()
  1862. < cur=`_get_cword`
  1863. < prev=${COMP_WORDS[COMP_CWORD-1]}
  1864. <
  1865. < if [ $COMP_CWORD -eq 1 ]; then
  1866. < if [[ "$cur" == -* ]]; then
  1867. < COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
  1868. < else
  1869. < _available_interfaces -w
  1870. < fi
  1871. < else
  1872. < COMPREPLY=( $( compgen -W 'scan scanning freq frequency \
  1873. < channel rate bit bitrate key enc encryption power \
  1874. < txpower retry ap accesspoint peers event' -- $cur ) )
  1875. < fi
  1876. < } &&
  1877. < complete -F _iwlist iwlist
  1878. <
  1879. < # Linux iwspy(8) completion
  1880. < #
  1881. < [ $UNAME = Linux ] && have iwspy &&
  1882. < _iwspy()
  1883. < {
  1884. < local cur
  1885. <
  1886. < COMPREPLY=()
  1887. < cur=`_get_cword`
  1888. <
  1889. < if [ $COMP_CWORD -eq 1 ]; then
  1890. < if [[ "$cur" == -* ]]; then
  1891. < COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
  1892. < else
  1893. < _available_interfaces -w
  1894. < fi
  1895. < else
  1896. < COMPREPLY=( $( compgen -W 'setthr getthr off' -- $cur ) )
  1897. < fi
  1898. < } &&
  1899. < complete -F _iwspy iwspy
  1900. <
  1901. < # Linux iwpriv(8) completion
  1902. < #
  1903. < [ $UNAME = Linux ] && have iwpriv &&
  1904. < _iwpriv()
  1905. < {
  1906. < local cur prev
  1907. <
  1908. < COMPREPLY=()
  1909. < cur=`_get_cword`
  1910. < prev=${COMP_WORDS[COMP_CWORD-1]}
  1911. <
  1912. < case "$prev" in
  1913. < roam)
  1914. < COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
  1915. < return 0
  1916. < ;;
  1917. < port)
  1918. < COMPREPLY=( $( compgen -W 'ad-hoc managed' -- $cur ) )
  1919. < return 0
  1920. < ;;
  1921. < esac
  1922. <
  1923. < if [ $COMP_CWORD -eq 1 ]; then
  1924. < if [[ "$cur" == -* ]]; then
  1925. < COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
  1926. < else
  1927. < _available_interfaces -w
  1928. < fi
  1929. < else
  1930. < COMPREPLY=( $( compgen -W '--all roam port' -- $cur ) )
  1931. < fi
  1932. < } &&
  1933. < complete -F _iwpriv iwpriv
  1934. <
  1935. < # RedHat & Debian GNU/Linux if{up,down} completion
  1936. < #
  1937. < [ $UNAME = Linux ] && { have ifup || have ifdown; } &&
  1938. < _ifupdown()
  1939. < {
  1940. < local cur
  1941. <
  1942. < COMPREPLY=()
  1943. < cur=`_get_cword`
  1944. <
  1945. < if [ $COMP_CWORD -eq 1 ]; then
  1946. < _configured_interfaces
  1947. < COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") )
  1948. < fi
  1949. <
  1950. < return 0
  1951. < } &&
  1952. < complete -F _ifupdown ifup ifdown
  1953. < [ $UNAME = Linux ] && have ifstatus && complete -F _ifupdown ifstatus
  1954. <
  1955. < # Linux ipsec(8) completion (for FreeS/WAN)
  1956. < #
  1957. < [ $UNAME = Linux ] && have ipsec &&
  1958. < _ipsec()
  1959. < {
  1960. < local cur
  1961. <
  1962. < COMPREPLY=()
  1963. < cur=`_get_cword`
  1964. <
  1965. <
  1966. < if [ $COMP_CWORD -eq 1 ]; then
  1967. < COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look \
  1968. < manual pluto ranbits rsasigkey \
  1969. < setup showdefaults showhostkey spi \
  1970. < spigrp tncfg whack' -- $cur ) )
  1971. < return 0
  1972. < fi
  1973. <
  1974. < case ${COMP_WORDS[1]} in
  1975. < auto)
  1976. < COMPREPLY=( $( compgen -W '--asynchronous --up --add --delete \
  1977. < --replace --down --route --unroute \
  1978. < --ready --status --rereadsecrets' \
  1979. < -- $cur ) )
  1980. < ;;
  1981. < manual)
  1982. < COMPREPLY=( $( compgen -W '--up --down --route --unroute \
  1983. < --union' -- $cur ) )
  1984. < ;;
  1985. < ranbits)
  1986. < COMPREPLY=( $( compgen -W '--quick --continuous --bytes' \
  1987. < -- $cur ) )
  1988. < ;;
  1989. < setup)
  1990. < COMPREPLY=( $( compgen -W '--start --stop --restart' -- $cur ) )
  1991. < ;;
  1992. <
  1993. < *)
  1994. < ;;
  1995. < esac
  1996. <
  1997. < return 0
  1998. < } &&
  1999. < complete -F _ipsec ipsec
  2000. <
  2001. < # Postfix completion.
  2002. < #
  2003. < have postfix && {
  2004. < # postfix(1)
  2005. < #
  2006. < _postfix()
  2007. < {
  2008. < local cur prev
  2009. <
  2010. < cur=`_get_cword`
  2011. < prev=${COMP_WORDS[COMP_CWORD-1]}
  2012. <
  2013. < if [[ $cur == '-' ]]; then
  2014. < COMPREPLY=(-c -D -v)
  2015. < return 0
  2016. < fi
  2017. < if [[ $prev == '-c' ]]; then
  2018. < _filedir -d
  2019. < return 0
  2020. < fi
  2021. < if [[ $prev == '-D' ]]; then
  2022. < COMPREPLY=( $( compgen -W 'start' -- "`get_cword`" ) )
  2023. < return 0
  2024. < fi
  2025. < COMPREPLY=( $( compgen -W 'start stop reload abort flush check' -- \
  2026. < "`get_cword`" ) )
  2027. < }
  2028. < complete -F _postfix postfix
  2029. <
  2030. < # postalias(1) and postmap(1)
  2031. < #
  2032. < _postmap()
  2033. < {
  2034. < local cur prev len idx
  2035. <
  2036. < cur=`_get_cword`
  2037. < prev=${COMP_WORDS[COMP_CWORD-1]}
  2038. <
  2039. < if [[ $cur == '-' ]]; then
  2040. < COMPREPLY=(-N -f -i -n -o -p -r -v -w -c -d -q)
  2041. < return 0
  2042. < fi
  2043. < if [[ $prev == '-c' ]]; then
  2044. < _filedir -d
  2045. < return 0
  2046. < fi
  2047. < if [[ $prev == -[dq] ]]; then
  2048. < return 0
  2049. < fi
  2050. <
  2051. < if [[ "$cur" == *:* ]]; then
  2052. < COMPREPLY=( $( compgen -f -- ${cur#*:} ) )
  2053. < else
  2054. < len=${#cur}
  2055. < idx=0
  2056. < for pval in $( /usr/sbin/postconf -m ); do
  2057. < if [[ "$cur" == "${pval:0:$len}" ]]; then
  2058. < COMPREPLY[$idx]="$pval:"
  2059. < idx=$(($idx+1))
  2060. < fi
  2061. < done
  2062. < if [[ $idx -eq 0 ]]; then
  2063. < COMPREPLY=( $( compgen -f -- "$cur" ) )
  2064. < fi
  2065. < fi
  2066. < return 0
  2067. < }
  2068. < complete -F _postmap postmap postalias
  2069. <
  2070. < # postcat(1)
  2071. < #
  2072. < _postcat()
  2073. < {
  2074. < local cur prev pval len idx qfile
  2075. <
  2076. < cur=`_get_cword`
  2077. < prev=${COMP_WORDS[COMP_CWORD-1]}
  2078. <
  2079. < if [[ $cur == '-' ]]; then
  2080. < COMPREPLY=(-c -q -v)
  2081. < return 0
  2082. < fi
  2083. < if [[ $prev == '-c' ]]; then
  2084. < _filedir -d
  2085. < return 0
  2086. < fi
  2087. <
  2088. < qfile=0
  2089. < for idx in ${COMP_WORDS[@]}; do
  2090. < [[ "$idx" = -q ]] && qfile=1 && break
  2091. < done
  2092. < if [[ $qfile == 1 ]]; then
  2093. < len=${#cur}
  2094. < idx=0
  2095. < for pval in $( mailq | \
  2096. < sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
  2097. < if [[ "$cur" == "${pval:0:$len}" ]]; then
  2098. < COMPREPLY[$idx]=$pval
  2099. < idx=$(($idx+1))
  2100. < fi
  2101. < done
  2102. < return 0
  2103. < else
  2104. < _filedir
  2105. < return 0
  2106. < fi
  2107. < }
  2108. < complete -F _postcat postcat
  2109. <
  2110. < # postconf(1)
  2111. < #
  2112. < _postconf()
  2113. < {
  2114. < local cur prev pval len idx eqext
  2115. <
  2116. < cur=`_get_cword`
  2117. < prev=${COMP_WORDS[COMP_CWORD-1]}
  2118. < if [[ $cur == '-' ]]; then
  2119. < COMPREPLY=(-c -d -e -h -m -l -n -v)
  2120. < return 0
  2121. < fi
  2122. < if [[ $prev == '-c' ]]; then
  2123. < _filedir -d
  2124. < return 0
  2125. < fi
  2126. < if [[ $prev == '-e' ]]; then
  2127. < cur=${cur#[\"\']}
  2128. < eqext='='
  2129. < fi
  2130. < len=${#cur}
  2131. < idx=0
  2132. < for pval in $( /usr/sbin/postconf | cut -d ' ' -f 1 ); do
  2133. < if [[ "$cur" == "${pval:0:$len}" ]]; then
  2134. < COMPREPLY[$idx]="$pval$eqext"
  2135. < idx=$(($idx+1))
  2136. < fi
  2137. < done
  2138. < return 0
  2139. < }
  2140. < complete -F _postconf postconf
  2141. <
  2142. < # postsuper(1)
  2143. < #
  2144. < _postsuper()
  2145. < {
  2146. < local cur prev pval len idx
  2147. <
  2148. < cur=`_get_cword`
  2149. < prev=${COMP_WORDS[COMP_CWORD-1]}
  2150. <
  2151. < if [[ $cur == '-' ]]; then
  2152. < COMPREPLY=(-c -d -h -H -p -r -s -v)
  2153. < return 0
  2154. < fi
  2155. < case $prev in
  2156. < -[dr])
  2157. < len=${#cur}
  2158. < idx=0
  2159. < for pval in $( echo ALL; mailq | \
  2160. < sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
  2161. < if [[ "$cur" == "${pval:0:$len}" ]]; then
  2162. < COMPREPLY[$idx]=$pval
  2163. < idx=$(($idx+1))
  2164. < fi
  2165. < done
  2166. < return 0
  2167. < ;;
  2168. < -h)
  2169. < len=${#cur}
  2170. < idx=0
  2171. < for pval in $( echo ALL; mailq | \
  2172. < sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//; /!$/d' ); do
  2173. < if [[ "$cur" == "${pval:0:$len}" ]]; then
  2174. < COMPREPLY[$idx]=$pval
  2175. < idx=$(($idx+1))
  2176. < fi
  2177. < done
  2178. < return 0
  2179. < ;;
  2180. < -H)
  2181. < len=${#cur}
  2182. < idx=0
  2183. < for pval in $( echo ALL; mailq | \
  2184. < sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do
  2185. < if [[ "$cur" == "${pval:0:$len}" ]]; then
  2186. < COMPREPLY[$idx]=$pval
  2187. < idx=$(($idx+1))
  2188. < fi
  2189. < done
  2190. < return 0
  2191. < ;;
  2192. < esac
  2193. < COMPREPLY=( $( compgen -W 'hold incoming active deferred' -- $cur ) )
  2194. < return 0
  2195. < }
  2196. < complete -F _postsuper postsuper
  2197. < }
  2198. <
  2199. < # cvs(1) completion
  2200. < #
  2201. < have cvs && {
  2202. < set_prefix()
  2203. < {
  2204. < [ -z ${prefix:-} ] || prefix=${cur%/*}/
  2205. < [ -r ${prefix:-}CVS/Entries ] || prefix=""
  2206. < }
  2207. <
  2208. < get_entries()
  2209. < {
  2210. < local IFS=$'\n'
  2211. < [ -r ${prefix:-}CVS/Entries ] && \
  2212. < entries=$(cut -d/ -f2 -s ${prefix:-}CVS/Entries)
  2213. < }
  2214. <
  2215. < get_modules()
  2216. < {
  2217. < if [ -n "$prefix" ]; then
  2218. < COMPREPLY=( $( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ) )
  2219. < else
  2220. < COMPREPLY=( $( command ls -d ${cvsroot}/!(CVSROOT) ) )
  2221. < fi
  2222. < }
  2223. <
  2224. < _cvs()
  2225. < {
  2226. < local cur count mode i cvsroot cvsroots pwd
  2227. < local -a flags miss files entries changed newremoved
  2228. <
  2229. < COMPREPLY=()
  2230. < cur=`_get_cword`
  2231. <
  2232. < count=0
  2233. < for i in ${COMP_WORDS[@]}; do
  2234. < [ $count -eq $COMP_CWORD ] && break
  2235. < # Last parameter was the CVSROOT, now go back to mode selection
  2236. < if [ "${COMP_WORDS[((count))]}" == "$cvsroot" -a "$mode" == "cvsroot" ]; then
  2237. < mode=""
  2238. < fi
  2239. < if [ -z "$mode" ]; then
  2240. < case $i in
  2241. < -d)
  2242. < mode=cvsroot
  2243. < cvsroot=${COMP_WORDS[((count+1))]}
  2244. < ;;
  2245. < @(ad?(d)|new))
  2246. < mode=add
  2247. < ;;
  2248. < @(adm?(in)|rcs))
  2249. < mode=admin
  2250. < ;;
  2251. < ann?(notate))
  2252. < mode=annotate
  2253. < ;;
  2254. < @(checkout|co|get))
  2255. < mode=checkout
  2256. < ;;
  2257. < @(com?(mit)|ci))
  2258. < mode=commit
  2259. < ;;
  2260. < di?(f?(f)))
  2261. < mode=diff
  2262. < ;;
  2263. < ex?(p?(ort)))
  2264. < mode=export
  2265. < ;;
  2266. < ?(un)edit)
  2267. < mode=$i
  2268. < ;;
  2269. < hi?(s?(tory)))
  2270. < mode=history
  2271. < ;;
  2272. < im?(p?(ort)))
  2273. < mode=import
  2274. < ;;
  2275. < re?(l?(ease)))
  2276. < mode=release
  2277. < ;;
  2278. < ?(r)log)
  2279. < mode=log
  2280. < ;;
  2281. < @(rdiff|patch))
  2282. < mode=rdiff
  2283. < ;;
  2284. < @(remove|rm|delete))
  2285. < mode=remove
  2286. < ;;
  2287. < @(rtag|rfreeze))
  2288. < mode=rtag
  2289. < ;;
  2290. < st?(at?(us)))
  2291. < mode=status
  2292. < ;;
  2293. < @(tag|freeze))
  2294. < mode=tag
  2295. < ;;
  2296. < up?(d?(ate)))
  2297. < mode=update
  2298. < ;;
  2299. < *)
  2300. < ;;
  2301. < esac
  2302. < elif [[ "$i" = -* ]]; then
  2303. < flags=( ${flags[@]:-} $i )
  2304. < fi
  2305. < count=$((++count))
  2306. < done
  2307. <
  2308. < case "$mode" in
  2309. < add)
  2310. < if [[ "$cur" != -* ]]; then
  2311. < set_prefix
  2312. < if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
  2313. < get_entries
  2314. < [ -z "$cur" ] && \
  2315. < files=$( command ls -Ad !(CVS) ) || \
  2316. < files=$( command ls -d ${cur}* 2>/dev/null )
  2317. < for i in ${entries[@]:-}; do
  2318. < files=( ${files[@]/#$i//} )
  2319. < done
  2320. < COMPREPLY=( $( compgen -W '${files[@]}' -- \
  2321. < $cur ) )
  2322. < fi
  2323. < else
  2324. < COMPREPLY=( $( compgen -W '-k -m' -- $cur ) )
  2325. < fi
  2326. < ;;
  2327. < admin)
  2328. < if [[ "$cur" = -* ]]; then
  2329. < COMPREPLY=( $( compgen -W '-i -a -A -e -b -c -k -l -u \
  2330. < -L -U -m -M -n -N -o -q -I \
  2331. < -s -t -t- -T -V -x -z' -- \
  2332. < $cur ) )
  2333. < fi
  2334. < ;;
  2335. < annotate)
  2336. < if [[ "$cur" = -* ]]; then
  2337. < COMPREPLY=( $( compgen -W '-D -F -f -l -R -r' -- $cur ) )
  2338. < else
  2339. < get_entries
  2340. < COMPREPLY=( $( compgen -W '${entries[@]}' -- $cur ) )
  2341. < fi
  2342. < ;;
  2343. < checkout)
  2344. < if [[ "$cur" != -* ]]; then
  2345. < [ -z "$cvsroot" ] && cvsroot=$CVSROOT
  2346. < COMPREPLY=( $( cvs -d "$cvsroot" co -c 2> /dev/null | \
  2347. < awk '{print $1}' ) )
  2348. < COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
  2349. < else
  2350. < COMPREPLY=( $( compgen -W '-A -N -P -R -c -f -l -n -p \
  2351. < -s -r -D -d -k -j' -- $cur ) )
  2352. < fi
  2353. < ;;
  2354. < commit)
  2355. < set_prefix
  2356. <
  2357. < if [[ "$cur" != -* ]] && [ -r ${prefix:-}CVS/Entries ]; then
  2358. < # if $COMP_CVS_REMOTE is not null, 'cvs commit' will
  2359. < # complete on remotely checked-out files (requires
  2360. < # passwordless access to the remote repository
  2361. < if [ -n "${COMP_CVS_REMOTE:-}" ]; then
  2362. < # this is the least computationally intensive
  2363. < # way found so far, but other changes
  2364. < # (something other than changed/removed/new)
  2365. < # may be missing
  2366. < changed=( $( cvs -q diff --brief 2>&1 | \
  2367. < sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ) )
  2368. < newremoved=( $( cvs -q diff --brief 2>&1 | \
  2369. < sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ) )
  2370. < COMPREPLY=( $( compgen -W '${changed[@]:-} \
  2371. < ${newremoved[@]:-}' -- $cur ) )
  2372. < else
  2373. < _filedir
  2374. < fi
  2375. < else
  2376. < COMPREPLY=( $( compgen -W '-n -R -l -f -F -m -r' -- \
  2377. < $cur ) )
  2378. < fi
  2379. < ;;
  2380. < cvsroot)
  2381. < if [ -r ~/.cvspass ]; then
  2382. < # Ugly escaping because of bash treating ':' specially
  2383. < cvsroots=$( sed 's/^[^ ]* //; s/:/\\:/g' ~/.cvspass )
  2384. < COMPREPLY=( $( compgen -W '$cvsroots' -- $cur ) )
  2385. < fi
  2386. < ;;
  2387. < export)
  2388. < if [[ "$cur" != -* ]]; then
  2389. < [ -z "$cvsroot" ] && cvsroot=$CVSROOT
  2390. < COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) )
  2391. < COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
  2392. < else
  2393. < COMPREPLY=( $( compgen -W '-N -f -l -R -n \
  2394. < -r -D -d -k' -- $cur ) )
  2395. < fi
  2396. < ;;
  2397. < diff)
  2398. < if [[ "$cur" == -* ]]; then
  2399. < _longopt diff
  2400. < else
  2401. < get_entries
  2402. < COMPREPLY=( $( compgen -W '${entries[@]:-}' -- $cur ) )
  2403. < fi
  2404. < ;;
  2405. < remove)
  2406. < if [[ "$cur" != -* ]]; then
  2407. < set_prefix
  2408. < if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
  2409. < get_entries
  2410. < # find out what files are missing
  2411. < for i in ${entries[@]}; do
  2412. < [ ! -r "$i" ] && miss=( ${miss[@]:-} $i )
  2413. < done
  2414. < COMPREPLY=( $(compgen -W '${miss[@]:-}' -- $cur) )
  2415. < fi
  2416. < else
  2417. < COMPREPLY=( $( compgen -W '-f -l -R' -- $cur ) )
  2418. < fi
  2419. < ;;
  2420. < import)
  2421. < if [[ "$cur" != -* ]]; then
  2422. < # starts with same algorithm as checkout
  2423. < [ -z "$cvsroot" ] && cvsroot=$CVSROOT
  2424. < prefix=${cur%/*}
  2425. < if [ -r ${cvsroot}/${prefix} ]; then
  2426. < get_modules
  2427. < COMPREPLY=( ${COMPREPLY[@]#$cvsroot} )
  2428. < COMPREPLY=( ${COMPREPLY[@]#\/} )
  2429. < fi
  2430. < pwd=$( pwd )
  2431. < pwd=${pwd##*/}
  2432. < COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' -- \
  2433. < $cur ) )
  2434. < else
  2435. < COMPREPLY=( $( compgen -W '-d -k -I -b -m -W' -- $cur ))
  2436. < fi
  2437. < ;;
  2438. < update)
  2439. < if [[ "$cur" = -* ]]; then
  2440. < COMPREPLY=( $( compgen -W '-A -P -C -d -f -l -R -p \
  2441. < -k -r -D -j -I -W' -- \
  2442. < $cur ) )
  2443. < fi
  2444. < ;;
  2445. < "")
  2446. < COMPREPLY=( $( compgen -W 'add admin annotate checkout ci co \
  2447. < commit diff delete edit export \
  2448. < freeze get history import log new \
  2449. < patch rcs rdiff release remove \
  2450. < rfreeze rlog rm rtag stat status \
  2451. < tag unedit up update -H -Q -q -b \
  2452. < -d -e -f -l -n -t -r -v -w -x -z \
  2453. < --help --version' -- $cur ) )
  2454. < ;;
  2455. < *)
  2456. < ;;
  2457. < esac
  2458. <
  2459. < return 0
  2460. < }
  2461. < complete -F _cvs $default cvs
  2462. < }
  2463. <
  2464. < have rpm && {
  2465. < # helper functions for rpm completion
  2466. < #
  2467. < _rpm_installed_packages()
  2468. < {
  2469. < local ver nodig nosig
  2470. <
  2471. < if [ -r /var/log/rpmpkgs -a \
  2472. < /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]; then
  2473. < # using RHL 7.2 or later - this is quicker than querying the DB
  2474. < COMPREPLY=( $( sed -ne \
  2475. < 's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+.*\.rpm$|\1|p' \
  2476. < /var/log/rpmpkgs ) )
  2477. < else
  2478. < nodig=""
  2479. < nosig=""
  2480. < ver=$(rpm --version)
  2481. < ver=${ver##* }
  2482. <
  2483. < if [[ "$ver" > "4.0.4" ]]; then
  2484. < nodig="--nodigest"
  2485. < fi
  2486. < if [[ "$ver" > "4.0.99" ]]; then
  2487. < nosig="--nosignature"
  2488. < fi
  2489. <
  2490. < COMPREPLY=( $( rpm -qa $nodig $nosig | sed -ne \
  2491. < 's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+$|\1|p' ) )
  2492. < fi
  2493. < }
  2494. <
  2495. < _rpm_groups()
  2496. < {
  2497. < local IFS=$'\t'
  2498. < # remove trailing backslash, or grep will complain
  2499. < cur=${cur%"\\"}
  2500. < COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat '%{group}\n' | \
  2501. < grep "^$cur" ) )
  2502. < # backslash escape spaces and translate newlines to tabs
  2503. < COMPREPLY=( $( echo ${COMPREPLY[@]} | sed 's/ /\\ /g' | tr '\n' '\t' ) )
  2504. < }
  2505. <
  2506. < # rpm(8) completion
  2507. < #
  2508. < _rpm()
  2509. < {
  2510. < local cur prev ver nodig nosig
  2511. <
  2512. < COMPREPLY=()
  2513. < cur=`_get_cword`
  2514. < prev=${COMP_WORDS[COMP_CWORD-1]}
  2515. < nodig=""
  2516. < nosig=""
  2517. < ver=$(rpm --version); ver=${ver##* }
  2518. <
  2519. < if [[ "$ver" > "4.0.4" ]]; then
  2520. < nodig="--nodigest"
  2521. < fi
  2522. < if [[ "$ver" > "4.0.99" ]]; then
  2523. < nosig="--nosignature"
  2524. < fi
  2525. <
  2526. < if [ $COMP_CWORD -eq 1 ]; then
  2527. < # first parameter on line
  2528. < case "$cur" in
  2529. < -b*)
  2530. < COMPREPLY=( $( compgen -W '-ba -bb -bc -bi -bl -bp -bs'\
  2531. < -- $cur ) )
  2532. < ;;
  2533. < -t*)
  2534. < COMPREPLY=( $( compgen -W '-ta -tb -tc -ti -tl -tp -ts'\
  2535. < -- $cur ) )
  2536. < ;;
  2537. < --*)
  2538. < COMPREPLY=( $( compgen -W '--help --version --initdb \
  2539. < --checksig --recompile --rebuild --resign --addsign \
  2540. < --rebuilddb --showrc --setperms --setugids --tarbuild \
  2541. < --eval --install --upgrade --query --freshen --erase \
  2542. < --verify --querytags --rmsource --rmspec --clean \
  2543. < --import' -- $cur ) )
  2544. < ;;
  2545. < *)
  2546. < COMPREPLY=( $( compgen -W '-b -e -F -i -q -t -U -V' \
  2547. < -- $cur ) )
  2548. < ;;
  2549. < esac
  2550. <
  2551. < return 0
  2552. < fi
  2553. <
  2554. < case "$prev" in
  2555. < --@(@(db|exclude)path|prefix|relocate|root))
  2556. < _filedir -d
  2557. < return 0
  2558. < ;;
  2559. < --eval)
  2560. < # get a list of macros
  2561. < COMPREPLY=( $( sed -ne 's|^\(%'${cur#\%}'[^ '$'\t'']*\).*$|\1|p' \
  2562. < /usr/lib/rpm/macros ) )
  2563. < return 0
  2564. < ;;
  2565. < --pipe)
  2566. < COMPREPLY=( $( compgen -c -- $cur ) )
  2567. < return 0
  2568. < ;;
  2569. < --rcfile)
  2570. < _filedir
  2571. < return 0
  2572. < ;;
  2573. < --specfile)
  2574. < # complete on .spec files
  2575. < _filedir spec
  2576. < return 0
  2577. < ;;
  2578. < --whatprovides)
  2579. < if [[ "$cur" == */* ]]; then
  2580. < _filedir
  2581. < else
  2582. < # complete on capabilities
  2583. < COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat \
  2584. < '%{providename}\n' | grep "^$cur" ) )
  2585. < fi
  2586. < return 0
  2587. < ;;
  2588. < --whatrequires)
  2589. < # complete on capabilities
  2590. < COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat \
  2591. < '%{requirename}\n' | grep "^$cur" ) )
  2592. < return 0
  2593. < ;;
  2594. < esac
  2595. <
  2596. < case "${COMP_WORDS[1]}" in
  2597. < -@([iFU]*|-install|-freshen|-upgrade))
  2598. < if [[ "$cur" == -* ]]; then
  2599. < COMPREPLY=( $( compgen -W '--percent --force --test \
  2600. < --replacepkgs --replacefiles --root --excludedocs \
  2601. < --includedocs --noscripts --rcfile --ignorearch \
  2602. < --dbpath --prefix --ignoreos --nodeps --allfiles \
  2603. < --ftpproxy --ftpport --justdb --httpproxy --httpport \
  2604. < --noorder --relocate --badreloc --notriggers \
  2605. < --excludepath --ignoresize --oldpackage --define \
  2606. < --eval --pipe --queryformat --repackage --nosuggests \
  2607. < --nodigest --nosignature' -- $cur ) )
  2608. < else
  2609. < _filedir 'rpm'
  2610. < fi
  2611. < ;;
  2612. < -@(e|-erase))
  2613. < if [[ "$cur" == -* ]]; then
  2614. < COMPREPLY=( $( compgen -W '--allmatches --noscripts \
  2615. < --notriggers --nodeps --test --repackage' -- $cur ) )
  2616. < else
  2617. < _rpm_installed_packages
  2618. < fi
  2619. < ;;
  2620. < -@(q*|-query))
  2621. < # check whether we're doing file completion
  2622. < if [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
  2623. < if [[ "$cur" == -* ]]; then
  2624. < COMPREPLY=( $( compgen -W '--scripts --root \
  2625. < --rcfile --requires --ftpport --ftpproxy \
  2626. < --httpproxy --httpport --provides --triggers \
  2627. < --dump --changelog --dbpath \
  2628. < --last --filesbypkg \
  2629. < --info --list --state \
  2630. < --docfiles --configfiles --queryformat \
  2631. < --conflicts --obsoletes \
  2632. < --nodigest --nosignature \
  2633. < --triggerscripts' -- $cur ) )
  2634. < else
  2635. < _filedir
  2636. < fi
  2637. < elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
  2638. < _rpm_groups
  2639. < elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
  2640. < # uninstalled package completion
  2641. < if [[ "$cur" == -* ]]; then
  2642. < COMPREPLY=( $( compgen -W '--scripts --root \
  2643. < --rcfile --whatprovides --whatrequires \
  2644. < --requires --triggeredby --ftpport --ftpproxy \
  2645. < --httpproxy --httpport --provides --triggers \
  2646. < --dump --changelog --dbpath --filesbypkg \
  2647. < --define --eval --pipe --showrc --info --list \
  2648. < --state --docfiles --configfiles --queryformat\
  2649. < --conflicts --obsoletes --nodigest \
  2650. < --nosignature' -- $cur ) )
  2651. < else
  2652. < _filedir 'rpm'
  2653. < fi
  2654. < else
  2655. < # installed package completion
  2656. < if [[ "$cur" == -* ]]; then
  2657. < COMPREPLY=( $( compgen -W '--scripts --root \
  2658. < --rcfile --whatprovides --whatrequires \
  2659. < --requires --triggeredby --ftpport --ftpproxy \
  2660. < --httpproxy --httpport --provides --triggers \
  2661. < --dump --changelog --dbpath --specfile \
  2662. < --querybynumber --last --filesbypkg --define \
  2663. < --eval --pipe --showrc --info --list --state \
  2664. < --docfiles --configfiles --queryformat \
  2665. < --conflicts --obsoletes --pkgid --hdrid \
  2666. < --fileid --tid --nodigest --nosignature \
  2667. < --triggerscripts' -- $cur ) )
  2668. < elif [ "${COMP_LINE#* -*([^ -])a}" == "$COMP_LINE" ]; then
  2669. < _rpm_installed_packages
  2670. < fi
  2671. < fi
  2672. < ;;
  2673. < -@(K*|-checksig))
  2674. < if [[ "$cur" == -* ]]; then
  2675. < COMPREPLY=( $( compgen -W '--nopgp --nogpg --nomd5 \
  2676. < --nodigest --nosignature' -- $cur ) )
  2677. < else
  2678. < _filedir 'rpm'
  2679. < fi
  2680. < ;;
  2681. < -@([Vy]*|-verify))
  2682. < if [[ "$cur" == -* ]]; then
  2683. < COMPREPLY=( $( compgen -W '--root --rcfile --dbpath \
  2684. < --nodeps --nogroup --nolinkto --nomode --nomtime \
  2685. < --nordev --nouser --nofiles --noscripts --nomd5 \
  2686. < --querytags --specfile --whatrequires --whatprovides \
  2687. < --nodigest --nosignature' -- $cur ) )
  2688. < # check whether we're doing file completion
  2689. < elif [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
  2690. < _filedir
  2691. < elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
  2692. < _rpm_groups
  2693. < elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
  2694. < _filedir 'rpm'
  2695. < else
  2696. < _rpm_installed_packages
  2697. < fi
  2698. < ;;
  2699. < -[bt]*)
  2700. < if [[ "$cur" == -* ]]; then
  2701. < COMPREPLY=( $( compgen -W '--short-circuit --timecheck \
  2702. < --clean --rmsource --rmspec --test --sign --buildroot \
  2703. < --target -- buildarch --buildos --nobuild --nodeps \
  2704. < --nodirtokens' -- $cur ) )
  2705. < elif [[ ${COMP_WORDS[1]} == -b* ]]; then
  2706. < _filedir 'spec'
  2707. < else
  2708. < _filedir '@(tgz|tar.@(gz|bz2))'
  2709. < fi
  2710. < ;;
  2711. < --re@(build|compile))
  2712. < if [[ "$cur" == -* ]]; then
  2713. < COMPREPLY=( $( compgen -W '--nodeps --rmsource \
  2714. < --rmspec --sign --nodirtokens --target' -- $cur ) )
  2715. < else
  2716. < _filedir '?(no)src.rpm'
  2717. < fi
  2718. < ;;
  2719. < --tarbuild)
  2720. < _filedir '@(tgz|tar.@(gz|bz2))'
  2721. < ;;
  2722. < --@(re|add)sign)
  2723. < _filedir 'rpm'
  2724. < ;;
  2725. < --set@(perms|gids))
  2726. < _rpm_installed_packages
  2727. < ;;
  2728. < --@(clean|rms@(ource|pec)))
  2729. < if [[ "$cur" == -* ]]; then
  2730. < COMPREPLY=( $( compgen -W '--clean --rmsource \
  2731. < --rmspec' -- $cur ) )
  2732. < else
  2733. < _filedir 'spec'
  2734. < fi
  2735. < ;;
  2736. < --@(import|dbpath|root))
  2737. < if [[ "$cur" == -* ]]; then
  2738. < COMPREPLY=( $( compgen -W '--import --dbpath --root' \
  2739. < -- $cur ) )
  2740. < else
  2741. < _filedir
  2742. < fi
  2743. < ;;
  2744. < esac
  2745. <
  2746. < return 0
  2747. < }
  2748. < complete -F _rpm $filenames rpm rpmbuild
  2749. < }
  2750. <
  2751. < # Debian apt-get(8) completion.
  2752. < #
  2753. < have apt-get &&
  2754. < _apt_get()
  2755. < {
  2756. < local cur prev special i
  2757. <
  2758. < COMPREPLY=()
  2759. < cur=`_get_cword`
  2760. < prev=${COMP_WORDS[COMP_CWORD-1]}
  2761. <
  2762. < for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
  2763. < if [[ ${COMP_WORDS[i]} == @(install|remove|purge|source|build-dep) ]]; then
  2764. < special=${COMP_WORDS[i]}
  2765. < fi
  2766. < done
  2767. <
  2768. < if [ -n "$special" ]; then
  2769. < case $special in
  2770. < remove|purge)
  2771. < if [ -f /etc/debian_version ]; then
  2772. < # Debian system
  2773. < COMPREPLY=( $( _comp_dpkg_installed_packages \
  2774. < $cur ) )
  2775. < else
  2776. < # assume RPM based
  2777. < _rpm_installed_packages
  2778. < fi
  2779. < return 0
  2780. < ;;
  2781. < *)
  2782. < COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
  2783. < return 0
  2784. < ;;
  2785. <
  2786. < esac
  2787. < fi
  2788. <
  2789. < case "$prev" in
  2790. < -@(c|-config-file))
  2791. < _filedir
  2792. < return 0
  2793. < ;;
  2794. <
  2795. < -@(t|-target-release|-default-release))
  2796. < COMPREPLY=( $( apt-cache policy | \
  2797. < grep "release.o=Debian,a=$cur" | \
  2798. < sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) )
  2799. < return 0
  2800. < ;;
  2801. <
  2802. < esac
  2803. <
  2804. < if [[ "$cur" == -* ]]; then
  2805. <
  2806. < COMPREPLY=( $( compgen -W '-d -f -h -v -m -q -s -y \
  2807. < -u -t -b -c -o --download-only --fix-broken \
  2808. < --help --version --ignore-missing \
  2809. < --fix-missing --no-download --quiet --simulate \
  2810. < --just-print --dry-run --recon --no-act --yes \
  2811. < --assume-yes --show-upgraded --only-source \
  2812. < --compile --build --ignore-hold \
  2813. < --target-release --no-upgrade --force-yes \
  2814. < --print-uris --purge --reinstall \
  2815. < --list-cleanup --default-release \
  2816. < --trivial-only --no-remove --diff-only \
  2817. < --tar-only --config-file --option --auto-remove' -- $cur ) )
  2818. < else
  2819. <
  2820. < COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \
  2821. < dist-upgrade install remove purge source \
  2822. < build-dep check clean autoclean autoremove' \
  2823. < -- $cur ) )
  2824. <
  2825. < fi
  2826. <
  2827. <
  2828. < return 0
  2829. < } &&
  2830. < complete -F _apt_get $filenames apt-get
  2831. <
  2832. < # Debian apt-cache(8) completion.
  2833. < #
  2834. < have apt-cache &&
  2835. < _apt_cache()
  2836. < {
  2837. < local cur prev special i
  2838. <
  2839. < COMPREPLY=()
  2840. < cur=`_get_cword`
  2841. < prev=${COMP_WORDS[COMP_CWORD-1]}
  2842. <
  2843. <
  2844. < if [ "$cur" != show ]; then
  2845. < for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
  2846. < if [[ ${COMP_WORDS[i]} == @(add|depends|dotty|policy|rdepends|madison|show?(pkg|src|)) ]]; then
  2847. < special=${COMP_WORDS[i]}
  2848. < fi
  2849. < done
  2850. < fi
  2851. <
  2852. <
  2853. < if [ -n "$special" ]; then
  2854. < case $special in
  2855. < add)
  2856. < _filedir
  2857. < return 0
  2858. < ;;
  2859. <
  2860. < *)
  2861. < COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
  2862. < return 0
  2863. < ;;
  2864. <
  2865. < esac
  2866. < fi
  2867. <
  2868. <
  2869. < case "$prev" in
  2870. < -@(c|p|s|-config-file|-@(pkg|src)-cache))
  2871. < _filedir
  2872. < return 0
  2873. < ;;
  2874. < search)
  2875. < if [[ "$cur" != -* ]]; then
  2876. < return 0
  2877. < fi
  2878. < ;;
  2879. < esac
  2880. <
  2881. < if [[ "$cur" == -* ]]; then
  2882. <
  2883. < COMPREPLY=( $( compgen -W '-h -v -p -s -q -i -f -a -g -c \
  2884. < -o --help --version --pkg-cache --src-cache \
  2885. < --quiet --important --full --all-versions \
  2886. < --no-all-versions --generate --no-generate \
  2887. < --names-only --all-names --recurse \
  2888. < --config-file --option' -- $cur ) )
  2889. < else
  2890. <
  2891. < COMPREPLY=( $( compgen -W 'add gencaches show showpkg showsrc \
  2892. < stats dump dumpavail unmet search search \
  2893. < depends rdepends pkgnames dotty xvcg \
  2894. < policy madison' -- $cur ) )
  2895. <
  2896. < fi
  2897. <
  2898. <
  2899. < return 0
  2900. < } &&
  2901. < complete -F _apt_cache $filenames apt-cache
  2902. <
  2903. <
  2904. < # Debian aptitude(1) completion
  2905. < #
  2906. < have aptitude && {
  2907. < have grep-status && {
  2908. < _comp_dpkg_hold_packages()
  2909. < {
  2910. < grep-status -P -e "^$1" -a -FStatus 'hold' -n -s Package
  2911. < }
  2912. < } || {
  2913. < _comp_dpkg_hold_packages()
  2914. < {
  2915. < grep -B 2 'hold' /var/lib/dpkg/status | grep "Package: $1" \
  2916. < | cut -d\ -f2
  2917. < }
  2918. < }
  2919. <
  2920. < _aptitude()
  2921. < {
  2922. < local cur dashoptions prev special i
  2923. <
  2924. < COMPREPLY=()
  2925. < cur=`_get_cword`
  2926. < prev=${COMP_WORDS[COMP_CWORD-1]}
  2927. <
  2928. <
  2929. < dashoptions='-S -u -i -h --help --version -s --simulate -d \
  2930. < --download-only -P --prompt -y --assume-yes -F \
  2931. < --display-format -O --sort -w --width -f -r -g \
  2932. < --with-recommends --with-suggests -R -G \
  2933. < --without-recommends --without-suggests -t \
  2934. < --target-release -V --show-versions -D --show-deps\
  2935. < -Z -v --verbose --purge-unused'
  2936. <
  2937. < for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
  2938. < 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
  2939. < special=${COMP_WORDS[i]}
  2940. < fi
  2941. < #exclude some mutually exclusive options
  2942. < [[ ${COMP_WORDS[i]} == '-u' ]] && dashoptions=${dashoptions/-i}
  2943. < [[ ${COMP_WORDS[i]} == '-i' ]] && dashoptions=${dashoptions/-u}
  2944. < done
  2945. <
  2946. < if [[ -n "$special" ]]; then
  2947. < case $special in
  2948. < @(install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|changelog|why|why-not))
  2949. < COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
  2950. < return 0
  2951. < ;;
  2952. < @(purge|remove|reinstall|forbid-version))
  2953. < COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
  2954. < return 0
  2955. < ;;
  2956. < unhold)
  2957. < COMPREPLY=( $( _comp_dpkg_hold_packages $cur ) )
  2958. < return 0
  2959. < ;;
  2960. <
  2961. < esac
  2962. < fi
  2963. <
  2964. < case $prev in
  2965. < # don't complete anything if these options are found
  2966. < @(autoclean|clean|forget-new|search|upgrade|safe-upgrade|update|keep-all))
  2967. < return 0
  2968. < ;;
  2969. <
  2970. < -S)
  2971. < _filedir
  2972. < return 0
  2973. < ;;
  2974. <
  2975. < -@(t|-target-release|-default-release))
  2976. < COMPREPLY=( $( apt-cache policy | \
  2977. < grep "release.o=Debian,a=$cur" | \
  2978. < sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ) )
  2979. < return 0
  2980. < ;;
  2981. <
  2982. < esac
  2983. <
  2984. < if [[ "$cur" == -* ]]; then
  2985. < COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
  2986. < else
  2987. < COMPREPLY=( $( compgen -W 'update upgrade safe-upgrade forget-new clean \
  2988. < autoclean install reinstall remove \
  2989. < hold unhold purge markauto unmarkauto why why-not \
  2990. < dist-upgrade full-upgrade download search show \
  2991. < forbid-version changelog keep-all' -- $cur ) )
  2992. < fi
  2993. <
  2994. <
  2995. < return 0
  2996. < }
  2997. < complete -F _aptitude $default aptitude
  2998. < }
  2999. <
  3000. < # Debian apt-build(1) completion.
  3001. < #
  3002. < have apt-build &&
  3003. < _apt_build()
  3004. < {
  3005. < local cur prev special i
  3006. <
  3007. < COMPREPLY=()
  3008. < cur=`_get_cword`
  3009. < prev=${COMP_WORDS[COMP_CWORD-1]}
  3010. <
  3011. < for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
  3012. < if [[ ${COMP_WORDS[i]} == @(install|remove|source|info|clean) ]]; then
  3013. < special=${COMP_WORDS[i]}
  3014. < fi
  3015. < done
  3016. <
  3017. < if [ -n "$special" ]; then
  3018. < case $special in
  3019. < @(install|source|info))
  3020. < COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
  3021. < return 0
  3022. < ;;
  3023. < remove)
  3024. < COMPREPLY=( $( _comp_dpkg_installed_packages \
  3025. < $cur ) )
  3026. < return 0
  3027. < ;;
  3028. < *)
  3029. < return 0
  3030. < ;;
  3031. < esac
  3032. < fi
  3033. <
  3034. < case "$prev" in
  3035. <
  3036. < --@(patch|build-dir|repository-dir))
  3037. < _filedir
  3038. < return 0
  3039. < ;;
  3040. <
  3041. < -@(h|-help))
  3042. < return 0
  3043. < ;;
  3044. <
  3045. < esac
  3046. <
  3047. < if [[ "$cur" == -* ]]; then
  3048. < COMPREPLY=( $( compgen -W '--help --show-upgraded -u --build-dir \
  3049. < --repository-dir --build-only \
  3050. < --build-command --reinstall --rebuild \
  3051. < --remove-builddep --no-wrapper --purge \
  3052. < --patch --patch-strip -p --yes -y \
  3053. < --version -v --no-source' -- $cur ) )
  3054. <
  3055. < else
  3056. < COMPREPLY=( $( compgen -W 'update upgrade install remove \
  3057. < source dist-upgrade world clean info \
  3058. < clean-build update-repository ' -- $cur ) )
  3059. < fi
  3060. <
  3061. <
  3062. < return 0
  3063. < } &&
  3064. < complete -F _apt_build $filenames apt-build
  3065. <
  3066. < # chsh(1) completion
  3067. < #
  3068. < _chsh()
  3069. < {
  3070. < local cur prev
  3071. <
  3072. < COMPREPLY=()
  3073. < cur=`_get_cword`
  3074. < prev=${COMP_WORDS[COMP_CWORD-1]}
  3075. <
  3076. < if [ "$prev" = "-s" ]; then
  3077. < if [ -f /etc/debian_version ]; then
  3078. < COMPREPLY=( $( </etc/shells ) )
  3079. < else
  3080. < COMPREPLY=( $( chsh -l | grep "^$cur" ) )
  3081. < fi
  3082. < else
  3083. < COMPREPLY=( $( compgen -u -- $cur ) )
  3084. < fi
  3085. <
  3086. < return 0
  3087. < }
  3088. < complete -F _chsh chsh
  3089. <
  3090. < # chkconfig(8) completion
  3091. < #
  3092. < have chkconfig &&
  3093. < _chkconfig()
  3094. < {
  3095. < local cur prev
  3096. <
  3097. < COMPREPLY=()
  3098. < cur=`_get_cword`
  3099. < prev=${COMP_WORDS[COMP_CWORD-1]}
  3100. <
  3101. < case "$prev" in
  3102. < @([1-6]|--@(list|add|del)))
  3103. < _services
  3104. < return 0
  3105. < ;;
  3106. < --level)
  3107. < COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- $cur ) )
  3108. < return 0
  3109. < ;;
  3110. < esac
  3111. <
  3112. < if [[ "$cur" == -* ]]; then
  3113. < COMPREPLY=( $( compgen -W '--list --add --del --level' -- $cur ) )
  3114. < else
  3115. < if [ $COMP_CWORD -eq 2 -o $COMP_CWORD -eq 4 ]; then
  3116. < COMPREPLY=( $( compgen -W 'on off reset' -- $cur ) )
  3117. < else
  3118. < _services
  3119. < fi
  3120. < fi
  3121. < } &&
  3122. < complete -F _chkconfig chkconfig
  3123. ---
  3124. > # This function completes on valid shells
  3125. > #
  3126. > _shells()
  3127. > {
  3128. > COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
  3129. > '$( command grep "^[[:space:]]*/" /etc/shells 2>/dev/null )' \
  3130. > -- "$cur" ) )
  3131. > }
  3132. 2430c1024
  3133. < # This function provides simple user@host completion
  3134. ---
  3135. > # This function completes on valid filesystem types
  3136. 2432,2433c1026,1028
  3137. < _user_at_host() {
  3138. < local cur
  3139. ---
  3140. > _fstypes()
  3141. > {
  3142. > local fss
  3143. 2435,2436c1030,1041
  3144. < COMPREPLY=()
  3145. < cur=`_get_cword`
  3146. ---
  3147. > if [ -e /proc/filesystems ] ; then
  3148. > # Linux
  3149. > fss="$( cut -d$'\t' -f2 /proc/filesystems )
  3150. > $( awk '! /\*/ { print $NF }' /etc/filesystems 2>/dev/null )"
  3151. > else
  3152. > # Generic
  3153. > fss="$( awk '/^[ \t]*[^#]/ { print $3 }' /etc/fstab 2>/dev/null )
  3154. > $( awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2>/dev/null )
  3155. > $( awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2>/dev/null )
  3156. > $( awk '{ print $1 }' /etc/dfs/fstypes 2>/dev/null )
  3157. > $( [ -d /etc/fs ] && command ls /etc/fs )"
  3158. > fi
  3159. 2438,2442c1043,1045
  3160. < if [[ $cur == *@* ]]; then
  3161. < _known_hosts
  3162. < else
  3163. < COMPREPLY=( $( compgen -u -- "$cur" ) )
  3164. < fi
  3165. ---
  3166. > [ -n "$fss" ] && \
  3167. > COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$fss" -- "$cur" ) )
  3168. > }
  3169. 2444c1047,1078
  3170. < return 0
  3171. ---
  3172. > # Get real command.
  3173. > # - arg: $1 Command
  3174. > # - stdout: Filename of command in PATH with possible symbolic links resolved.
  3175. > # Empty string if command not found.
  3176. > # - return: True (0) if command found, False (> 0) if not.
  3177. > _realcommand()
  3178. > {
  3179. > type -P "$1" > /dev/null && {
  3180. > if type -p realpath > /dev/null; then
  3181. > realpath "$(type -P "$1")"
  3182. > elif type -p readlink > /dev/null; then
  3183. > readlink -f "$(type -P "$1")"
  3184. > else
  3185. > type -P "$1"
  3186. > fi
  3187. > }
  3188. > }
  3189. >
  3190. > # This function returns the first arugment, excluding options
  3191. > # @param $1 chars Characters out of $COMP_WORDBREAKS which should
  3192. > # NOT be considered word breaks. See __reassemble_comp_words_by_ref.
  3193. > _get_first_arg()
  3194. > {
  3195. > local i
  3196. >
  3197. > arg=
  3198. > for (( i=1; i < COMP_CWORD; i++ )); do
  3199. > if [[ "${COMP_WORDS[i]}" != -* ]]; then
  3200. > arg=${COMP_WORDS[i]}
  3201. > break
  3202. > fi
  3203. > done
  3204. 2446d1079
  3205. < shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
  3206. 2448,2454d1080
  3207. < # This function performs host completion based on ssh's known_hosts files,
  3208. < # defaulting to standard host completion if they don't exist.
  3209. < #
  3210. < _known_hosts()
  3211. < {
  3212. < local cur curd ocur user suffix aliases global_kh user_kh hosts i host
  3213. < local -a kh khd config
  3214. 2456,3075c1082,1088
  3215. < COMPREPLY=()
  3216. < cur=`_get_cword`
  3217. < ocur=$cur
  3218. <
  3219. < [ "$1" = -a ] || [ "$2" = -a ] && aliases='yes'
  3220. < [ "$1" = -c ] || [ "$2" = -c ] && suffix=':'
  3221. < [[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}
  3222. < kh=()
  3223. <
  3224. < # ssh config files
  3225. < [ -r /etc/ssh/ssh_config ] &&
  3226. < config=( "${config[@]}" "/etc/ssh/ssh_config" )
  3227. < [ -r "${HOME}/.ssh/config" ] &&
  3228. < config=( "${config[@]}" "${HOME}/.ssh/config" )
  3229. < [ -r "${HOME}/.ssh2/config" ] &&
  3230. < config=( "${config[@]}" "${HOME}/.ssh2/config" )
  3231. <
  3232. < if [ ${#config[@]} -gt 0 ]; then
  3233. < # expand path (if present) to global known hosts file
  3234. < 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[@]}" ) )
  3235. < # expand path (if present) to user known hosts file
  3236. < 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[@]}" ) )
  3237. < fi
  3238. <
  3239. < # choose which global known hosts file to use
  3240. < if [ -r "$global_kh" ]; then
  3241. < kh=( "$global_kh" )
  3242. < else
  3243. < [ -r /etc/ssh/ssh_known_hosts ] &&
  3244. < kh=( ${kh[@]} /etc/ssh/ssh_known_hosts )
  3245. < [ -r /etc/ssh/ssh_known_hosts2 ] &&
  3246. < kh=( ${kh[@]} /etc/ssh/ssh_known_hosts2 )
  3247. < [ -r /etc/known_hosts ] &&
  3248. < kh=( ${kh[@]} /etc/known_hosts )
  3249. < [ -r /etc/known_hosts2 ] &&
  3250. < kh=( ${kh[@]} /etc/known_hosts2 )
  3251. < [ -d /etc/ssh2/knownhosts ] &&
  3252. < khd=( ${khd[@]} /etc/ssh2/knownhosts/*pub )
  3253. < fi
  3254. <
  3255. < # choose which user known hosts file to use
  3256. < if [ -r "$user_kh" ]; then
  3257. < kh=( ${kh[@]} "$user_kh" )
  3258. < else
  3259. < [ -r ~/.ssh/known_hosts ] &&
  3260. < kh=( ${kh[@]} ~/.ssh/known_hosts )
  3261. < [ -r ~/.ssh/known_hosts2 ] &&
  3262. < kh=( ${kh[@]} ~/.ssh/known_hosts2 )
  3263. < [ -d ~/.ssh2/hostkeys ] &&
  3264. < khd=( ${khd[@]} ~/.ssh2/hostkeys/*pub )
  3265. < fi
  3266. <
  3267. < # If we have known_hosts files to use
  3268. < if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 ]; then
  3269. < # Escape slashes and dots in paths for awk
  3270. < cur=${cur//\//\\\/}
  3271. < cur=${cur//\./\\\.}
  3272. < curd=$cur
  3273. <
  3274. < if [[ "$cur" == [0-9]*.* ]]; then
  3275. < # Digits followed by a dot - just search for that
  3276. < cur="^$cur.*"
  3277. < elif [[ "$cur" == [0-9]* ]]; then
  3278. < # Digits followed by no dot - search for digits followed
  3279. < # by a dot
  3280. < cur="^$cur.*\."
  3281. < elif [ -z "$cur" ]; then
  3282. < # A blank - search for a dot or an alpha character
  3283. < cur="[a-z.]"
  3284. < else
  3285. < cur="^$cur"
  3286. < fi
  3287. <
  3288. < if [ ${#kh[@]} -gt 0 ]; then
  3289. <
  3290. < # FS needs to look for a comma separated list
  3291. < COMPREPLY=( $( awk 'BEGIN {FS=","}
  3292. < /^[^|]/ {for (i=1; i<=2; ++i) { \
  3293. < gsub(" .*$", "", $i); \
  3294. < if ($i ~ /'$cur'/) {print $i} \
  3295. < }}' ${kh[@]} 2>/dev/null ) )
  3296. < fi
  3297. < if [ ${#khd[@]} -gt 0 ]; then
  3298. < # Needs to look for files called
  3299. < # .../.ssh2/key_22_<hostname>.pub
  3300. < # dont fork any processes, because in a cluster environment,
  3301. < # there can be hundreds of hostkeys
  3302. < for i in ${khd[@]} ; do
  3303. < if [[ "$i" == *key_22_$curd*.pub ]] && [ -r "$i" ] ; then
  3304. < host=${i/#*key_22_/}
  3305. < host=${host/%.pub/}
  3306. < COMPREPLY=( ${COMPREPLY[@]} $host )
  3307. < fi
  3308. < done
  3309. < fi
  3310. < # append any available aliases from config files
  3311. < if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
  3312. < local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']*\([^*?]*\)$/\2/p' "${config[@]}" )
  3313. < hosts=$( compgen -W "$host_aliases" -- $ocur )
  3314. < COMPREPLY=( ${COMPREPLY[@]} $hosts )
  3315. < fi
  3316. <
  3317. < # Now add results of normal hostname completion
  3318. < COMPREPLY=( ${COMPREPLY[@]} $( compgen -A hostname -- $ocur ) )
  3319. <
  3320. < # apply suffix
  3321. < for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
  3322. < COMPREPLY[i]=$user${COMPREPLY[i]}$suffix
  3323. < done
  3324. < else
  3325. < # Just do normal hostname completion
  3326. < COMPREPLY=( $( compgen -A hostname -S "$suffix" -- $cur ) )
  3327. < fi
  3328. <
  3329. < return 0
  3330. < }
  3331. < complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \
  3332. < ping ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr
  3333. <
  3334. < # ssh(1) completion
  3335. < #
  3336. < have ssh && {
  3337. < _ssh()
  3338. < {
  3339. < local cur prev
  3340. < local -a config
  3341. <
  3342. < COMPREPLY=()
  3343. < cur=`_get_cword`
  3344. < prev=${COMP_WORDS[COMP_CWORD-1]}
  3345. <
  3346. < case "$prev" in
  3347. < -*c)
  3348. < COMPREPLY=( $( compgen -W 'blowfish 3des 3des-cbc blowfish-cbc \
  3349. < arcfour cast128-cbc' -- $cur ) )
  3350. < ;;
  3351. < -*i)
  3352. < _filedir
  3353. < ;;
  3354. < -*l)
  3355. < COMPREPLY=( $( compgen -u -- $cur ) )
  3356. < ;;
  3357. < *)
  3358. < _known_hosts -a
  3359. <
  3360. < [ $COMP_CWORD -eq 1 ] || \
  3361. < COMPREPLY=( ${COMPREPLY[@]} $( compgen -c -- $cur ) )
  3362. < esac
  3363. <
  3364. < return 0
  3365. < }
  3366. < shopt -u hostcomplete && complete -F _ssh ssh slogin sftp xhost autossh
  3367. <
  3368. < # scp(1) completion
  3369. < #
  3370. < _scp()
  3371. < {
  3372. < local cur userhost path
  3373. <
  3374. < COMPREPLY=()
  3375. < cur=`_get_cword ":"`
  3376. <
  3377. < _expand || return 0
  3378. <
  3379. < if [[ "$cur" == *:* ]]; then
  3380. < local IFS=$'\t\n'
  3381. < # remove backslash escape from :
  3382. < cur=${cur/\\:/:}
  3383. < userhost=${cur%%?(\\):*}
  3384. < path=${cur#*:}
  3385. < # unescape spaces
  3386. < path=${path//\\\\\\\\ / }
  3387. < if [ -z "$path" ]; then
  3388. < # default to home dir of specified user on remote host
  3389. < path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
  3390. < fi
  3391. < # escape spaces; remove executables, aliases, pipes and sockets;
  3392. < # add space at end of file names
  3393. < COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
  3394. < command ls -aF1d "$path*" 2>/dev/null | \
  3395. < sed -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\\\\\\\\\&/g" \
  3396. < -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
  3397. < return 0
  3398. < fi
  3399. <
  3400. < [[ "$cur" == */* ]] || _known_hosts -c -a
  3401. < local IFS=$'\t\n'
  3402. < COMPREPLY=( ${COMPREPLY[@]} $( command ls -aF1d $cur* \
  3403. < 2>/dev/null | sed \
  3404. < -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\&/g" \
  3405. < -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
  3406. < return 0
  3407. < }
  3408. < complete -F _scp $nospace scp
  3409. < }
  3410. <
  3411. < # rsync(1) completion
  3412. < #
  3413. < have rsync &&
  3414. < _rsync()
  3415. < {
  3416. < local cur prev shell i userhost path
  3417. <
  3418. < COMPREPLY=()
  3419. < cur=`_get_cword`
  3420. < prev=${COMP_WORDS[COMP_CWORD-1]}
  3421. <
  3422. < _expand || return 0
  3423. <
  3424. < case "$prev" in
  3425. < --@(config|password-file|include-from|exclude-from))
  3426. < _filedir
  3427. < return 0
  3428. < ;;
  3429. < -@(T|-temp-dir|-compare-dest))
  3430. < _filedir -d
  3431. < return 0
  3432. < ;;
  3433. < -@(e|-rsh))
  3434. < COMPREPLY=( $( compgen -W 'rsh ssh' -- $cur ) )
  3435. < return 0
  3436. < ;;
  3437. < esac
  3438. <
  3439. < case "$cur" in
  3440. < -*)
  3441. < COMPREPLY=( $( compgen -W '-v -q -c -a -r -R -b -u -l -L -H \
  3442. < -p -o -g -D -t -S -n -W -x -B -e -C -I -T -P \
  3443. < -z -h -4 -6 --verbose --quiet --checksum \
  3444. < --archive --recursive --relative --backup \
  3445. < --backup-dir --suffix= --update --links \
  3446. < --copy-links --copy-unsafe-links --safe-links \
  3447. < --hard-links --perms --owner --group --devices\
  3448. < --times --sparse --dry-run --whole-file \
  3449. < --no-whole-file --one-file-system \
  3450. < --block-size= --rsh= --rsync-path= \
  3451. < --cvs-exclude --existing --ignore-existing \
  3452. < --delete --delete-excluded --delete-after \
  3453. < --ignore-errors --max-delete= --partial \
  3454. < --force --numeric-ids --timeout= \
  3455. < --ignore-times --size-only --modify-window= \
  3456. < --temp-dir= --compare-dest= --compress \
  3457. < --exclude= --exclude-from= --include= \
  3458. < --include-from= --version --daemon --no-detach\
  3459. < --address= --config= --port= --blocking-io \
  3460. < --no-blocking-io --stats --progress \
  3461. < --log-format= --password-file= --bwlimit= \
  3462. < --write-batch= --read-batch= --help' -- $cur ))
  3463. < ;;
  3464. < *:*)
  3465. < # find which remote shell is used
  3466. < shell=rsh
  3467. < for (( i=1; i < COMP_CWORD; i++ )); do
  3468. < if [[ "${COMP_WORDS[i]}" == -@(e|-rsh) ]]; then
  3469. < shell=${COMP_WORDS[i+1]}
  3470. < break
  3471. < fi
  3472. < done
  3473. < if [[ "$shell" == ssh ]]; then
  3474. < # remove backslash escape from :
  3475. < cur=${cur/\\:/:}
  3476. < userhost=${cur%%?(\\):*}
  3477. < path=${cur#*:}
  3478. < # unescape spaces
  3479. < path=${path//\\\\\\\\ / }
  3480. < if [ -z "$path" ]; then
  3481. < # default to home dir of specified
  3482. < # user on remote host
  3483. < path=$(ssh -o 'Batchmode yes' \
  3484. < $userhost pwd 2>/dev/null)
  3485. < fi
  3486. < # escape spaces; remove executables, aliases, pipes
  3487. < # and sockets; add space at end of file names
  3488. < COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
  3489. < command ls -aF1d "$path*" 2>/dev/null | \
  3490. < sed -e 's/ /\\\\\\\ /g' -e 's/[*@|=]$//g' \
  3491. < -e 's/[^\/]$/& /g' ) )
  3492. < fi
  3493. < ;;
  3494. < *)
  3495. < _known_hosts -c -a
  3496. < _filedir
  3497. < ;;
  3498. < esac
  3499. <
  3500. < return 0
  3501. < } &&
  3502. < complete -F _rsync $nospace $filenames rsync
  3503. <
  3504. < # Linux route(8) completion
  3505. < #
  3506. < [ $UNAME = Linux ] &&
  3507. < _route()
  3508. < {
  3509. < local cur prev
  3510. <
  3511. < COMPREPLY=()
  3512. < cur=`_get_cword`
  3513. < prev=${COMP_WORDS[COMP_CWORD-1]}
  3514. <
  3515. < if [ "$prev" = dev ]; then
  3516. < COMPREPLY=( $( ifconfig -a | sed -ne 's|^\('$cur'[^ ]*\).*$|\1|p' ))
  3517. < return 0
  3518. < fi
  3519. <
  3520. < COMPREPLY=( $( compgen -W 'add del -host -net netmask metric mss \
  3521. < window irtt reject mod dyn reinstate dev \
  3522. < default gw' -- $cur ) )
  3523. <
  3524. < COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \
  3525. < (while read -d ' ' i; do
  3526. < [ "$i" == "" ] && continue
  3527. < # flatten array with spaces on either side,
  3528. < # otherwise we cannot grep on word
  3529. < # boundaries of first and last word
  3530. < COMPREPLY=" ${COMPREPLY[@]} "
  3531. < # remove word from list of completions
  3532. < COMPREPLY=( ${COMPREPLY/ $i / } )
  3533. < done
  3534. < echo ${COMPREPLY[@]})
  3535. < ) )
  3536. < return 0
  3537. < }
  3538. < [ $UNAME = Linux ] && complete -F _route route
  3539. <
  3540. < # GNU make(1) completion
  3541. < #
  3542. < have make || have gmake || have gnumake || have pmake &&
  3543. < _make()
  3544. < {
  3545. < local file makef makef_dir="." makef_inc cur prev i
  3546. <
  3547. < COMPREPLY=()
  3548. < cur=`_get_cword`
  3549. < prev=${COMP_WORDS[COMP_CWORD-1]}
  3550. <
  3551. < # --name value style option
  3552. < case $prev in
  3553. < -@(f|o|W))
  3554. < _filedir
  3555. < return 0
  3556. < ;;
  3557. < -@(I|C))
  3558. < _filedir -d
  3559. < return 0
  3560. < ;;
  3561. < esac
  3562. <
  3563. < # --name=value style option
  3564. < if [[ "$cur" == *=* ]]; then
  3565. < prev=${cur/=*/}
  3566. < cur=${cur/*=/}
  3567. < case "$prev" in
  3568. < --@(file|makefile))
  3569. < _filedir
  3570. < return 0
  3571. < ;;
  3572. < --@(directory|include-dir))
  3573. < _filedir -d
  3574. < return 0
  3575. < ;;
  3576. < esac
  3577. < fi
  3578. <
  3579. < if [[ "$cur" == -* ]]; then
  3580. < COMPREPLY=( $( compgen -W '-b -m -B -C -d -e -f -h -i -I\
  3581. < -j -l -k -n -o -p -q -r -R - s -S -t -v -w -W \
  3582. < --always-make --directory= --debug \
  3583. < --environment-overrides --file= --makefile= --help \
  3584. < --ignore-errors --include-dir= --jobs --load-average \
  3585. < --max-load --keep-going --just-print --dry-run \
  3586. < --recon --old-file= --assume-old= --print-data-base \
  3587. < --question --no-builtin-rules --no-builtin-variables \
  3588. < --silent --quiet --no-keep-goind --stop --touch \
  3589. < --version --print-directory --no-print-directory \
  3590. < --what-if= --new-file= --assume-new= \
  3591. < --warn-undefined-variables' -- $cur ) )
  3592. < else
  3593. < # before we check for makefiles, see if a path was specified
  3594. < # with -C
  3595. < for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
  3596. < if [[ ${COMP_WORDS[i]} == -C ]]; then
  3597. < # eval for tilde expansion
  3598. < eval makef_dir=${COMP_WORDS[i+1]}
  3599. < break
  3600. < fi
  3601. < done
  3602. <
  3603. < # make reads `GNUmakefile', then `makefile', then `Makefile'
  3604. < if [ -f ${makef_dir}/GNUmakefile ]; then
  3605. < makef=${makef_dir}/GNUmakefile
  3606. < elif [ -f ${makef_dir}/makefile ]; then
  3607. < makef=${makef_dir}/makefile
  3608. < elif [ -f ${makef_dir}/Makefile ]; then
  3609. < makef=${makef_dir}/Makefile
  3610. < else
  3611. < makef=${makef_dir}/*.mk # local convention
  3612. < fi
  3613. <
  3614. < # before we scan for targets, see if a Makefile name was
  3615. < # specified with -f
  3616. < for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
  3617. < if [[ ${COMP_WORDS[i]} == -f ]]; then
  3618. < # eval for tilde expansion
  3619. < eval makef=${COMP_WORDS[i+1]}
  3620. < break
  3621. < fi
  3622. < done
  3623. <
  3624. < [ ! -f $makef ] && return 0
  3625. <
  3626. < # deal with included Makefiles
  3627. < makef_inc=$( grep -E '^-?include' $makef | sed -e "s,^.* ,"$makef_dir"/," )
  3628. <
  3629. < for file in $makef_inc; do
  3630. < [ -f $file ] && makef="$makef $file"
  3631. < done
  3632. <
  3633. < COMPREPLY=( $( awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \
  3634. < {split($1,A,/ /);for(i in A)print A[i]}' \
  3635. < $makef 2>/dev/null | command grep "^$cur" ))
  3636. < fi
  3637. < } &&
  3638. < complete -f -F _make $filenames make gmake gnumake pmake
  3639. <
  3640. < # GNU tar(1) completion
  3641. < #
  3642. < _tar()
  3643. < {
  3644. < local cur ext regex tar untar
  3645. <
  3646. < COMPREPLY=()
  3647. < cur=`_get_cword`
  3648. <
  3649. < if [ $COMP_CWORD -eq 1 ]; then
  3650. < COMPREPLY=( $( compgen -W 'c t x u r d A' -- $cur ) )
  3651. < return 0
  3652. < fi
  3653. <
  3654. < case "${COMP_WORDS[1]}" in
  3655. < ?(-)[cr]*f)
  3656. < _filedir
  3657. < return 0
  3658. < ;;
  3659. < +([^IZzjy])f)
  3660. < ext='t@(ar?(.@(Z|gz|bz?(2)))|gz|bz?(2))'
  3661. < regex='t\(ar\(\.\(Z\|gz\|bz2\?\)\)\?\|gz\|bz2\?\)'
  3662. < ;;
  3663. < *[Zz]*f)
  3664. < ext='t?(ar.)@(gz|Z)'
  3665. < regex='t\(ar\.\)\?\(gz\|Z\)'
  3666. < ;;
  3667. < *[Ijy]*f)
  3668. < ext='t?(ar.)bz?(2)'
  3669. < regex='t\(ar\.\)\?bz2\?'
  3670. < ;;
  3671. < *)
  3672. < _filedir
  3673. < return 0
  3674. < ;;
  3675. <
  3676. < esac
  3677. <
  3678. < if [[ "$COMP_LINE" == *$ext' ' ]]; then
  3679. < # complete on files in tar file
  3680. < #
  3681. < # get name of tar file from command line
  3682. < tar=$( echo "$COMP_LINE" | \
  3683. < sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' )
  3684. < # devise how to untar and list it
  3685. < untar=t${COMP_WORDS[1]//[^Izjyf]/}
  3686. <
  3687. < COMPREPLY=( $( compgen -W "$( echo $( tar $untar $tar \
  3688. < 2>/dev/null ) )" -- "$cur" ) )
  3689. < return 0
  3690. < fi
  3691. <
  3692. < # file completion on relevant files
  3693. < _filedir $ext
  3694. <
  3695. < return 0
  3696. < }
  3697. < [ -n "${COMP_TAR_INTERNAL_PATHS:-}" ] && complete -F _tar $dirnames tar ||
  3698. < complete -F _tar $filenames tar
  3699. <
  3700. < # jar(1) completion
  3701. < #
  3702. < have jar &&
  3703. < _jar()
  3704. < {
  3705. < local cur
  3706. <
  3707. < COMPREPLY=()
  3708. < cur=`_get_cword`
  3709. <
  3710. < if [ $COMP_CWORD = 1 ]; then
  3711. < COMPREPLY=( $( compgen -W 'c t x u' -- $cur ) )
  3712. < return 0
  3713. < fi
  3714. <
  3715. < case "${COMP_WORDS[1]}" in
  3716. < *c*f)
  3717. < _filedir
  3718. < ;;
  3719. < *f)
  3720. < _filedir '?(e|j|w)ar'
  3721. < ;;
  3722. < *)
  3723. < _filedir
  3724. < ;;
  3725. < esac
  3726. < } &&
  3727. < complete -F _jar $filenames jar
  3728. <
  3729. < # Linux iptables(8) completion
  3730. < #
  3731. < have iptables &&
  3732. < _iptables()
  3733. < {
  3734. < local cur prev table chain
  3735. <
  3736. < COMPREPLY=()
  3737. < cur=`_get_cword`
  3738. < prev=${COMP_WORDS[COMP_CWORD-1]}
  3739. < chain='s/^Chain \([^ ]\+\).*$/\1/p'
  3740. <
  3741. < if [[ $COMP_LINE == *-t\ *filter* ]]; then
  3742. < table="-t filter"
  3743. < elif [[ $COMP_LINE == *-t\ *nat* ]]; then
  3744. < table="-t nat"
  3745. < elif [[ $COMP_LINE == *-t\ *mangle* ]]; then
  3746. < table="-t mangle"
  3747. < fi
  3748. <
  3749. < case "$prev" in
  3750. < -*[AIDRPFXLZ])
  3751. < COMPREPLY=( $( compgen -W '`iptables $table -nL | \
  3752. < sed -ne "s/^Chain \([^ ]\+\).*$/\1/p"`' -- $cur ) )
  3753. < ;;
  3754. < -*t)
  3755. < COMPREPLY=( $( compgen -W 'nat filter mangle' -- $cur ) )
  3756. < ;;
  3757. < -j)
  3758. < if [ "$table" = "-t filter" -o "$table" = "" ]; then
  3759. < COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
  3760. < `iptables $table -nL | sed -ne "$chain" \
  3761. < -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
  3762. < $cur ) )
  3763. < elif [ "$table" = "-t nat" ]; then
  3764. < COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
  3765. < MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \
  3766. < sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \
  3767. < -- $cur ) )
  3768. < elif [ "$table" = "-t mangle" ]; then
  3769. < COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
  3770. < MARK TOS `iptables $table -nL | sed -ne "$chain" \
  3771. < -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
  3772. < $cur ) )
  3773. < fi
  3774. < ;;
  3775. < *)
  3776. < if [[ "$cur" == -* ]]; then
  3777. < COMPREPLY=( $( compgen -W '-i -o -s -d -p -f -m --append \
  3778. < --delete --insert --replace --list --flush --zero --new \
  3779. < --delete-chain --policy --rename-chain --proto --source \
  3780. < --destination --in-interface --jump --match --numeric \
  3781. < --out-interface --table --verbose --line-numbers --exact \
  3782. < --fragment --modprobe= --set-counters --version' -- "$cur") )
  3783. < fi
  3784. < ;;
  3785. < esac
  3786. <
  3787. < } &&
  3788. < complete -F _iptables iptables
  3789. <
  3790. < # tcpdump(8) completion
  3791. < #
  3792. < have tcpdump &&
  3793. < _tcpdump()
  3794. < {
  3795. < local cur
  3796. <
  3797. < COMPREPLY=()
  3798. < cur=`_get_cword`
  3799. < prev=${COMP_WORDS[COMP_CWORD-1]}
  3800. <
  3801. < case "$prev" in
  3802. < -@(r|w|F))
  3803. < _filedir
  3804. < return 0
  3805. < ;;
  3806. < -i)
  3807. < _available_interfaces -a
  3808. < return 0
  3809. < ;;
  3810. < esac
  3811. <
  3812. <
  3813. < if [[ "$cur" == -* ]]; then
  3814. < COMPREPLY=( $( compgen -W '-a -d -e -f -l -n -N -O -p \
  3815. < -q -R -S -t -u -v -x -C -F -i -m -r -s -T -w \
  3816. < -E' -- $cur ) )
  3817. < fi
  3818. <
  3819. < } &&
  3820. < complete -F _tcpdump tcpdump
  3821. <
  3822. < # autorpm(8) completion
  3823. < #
  3824. < have autorpm &&
  3825. < _autorpm()
  3826. < {
  3827. < local cur
  3828. <
  3829. < COMPREPLY=()
  3830. < cur=`_get_cword`
  3831. <
  3832. < COMPREPLY=( $( compgen -W '--notty --debug --help --version \
  3833. < auto add fullinfo info help install list \
  3834. < remove set' -- $cur ) )
  3835. ---
  3836. > # This function counts the number of args, excluding options
  3837. > # @param $1 chars Characters out of $COMP_WORDBREAKS which should
  3838. > # NOT be considered word breaks. See __reassemble_comp_words_by_ref.
  3839. > _count_args()
  3840. > {
  3841. > local i cword words
  3842. > __reassemble_comp_words_by_ref "$1" words cword
  3843. 3077,3078c1090,1094
  3844. < } &&
  3845. < complete -F _autorpm autorpm
  3846. ---
  3847. > args=1
  3848. > for i in "${words[@]:1:cword-1}"; do
  3849. > [[ "$i" != -* ]] && args=$(($args+1))
  3850. > done
  3851. > }
  3852. 3080,3081c1096
  3853. < # This meta-cd function observes the CDPATH variable, so that cd additionally
  3854. < # completes on directories under those specified in CDPATH.
  3855. ---
  3856. > # This function completes on PCI IDs
  3857. 3083c1098
  3858. < _cd()
  3859. ---
  3860. > _pci_ids()
  3861. 3085,3124c1100,1101
  3862. < local IFS=$'\t\n' cur=`_get_cword` i j k
  3863. <
  3864. < # try to allow variable completion
  3865. < if [[ "$cur" == ?(\\)\$* ]]; then
  3866. < COMPREPLY=( $( compgen -v -P '$' -- "${cur#?(\\)$}" ) )
  3867. < return 0
  3868. < fi
  3869. <
  3870. < # Use standard dir completion if no CDPATH or parameter starts with /,
  3871. < # ./ or ../
  3872. < if [ -z "${CDPATH:-}" ] || [[ "$cur" == ?(.)?(.)/* ]]; then
  3873. < _filedir -d
  3874. < return 0
  3875. < fi
  3876. <
  3877. < local -r mark_dirs=$(_rl_enabled mark-directories && echo y)
  3878. < local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y)
  3879. <
  3880. < # we have a CDPATH, so loop on its contents
  3881. < for i in ${CDPATH//:/$'\t'}; do
  3882. < # create an array of matched subdirs
  3883. < k=${#COMPREPLY[@]}
  3884. < for j in $( compgen -d $i/$cur ); do
  3885. < if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
  3886. < j="${j}/"
  3887. < fi
  3888. < COMPREPLY[k++]=${j#$i/}
  3889. < done
  3890. < done
  3891. <
  3892. < _filedir -d
  3893. <
  3894. < if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
  3895. < i=${COMPREPLY[0]}
  3896. < if [ "$i" == "$cur" ] && [[ $i != "*/" ]]; then
  3897. < COMPREPLY[0]="${i}/"
  3898. < fi
  3899. < fi
  3900. <
  3901. < return 0
  3902. ---
  3903. > COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W \
  3904. > "$( PATH="$PATH:/sbin" lspci -n | awk '{print $3}')" -- "$cur" ) )
  3905. 3126,3130d1102
  3906. < if shopt -q cdable_vars; then
  3907. < complete -v -F _cd $nospace $filenames cd
  3908. < else
  3909. < complete -F _cd $nospace $filenames cd
  3910. < fi
  3911. 3132,3135c1104
  3912. < # A meta-command completion function for commands like sudo(8), which need to
  3913. < # first complete on a command, then complete according to that command's own
  3914. < # completion definition - currently not quite foolproof (e.g. mount and umount
  3915. < # don't work properly), but still quite useful.
  3916. ---
  3917. > # This function completes on USB IDs
  3918. 3137c1106
  3919. < _command()
  3920. ---
  3921. > _usb_ids()
  3922. 3139,3213c1108,1109
  3923. < local cur func cline cspec noglob cmd done i \
  3924. < _COMMAND_FUNC _COMMAND_FUNC_ARGS
  3925. <
  3926. < COMPREPLY=()
  3927. < cur=`_get_cword`
  3928. < # If the the first arguments following our meta-command-invoker are
  3929. < # switches, get rid of them. Most definitely not foolproof.
  3930. < done=
  3931. < while [ -z $done ] ; do
  3932. < cmd=${COMP_WORDS[1]}
  3933. < if [[ "$cmd" == -* ]] && [ $COMP_CWORD -gt 1 ]; then
  3934. < for (( i=1 ; i<COMP_CWORD ; i++)) ; do
  3935. < COMP_WORDS[i]=${COMP_WORDS[i+1]}
  3936. < done
  3937. < COMP_CWORD=$(($COMP_CWORD-1))
  3938. < else
  3939. < done=1
  3940. < fi
  3941. < done
  3942. <
  3943. < if [ $COMP_CWORD -eq 1 ]; then
  3944. < COMPREPLY=( $( compgen -c -- $cur ) )
  3945. < elif complete -p $cmd &>/dev/null; then
  3946. < cspec=$( complete -p $cmd )
  3947. < if [ "${cspec#* -F }" != "$cspec" ]; then
  3948. < # complete -F <function>
  3949. < #
  3950. < # COMP_CWORD and COMP_WORDS() are not read-only,
  3951. < # so we can set them before handing off to regular
  3952. < # completion routine
  3953. <
  3954. < # set current token number to 1 less than now
  3955. < COMP_CWORD=$(( $COMP_CWORD - 1 ))
  3956. <
  3957. < # get function name
  3958. < func=${cspec#*-F }
  3959. < func=${func%% *}
  3960. < # get current command line minus initial command
  3961. < cline="${COMP_LINE#*( )$1 }"
  3962. < # save noglob state
  3963. < shopt -qo noglob; noglob=$?
  3964. < # turn on noglob, as things like 'sudo ls *<Tab>'
  3965. < # don't work otherwise
  3966. < shopt -so noglob
  3967. < # split current command line tokens into array
  3968. < COMP_WORDS=( $cline )
  3969. < # reset noglob if necessary
  3970. < [ $noglob -eq 1 ] && shopt -uo noglob
  3971. < $func $cline
  3972. < # This is needed in case user finished entering
  3973. < # command and pressed tab (e.g. sudo ls <Tab>)
  3974. < COMP_CWORD=$(( $COMP_CWORD > 0 ? $COMP_CWORD : 1 ))
  3975. < cur=`_get_cword`
  3976. < _COMMAND_FUNC=$func
  3977. < _COMMAND_FUNC_ARGS=( $cmd $2 $3 )
  3978. < COMP_LINE=$cline
  3979. < COMP_POINT=$(( ${COMP_POINT} - ${#1} - 1 ))
  3980. < $func $cmd $2 $3
  3981. < # remove any \: generated by a command that doesn't
  3982. < # default to filenames or dirnames (e.g. sudo chown)
  3983. < if [ "${cspec#*-o }" != "$cspec" ]; then
  3984. < cspec=${cspec#*-o }
  3985. < cspec=${cspec%% *}
  3986. < if [[ "$cspec" != @(dir|file)names ]]; then
  3987. < COMPREPLY=("${COMPREPLY[@]//\\\\:/:}")
  3988. < fi
  3989. < fi
  3990. < elif [ -n "$cspec" ]; then
  3991. < cspec=${cspec#complete};
  3992. < cspec=${cspec%%$cmd};
  3993. < COMPREPLY=( $( eval compgen "$cspec" -- "$cur" ) );
  3994. < fi
  3995. < fi
  3996. <
  3997. < [ ${#COMPREPLY[@]} -eq 0 ] && _filedir
  3998. ---
  3999. > COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W \
  4000. > "$( PATH="$PATH:/sbin" lsusb | awk '{print $6}' )" -- "$cur" ) )
  4001. 3215,3216d1110
  4002. < complete -F _command $filenames nohup exec nice eval strace time ltrace then \
  4003. < else do vsound command xargs
  4004. 3218c1112,1113
  4005. < _root_command()
  4006. ---
  4007. > # CD device names
  4008. > _cd_devices()
  4009. 3220c1115,1116
  4010. < PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin _command $1 $2 $3
  4011. ---
  4012. > COMPREPLY=( "${COMPREPLY[@]}"
  4013. > $( compgen -f -d -X "!*/?([amrs])cd*" -- "${cur:-/dev/}" ) )
  4014. 3222d1117
  4015. < complete -F _root_command $filenames sudo fakeroot really
  4016. 3224,3227c1119,1120
  4017. < # ant(1) completion
  4018. < #
  4019. < have ant && {
  4020. < _ant()
  4021. ---
  4022. > # DVD device names
  4023. > _dvd_devices()
  4024. 3229,4132c1122,1123
  4025. < local cur prev buildfile i
  4026. <
  4027. < COMPREPLY=()
  4028. < cur=`_get_cword`
  4029. < prev=${COMP_WORDS[COMP_CWORD-1]}
  4030. <
  4031. < case "$prev" in
  4032. < -buildfile|-f)
  4033. < _filedir 'xml'
  4034. < return 0
  4035. < ;;
  4036. < -logfile)
  4037. < _filedir
  4038. < return 0
  4039. < ;;
  4040. < esac
  4041. <
  4042. < if [[ "$cur" == -* ]]; then
  4043. < # relevant options completion
  4044. < COMPREPLY=( $( compgen -W '-help -projecthelp -version -quiet \
  4045. < -verbose -debug -emacs -logfile -logger \
  4046. < -listener -buildfile -f -D -find' -- $cur ) )
  4047. < else
  4048. < # available targets completion
  4049. < # find which buildfile to use
  4050. < buildfile=build.xml
  4051. < for (( i=1; i < COMP_CWORD; i++ )); do
  4052. < if [[ "${COMP_WORDS[i]}" == -buildfile ]]; then
  4053. < buildfile=${COMP_WORDS[i+1]}
  4054. < break
  4055. < fi
  4056. < done
  4057. < [ ! -f $buildfile ] && return 0
  4058. <
  4059. < # parse buildfile for targets
  4060. < COMPREPLY=( $( awk -F'"' '/<target name="/ {print $2}' \
  4061. < $buildfile | grep "^$cur" )
  4062. < $( awk -F"'" "/<target name='/ "'{print $2}' \
  4063. < $buildfile | grep "^$cur" )
  4064. < $( awk -F'"' '/<target [^n]/ {if ($1 ~ /name=/) { print $2 } else if ($3 ~ /name=/) {print $4} else if ($5 ~ /name=/) {print $6}}' \
  4065. < $buildfile | grep "^$cur" ) )
  4066. < fi
  4067. < }
  4068. < have complete-ant-cmd.pl && \
  4069. < complete -C complete-ant-cmd.pl -F _ant $filenames ant || \
  4070. < complete -F _ant $filenames ant
  4071. < }
  4072. <
  4073. < have nslookup &&
  4074. < _nslookup()
  4075. < {
  4076. < local cur
  4077. <
  4078. < COMPREPLY=()
  4079. < cur=${COMP_WORDS[COMP_CWORD]#-}
  4080. <
  4081. < COMPREPLY=( $( compgen -P '-' -W 'all class= debug d2 domain= \
  4082. < srchlist= defname search port= querytype= \
  4083. < type= recurse retry root timeout vc \
  4084. < ignoretc' -- $cur ) )
  4085. < } &&
  4086. < complete -F _nslookup nslookup
  4087. <
  4088. < # mysqladmin(1) completion
  4089. < #
  4090. < have mysqladmin &&
  4091. < _mysqladmin()
  4092. < {
  4093. < local cur prev
  4094. <
  4095. < COMPREPLY=()
  4096. < cur=`_get_cword`
  4097. < prev=${COMP_WORDS[COMP_CWORD-1]}
  4098. <
  4099. < case "$prev" in
  4100. < -u)
  4101. < COMPREPLY=( $( compgen -u -- $cur ) )
  4102. < return 0
  4103. < ;;
  4104. < *)
  4105. < ;;
  4106. < esac
  4107. <
  4108. < COMPREPLY=( $( compgen -W '-# -f -? -C -h -p -P -i -r -E -s -S -t -u \
  4109. < -v -V -w' -- $cur ) )
  4110. <
  4111. < COMPREPLY=( ${COMPREPLY[@]} \
  4112. < $( compgen -W 'create drop extended-status flush-hosts \
  4113. < flush-logs flush-status flush-tables \
  4114. < flush-threads flush-privileges kill \
  4115. < password ping processlist reload refresh \
  4116. < shutdown status variables version' \
  4117. < -- $cur ) )
  4118. < } &&
  4119. < complete -F _mysqladmin mysqladmin
  4120. <
  4121. < # gzip(1) completion
  4122. < #
  4123. < have gzip &&
  4124. < _gzip()
  4125. < {
  4126. < local cur prev xspec IFS=$'\t\n'
  4127. <
  4128. < COMPREPLY=()
  4129. < cur=`_get_cword`
  4130. < prev=${COMP_WORDS[COMP_CWORD-1]}
  4131. <
  4132. < if [[ "$cur" == -* ]]; then
  4133. < COMPREPLY=( $( compgen -W '-c -d -f \
  4134. < -h -l -L -n -N -q -r -S -t -v -V \
  4135. < -1 -2 -3 -4 -5 -6 -7 -8 -9 \
  4136. < --stdout --decompress --force --help --list \
  4137. < --license --no-name --name --quiet --recursive \
  4138. < --suffix --test --verbose --version --fast \
  4139. < --best' -- $cur ) )
  4140. < return 0
  4141. < fi
  4142. <
  4143. < xspec="*.?(t)gz"
  4144. < if [[ "$prev" == --* ]]; then
  4145. < [[ "$prev" == --decompress || \
  4146. < "$prev" == --list || \
  4147. < "$prev" == --test ]] && xspec="!"$xspec
  4148. < [[ "$prev" == --force ]] && xspec=
  4149. < elif [[ "$prev" == -* ]]; then
  4150. < [[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec
  4151. < [[ "$prev" == -*f* ]] && xspec=
  4152. < elif [ "$prev" = '>' ]; then
  4153. < xspec=
  4154. < elif [ "$prev" = '<' ]; then
  4155. < xspec=
  4156. < fi
  4157. <
  4158. < _expand || return 0
  4159. <
  4160. < COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
  4161. < $( compgen -d -- $cur ) )
  4162. < } &&
  4163. < complete -F _gzip $filenames gzip
  4164. <
  4165. < # bzip2(1) completion
  4166. < #
  4167. < have bzip2 &&
  4168. < _bzip2()
  4169. < {
  4170. < local cur prev xspec IFS=$'\t\n'
  4171. <
  4172. < COMPREPLY=()
  4173. < cur=`_get_cword`
  4174. < prev=${COMP_WORDS[COMP_CWORD-1]}
  4175. <
  4176. < if [[ "$cur" == -* ]]; then
  4177. < COMPREPLY=( $( compgen -W '-c -d -f -h -k -L -q -s \
  4178. < -t -v -V -z -1 -2 -3 -4 -5 -6 -7 -8 -9 \
  4179. < --help --decompress --compress --keep --force \
  4180. < --test --stdout --quiet --verbose --license \
  4181. < --version --small --fast --best' -- $cur ) )
  4182. < return 0
  4183. < fi
  4184. <
  4185. < xspec="*.bz2"
  4186. < if [[ "$prev" == --* ]]; then
  4187. < [[ "$prev" == --decompress || \
  4188. < "$prev" == --list || \
  4189. < "$prev" == --test ]] && xspec="!"$xspec
  4190. < [[ "$prev" == --compress ]] && xspec=
  4191. < elif [[ "$prev" == -* ]]; then
  4192. < [[ "$prev" == -*[dt]* ]] && xspec="!"$xspec
  4193. < [[ "$prev" == -*z* ]] && xspec=
  4194. < fi
  4195. <
  4196. < _expand || return 0
  4197. <
  4198. < COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
  4199. < $( compgen -d -- $cur ) )
  4200. < } &&
  4201. < complete -F _bzip2 $filenames bzip2
  4202. <
  4203. < # openssl(1) completion
  4204. < #
  4205. < have openssl && {
  4206. < _openssl_sections()
  4207. < {
  4208. < local config
  4209. <
  4210. < config=/etc/ssl/openssl.cnf
  4211. < [ ! -f $config ] && config=/usr/share/ssl/openssl.cnf
  4212. < for (( i=2; i < COMP_CWORD; i++ )); do
  4213. < if [[ "${COMP_WORDS[i]}" == -config ]]; then
  4214. < config=${COMP_WORDS[i+1]}
  4215. < break
  4216. < fi
  4217. < done
  4218. < [ ! -f $config ] && return 0
  4219. <
  4220. < COMPREPLY=( $( awk '/\[.*\]/ {print $2} ' $config | grep "^$cur" ) )
  4221. < }
  4222. <
  4223. < _openssl()
  4224. < {
  4225. < local cur prev
  4226. <
  4227. < COMPREPLY=()
  4228. < cur=`_get_cword`
  4229. <
  4230. < if [ $COMP_CWORD -eq 1 ]; then
  4231. < COMPREPLY=( $( compgen -W 'asn1parse ca ciphers crl crl2pkcs7 \
  4232. < dgst dh dhparam dsa dsaparam enc errstr gendh gendsa \
  4233. < genrsa nseq passwd pkcs12 pkcs7 pkcs8 rand req rsa \
  4234. < rsautl s_client s_server s_time sess_id smime speed \
  4235. < spkac verify version x509 md2 md4 md5 mdc2 rmd160 sha \
  4236. < sha1 base64 bf bf-cbc bf-cfb bf-ecb bf-ofb cast \
  4237. < cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb des \
  4238. < des-cbc des-cfb des-ecb des-ede des-ede-cbc \
  4239. < des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc \
  4240. < des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 \
  4241. < rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb \
  4242. < rc4 rc4-40' -- $cur ) )
  4243. < else
  4244. < prev=${COMP_WORDS[COMP_CWORD-1]}
  4245. < case ${COMP_WORDS[1]} in
  4246. < asn1parse)
  4247. < case $prev in
  4248. < -inform)
  4249. < COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
  4250. < return 0
  4251. < ;;
  4252. < -@(in|out|oid))
  4253. < _filedir
  4254. < return 0
  4255. < ;;
  4256. < esac
  4257. <
  4258. < if [[ "$cur" == -* ]]; then
  4259. < COMPREPLY=( $( compgen -W '-inform -in -out -noout -offset \
  4260. < -length -i -oid -strparse' -- $cur ) )
  4261. < fi
  4262. < ;;
  4263. < ca)
  4264. < case $prev in
  4265. < -@(config|revoke|cert|in|out|spkac|ss_cert))
  4266. < _filedir
  4267. < return 0
  4268. < ;;
  4269. < -outdir)
  4270. < _filedir -d
  4271. < return 0
  4272. < ;;
  4273. < -@(name|crlexts|extensions))
  4274. < _openssl_sections
  4275. < return 0
  4276. < ;;
  4277. < esac
  4278. <
  4279. < if [[ "$cur" == -* ]]; then
  4280. < COMPREPLY=( $( compgen -W '-verbose -config -name \
  4281. < -gencrl -revoke -crldays -crlhours -crlexts \
  4282. < -startdate -enddate -days -md -policy -keyfile \
  4283. < -key -passin -cert -in -out -notext -outdir \
  4284. < -infiles -spkac -ss_cert -preserveDN -batch \
  4285. < -msie_hack -extensions' -- $cur ) )
  4286. < fi
  4287. < ;;
  4288. < ciphers)
  4289. < if [[ "$cur" == -* ]]; then
  4290. < COMPREPLY=( $( compgen -W '-v -ssl2 -ssl3 -tls1' -- $cur ) )
  4291. < fi
  4292. < ;;
  4293. < crl)
  4294. < case $prev in
  4295. < -@(in|out)form)
  4296. < COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
  4297. < return 0
  4298. < ;;
  4299. < -@(in|out|CAfile))
  4300. < _filedir
  4301. < return 0
  4302. < ;;
  4303. < -CAPath)
  4304. < _filedir -d
  4305. < return 0
  4306. < ;;
  4307. < esac
  4308. <
  4309. < if [[ "$cur" == -* ]]; then
  4310. < COMPREPLY=( $( compgen -W '-inform -outform -text -in -out -noout \
  4311. < -hash -issuer -lastupdate -nextupdate -CAfile -CApath' -- $cur ) )
  4312. < fi
  4313. < ;;
  4314. < crl2pkcs7)
  4315. < case $prev in
  4316. < -@(in|out)form)
  4317. < COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
  4318. < return 0
  4319. < ;;
  4320. < -@(in|out))
  4321. < _filedir
  4322. < return 0
  4323. < ;;
  4324. < esac
  4325. <
  4326. < if [[ "$cur" == -* ]]; then
  4327. < COMPREPLY=( $( compgen -W '-inform -outform -in -out -print_certs' -- $cur ) )
  4328. < fi
  4329. < ;;
  4330. < dgst)
  4331. < case $prev in
  4332. < -@(out|sign|verify|prvrify|signature))
  4333. < _filedir
  4334. < return 0
  4335. < ;;
  4336. < esac
  4337. <
  4338. < if [[ "$cur" == -* ]]; then
  4339. < COMPREPLY=( $( compgen -W '-md5 -md4 -md2 -sha1 -sha -mdc2 -ripemd160 -dss1 \
  4340. < -c -d -hex -binary -out -sign -verify -prverify -signature' -- $cur ) )
  4341. < else
  4342. < _filedir
  4343. < fi
  4344. < ;;
  4345. < dsa)
  4346. < case $prev in
  4347. < -@(in|out)form)
  4348. < COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
  4349. < return 0
  4350. < ;;
  4351. < -@(in|out))
  4352. < _filedir
  4353. < return 0
  4354. < ;;
  4355. < esac
  4356. <
  4357. < if [[ "$cur" == -* ]]; then
  4358. < COMPREPLY=( $( compgen -W '-inform -outform -in -passin -out -passout -des -des3 -idea -text -noout \
  4359. < -modulus -pubin -pubout' -- $cur ) )
  4360. < fi
  4361. < ;;
  4362. < dsaparam)
  4363. < case $prev in
  4364. < -@(in|out)form)
  4365. < COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
  4366. < return 0
  4367. < ;;
  4368. < -@(in|out|rand))
  4369. < _filedir
  4370. < return 0
  4371. < ;;
  4372. < esac
  4373. <
  4374. < if [[ "$cur" == -* ]]; then
  4375. < COMPREPLY=( $( compgen -W '-inform -outform -in -out -noout \
  4376. < -text -C -rand -genkey' -- $cur ) )
  4377. < fi
  4378. < ;;
  4379. < enc)
  4380. < case $prev in
  4381. < -@(in|out|kfile))
  4382. < _filedir
  4383. < return 0
  4384. < ;;
  4385. < esac
  4386. <
  4387. < if [[ "$cur" == -* ]]; then
  4388. < COMPREPLY=( $( compgen -W '-ciphername -in -out -pass \
  4389. < -e -d -a -A -k -kfile -S -K -iv -p -P -bufsize -debug' -- $cur ) )
  4390. < fi
  4391. < ;;
  4392. < dhparam)
  4393. < case $prev in
  4394. < -@(in|out)form)
  4395. < COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
  4396. < return 0
  4397. < ;;
  4398. < -@(in|out|rand))
  4399. < _filedir
  4400. < return 0
  4401. < ;;
  4402. < esac
  4403. <
  4404. < if [[ "$cur" == -* ]]; then
  4405. < COMPREPLY=( $( compgen -W '-inform -outform -in -out -dsaparam -noout \
  4406. < -text -C -2 -5 -rand' -- $cur ) )
  4407. < fi
  4408. < ;;
  4409. < gendsa)
  4410. < case $prev in
  4411. < -@(out|rand))
  4412. < _filedir
  4413. < return 0
  4414. < ;;
  4415. < esac
  4416. <
  4417. < if [[ "$cur" == -* ]]; then
  4418. < COMPREPLY=( $( compgen -W '-out -des -des3 -idea -rand' -- $cur ) )
  4419. < else
  4420. < _filedir
  4421. < fi
  4422. < ;;
  4423. < genrsa)
  4424. < case $prev in
  4425. < -@(out|rand))
  4426. < _filedir
  4427. < return 0
  4428. < ;;
  4429. < esac
  4430. <
  4431. < if [[ "$cur" == -* ]]; then
  4432. < COMPREPLY=( $( compgen -W '-out -passout -des -des3 -idea -f4 -3 -rand' -- $cur ) )
  4433. < fi
  4434. < ;;
  4435. < pkcs7)
  4436. < case $prev in
  4437. < -@(in|out)form)
  4438. < COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
  4439. < return 0
  4440. < ;;
  4441. < -@(in|out))
  4442. < _filedir
  4443. < return 0
  4444. < ;;
  4445. < esac
  4446. <
  4447. < if [[ "$cur" == -* ]]; then
  4448. < COMPREPLY=( $( compgen -W '-inform -outform -in -out -print_certs -text -noout' -- $cur ) )
  4449. < fi
  4450. < ;;
  4451. < rand)
  4452. < case $prev in
  4453. < -@(out|rand))
  4454. < _filedir
  4455. < return 0
  4456. < ;;
  4457. < esac
  4458. <
  4459. < if [[ "$cur" == -* ]]; then
  4460. < COMPREPLY=( $( compgen -W '-out -rand -base64' -- $cur ) )
  4461. < fi
  4462. < ;;
  4463. < req)
  4464. < case "$prev" in
  4465. < -@(in|out|key)form)
  4466. < COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
  4467. < return 0
  4468. < ;;
  4469. <
  4470. < -@(in|out|rand|key|keyout|config))
  4471. < _filedir
  4472. < return 0
  4473. < ;;
  4474. < -extensions)
  4475. < _openssl_sections
  4476. < return 0
  4477. < ;;
  4478. < esac
  4479. <
  4480. < if [[ "$cur" == -* ]]; then
  4481. < COMPREPLY=( $( compgen -W '-inform -outform -in \
  4482. < -passin -out -passout -text -noout -verify \
  4483. < -modulus -new -rand -newkey -newkey -nodes \
  4484. < -key -keyform -keyout -md5 -sha1 -md2 -mdc2 \
  4485. < -config -x509 -days -asn1-kludge -newhdr \
  4486. < -extensions -reqexts section' -- $cur ) )
  4487. < fi
  4488. < ;;
  4489. < rsa)
  4490. < case $prev in
  4491. < -@(in|out)form)
  4492. < COMPREPLY=( $( compgen -W 'DER NET PEM' -- $cur ) )
  4493. < return 0
  4494. < ;;
  4495. < -@(in|out))
  4496. < _filedir
  4497. < return 0
  4498. < ;;
  4499. < esac
  4500. <
  4501. < if [[ "$cur" == -* ]]; then
  4502. < COMPREPLY=( $( compgen -W '-inform -outform -in -passin -out -passout \
  4503. < -sgckey -des -des3 -idea -text -noout -modulus -check -pubin \
  4504. < -pubout -engine' -- $cur ) )
  4505. < fi
  4506. < ;;
  4507. < rsautl)
  4508. < case $prev in
  4509. < -@(in|out|inkey))
  4510. < _filedir
  4511. < return 0
  4512. < ;;
  4513. < esac
  4514. <
  4515. < if [[ "$cur" == -* ]]; then
  4516. < COMPREPLY=( $( compgen -W '-in -out -inkey -pubin -certin -sign -verify \
  4517. < -encrypt -decrypt -pkcs -ssl -raw -hexdump -asn1parse' -- $cur ) )
  4518. < fi
  4519. < ;;
  4520. < s_client)
  4521. < case $prev in
  4522. < -connect)
  4523. < _known_hosts
  4524. < return 0
  4525. < ;;
  4526. < -@(cert|key|CAfile|rand))
  4527. < _filedir
  4528. < return 0
  4529. < ;;
  4530. < -CApath)
  4531. < _filedir -d
  4532. < return 0
  4533. < ;;
  4534. < esac
  4535. <
  4536. < if [[ "$cur" == -* ]]; then
  4537. < COMPREPLY=( $( compgen -W '-connect -verify -cert -key -CApath -CAfile \
  4538. < -reconnect -pause -showcerts -debug -msg -nbio_test -state -nbio \
  4539. < -crlf -ign_eof -quiet -ssl2 -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 \
  4540. < -bugs -cipher -starttls -engine -rand' -- $cur ) )
  4541. < fi
  4542. < ;;
  4543. < s_server)
  4544. < case $prev in
  4545. < -@(cert|key|dcert|dkey|dhparam|CAfile|rand))
  4546. < _filedir
  4547. < return 0
  4548. < ;;
  4549. < -CApath)
  4550. < _filedir -d
  4551. < return 0
  4552. < ;;
  4553. < esac
  4554. <
  4555. < if [[ "$cur" == -* ]]; then
  4556. < COMPREPLY=( $( compgen -W '-accept -context -verify -Verify -cert -key \
  4557. < -dcert -dkey -dhparam -nbio -nbio_test -crlf -debug -msg -state -CApath \
  4558. < -CAfile -nocert -cipher -quiet -no_tmp_rsa -ssl2 -ssl3 -tls1 -no_ssl2 \
  4559. < -no_ssl3 -no_tls1 -no_dhe -bugs -hack -www -WWW -HTTP -engine -id_prefix \
  4560. < -rand' -- $cur ) )
  4561. < fi
  4562. < ;;
  4563. < s_time)
  4564. < case $prev in
  4565. < -connect)
  4566. < _known_hosts
  4567. < return 0
  4568. < ;;
  4569. < -@(cert|key|CAfile))
  4570. < _filedir
  4571. < return 0
  4572. < ;;
  4573. < -CApath)
  4574. < _filedir -d
  4575. < return 0
  4576. < ;;
  4577. < esac
  4578. <
  4579. < if [[ "$cur" == -* ]]; then
  4580. < COMPREPLY=( $( compgen -W '-connect -www -cert -key -CApath -CAfile -reuse \
  4581. < -new -verify -nbio -time -ssl2 -ssl3 -bugs -cipher' -- $cur ) )
  4582. < fi
  4583. < ;;
  4584. <
  4585. < sess_id)
  4586. < case $prev in
  4587. < -@(in|out)form)
  4588. < COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
  4589. < return 0
  4590. < ;;
  4591. < -@(in|out))
  4592. < _filedir
  4593. < return 0
  4594. < ;;
  4595. < esac
  4596. <
  4597. <
  4598. < if [[ "$cur" == -* ]]; then
  4599. < COMPREPLY=( $( compgen -W '-inform -outform -in -out -text -noout \
  4600. < -context ID' -- $cur ) )
  4601. < fi
  4602. < ;;
  4603. < smime)
  4604. < case $prev in
  4605. < -@(in|out)form)
  4606. < COMPREPLY=( $( compgen -W 'SMIME DER PEM' -- $cur ) )
  4607. < return 0
  4608. < ;;
  4609. < -@(in|out|certfile|signer|recip|inkey|content|rand))
  4610. < _filedir
  4611. < return 0
  4612. < ;;
  4613. < esac
  4614. <
  4615. < if [[ "$cur" == -* ]]; then
  4616. < COMPREPLY=( $( compgen -W '-encrypt -decrypt -sign -verify -pk7out -des -des3 \
  4617. < -rc2-40 -rc2-64 -rc2-128 -aes128 -aes192 -aes256 -in -certfile -signer \
  4618. < -recip -inform -passin -inkey -out -outform -content -to -from -subject \
  4619. < -text -rand' -- $cur ) )
  4620. < else
  4621. < _filedir
  4622. < fi
  4623. < ;;
  4624. < speed)
  4625. < if [[ "$cur" == -* ]]; then
  4626. < COMPREPLY=( $( compgen -W '-engine' -- $cur ) )
  4627. < else
  4628. < COMPREPLY=( $( compgen -W 'md2 mdc2 md5 hmac sha1 rmd160 idea-cbc \
  4629. < rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4 rsa512 rsa1024 rsa2048 \
  4630. < rsa4096 dsa512 dsa1024 dsa2048 idea rc2 des rsa blowfish' -- $cur ) )
  4631. < fi
  4632. < ;;
  4633. < verify)
  4634. < case $prev in
  4635. < -@(CAfile|untrusted))
  4636. < _filedir
  4637. < return 0
  4638. < ;;
  4639. < -CApath)
  4640. < _filedir -d
  4641. < return 0
  4642. < ;;
  4643. < esac
  4644. <
  4645. < if [[ "$cur" == -* ]]; then
  4646. < COMPREPLY=( $( compgen -W '-CApath -CAfile -purpose -untrusted -help -issuer_checks \
  4647. < -verbose -certificates' -- $cur ) )
  4648. < else
  4649. < _filedir
  4650. < fi
  4651. < ;;
  4652. < x509)
  4653. < case "$prev" in
  4654. < -@(in|out|CA|CAkey|CAserial|extfile))
  4655. < _filedir
  4656. < return 0
  4657. < ;;
  4658. < -@(in|out)form)
  4659. < COMPREPLY=( $( compgen -W 'DER PEM NET' -- $cur ) )
  4660. < return 0
  4661. < ;;
  4662. < -@(key|CA|CAkey)form)
  4663. < COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
  4664. < return 0
  4665. < ;;
  4666. < -extensions)
  4667. < _openssl_sections
  4668. < return 0
  4669. < ;;
  4670. < esac
  4671. <
  4672. < if [[ "$cur" == -* ]]; then
  4673. < COMPREPLY=( $( compgen -W '-inform -outform \
  4674. < -keyform -CAform -CAkeyform -in -out \
  4675. < -serial -hash -subject -issuer -nameopt \
  4676. < -email -startdate -enddate -purpose \
  4677. < -dates -modulus -fingerprint -alias \
  4678. < -noout -trustout -clrtrust -clrreject \
  4679. < -addtrust -addreject -setalias -days \
  4680. < -set_serial -signkey -x509toreq -req \
  4681. < -CA -CAkey -CAcreateserial -CAserial \
  4682. < -text -C -md2 -md5 -sha1 -mdc2 -clrext \
  4683. < -extfile -extensions -engine' -- $cur ) )
  4684. < fi
  4685. < ;;
  4686. < @(md5|md4|md2|sha1|sha|mdc2|ripemd160))
  4687. < if [[ "$cur" == -* ]]; then
  4688. < COMPREPLY=( $( compgen -W '-c -d' -- $cur ) )
  4689. < else
  4690. < _filedir
  4691. < fi
  4692. < ;;
  4693. < esac
  4694. < fi
  4695. <
  4696. < return 0
  4697. < }
  4698. < complete -F _openssl $default openssl
  4699. < }
  4700. <
  4701. < # screen(1) completion
  4702. < #
  4703. < have screen &&
  4704. < _screen()
  4705. < {
  4706. < local cur prev preprev
  4707. <
  4708. < COMPREPLY=()
  4709. < cur=`_get_cword`
  4710. < prev=${COMP_WORDS[COMP_CWORD-1]}
  4711. <
  4712. < [ "$COMP_CWORD" -ge 2 ] && preprev=${COMP_WORDS[COMP_CWORD-2]}
  4713. <
  4714. < if [ "$preprev" = "-d" -o "$preprev" = "-D" -a "$prev" = "-r" -o \
  4715. < "$prev" = "-R" ]; then
  4716. < # list all
  4717. < COMPREPLY=( $( command screen -ls | \
  4718. < sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*$|\1|p' ) )
  4719. < else
  4720. < case "$prev" in
  4721. < -[rR])
  4722. < # list detached
  4723. < COMPREPLY=( $( command screen -ls | \
  4724. < sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*Detached.*$|\1|p' ) )
  4725. < ;;
  4726. < -[dDx])
  4727. < # list attached
  4728. < COMPREPLY=( $( command screen -ls | \
  4729. < sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*Attached.*$|\1|p' ) )
  4730. < ;;
  4731. < -s)
  4732. < # shells
  4733. < COMPREPLY=( $( grep ^${cur:-[^#]} /etc/shells ) )
  4734. < ;;
  4735. < *)
  4736. < ;;
  4737. < esac
  4738. < fi
  4739. <
  4740. < return 0
  4741. < } &&
  4742. < complete -F _screen $default screen
  4743. <
  4744. < # lftp(1) bookmark completion
  4745. < #
  4746. < have lftp &&
  4747. < _lftp()
  4748. < {
  4749. < local cur
  4750. <
  4751. < COMPREPLY=()
  4752. < cur=`_get_cword`
  4753. <
  4754. < if [ $COMP_CWORD -eq 1 ] && [ -f ~/.lftp/bookmarks ]; then
  4755. < COMPREPLY=( $( compgen -W '$( sed -ne "s/^\(.*\)'$'\t''.*$/\1/p" \
  4756. < ~/.lftp/bookmarks )' -- $cur ) )
  4757. < fi
  4758. <
  4759. < return 0
  4760. < } &&
  4761. < complete -F _lftp $default lftp
  4762. <
  4763. < # ncftp(1) bookmark completion
  4764. < #
  4765. < have ncftp &&
  4766. < _ncftp()
  4767. < {
  4768. < local cur
  4769. <
  4770. < COMPREPLY=()
  4771. < cur=`_get_cword`
  4772. <
  4773. < if [ $COMP_CWORD -eq 1 ] && [ -f ~/.ncftp/bookmarks ]; then
  4774. < COMPREPLY=( $( compgen -W '$( sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \
  4775. < ~/.ncftp/bookmarks )' -- $cur ) )
  4776. < fi
  4777. <
  4778. < return 0
  4779. < } &&
  4780. < complete -F _ncftp $default ncftp
  4781. <
  4782. < # gdb(1) completion
  4783. < #
  4784. < have gdb &&
  4785. < _gdb()
  4786. < {
  4787. < local cur prev
  4788. <
  4789. < COMPREPLY=()
  4790. < cur=`_get_cword`
  4791. < prev=${COMP_WORDS[COMP_CWORD-1]}
  4792. <
  4793. < if [ $COMP_CWORD -eq 1 ]; then
  4794. < COMPREPLY=( $( compgen -c -- $cur ) )
  4795. < elif [ $COMP_CWORD -eq 2 ]; then
  4796. < prev=${prev##*/}
  4797. < COMPREPLY=( $( compgen -fW "$( command ps axo comm,pid | \
  4798. < awk '{if ($1 ~ /^'"$prev"'/) print $2}' ) )" \
  4799. < -- "$cur" ) )
  4800. < fi
  4801. < } &&
  4802. < complete -F _gdb $filenames gdb
  4803. <
  4804. < # Postgresql completion
  4805. < #
  4806. < have psql && {
  4807. < _pg_databases()
  4808. < {
  4809. < COMPREPLY=( $( psql -l 2>/dev/null | \
  4810. < sed -e '1,/^-/d' -e '/^(/,$d' | \
  4811. < awk '{print $1}' | grep "^$cur" ) )
  4812. < }
  4813. <
  4814. < _pg_users()
  4815. < {
  4816. < COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
  4817. < grep "^ $cur" ) )
  4818. < [ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- $cur ) )
  4819. < }
  4820. <
  4821. < # createdb(1) completion
  4822. < #
  4823. < _createdb()
  4824. < {
  4825. < local cur prev
  4826. <
  4827. < COMPREPLY=()
  4828. < cur=`_get_cword`
  4829. < prev=${COMP_WORDS[COMP_CWORD-1]}
  4830. <
  4831. < case "$prev" in
  4832. < -@(h|-host=))
  4833. < _known_hosts
  4834. < return 0
  4835. < ;;
  4836. < -@(U|-username=))
  4837. < _pg_users
  4838. < return 0
  4839. < ;;
  4840. < esac
  4841. <
  4842. < if [[ "$cur" == -* ]]; then
  4843. < COMPREPLY=( $( compgen -W '-D -T -E -h -p -U -W -e -q \
  4844. < --location= --template= --encoding= --host= --port= \
  4845. < --username= --password --echo --quiet --help' -- $cur ))
  4846. < else
  4847. < _pg_databases
  4848. < fi
  4849. < }
  4850. < complete -F _createdb $default createdb
  4851. <
  4852. < # dropdb(1) completion
  4853. < #
  4854. < _dropdb()
  4855. < {
  4856. < local cur prev
  4857. <
  4858. < COMPREPLY=()
  4859. < cur=`_get_cword`
  4860. < prev=${COMP_WORDS[COMP_CWORD-1]}
  4861. <
  4862. < case "$prev" in
  4863. < -@(h|-host=))
  4864. < _known_hosts
  4865. < return 0
  4866. < ;;
  4867. < -@(U|-username=))
  4868. < _pg_users
  4869. < return 0
  4870. < ;;
  4871. < esac
  4872. <
  4873. < if [[ "$cur" == -* ]]; then
  4874. < COMPREPLY=( $( compgen -W '-h -p -U -W -e -q \
  4875. < --host= --port= --username= --password \
  4876. < --interactive --echo --quiet --help' -- $cur ) )
  4877. < else
  4878. < _pg_databases
  4879. < fi
  4880. < }
  4881. < complete -F _dropdb $default dropdb
  4882. <
  4883. < # psql(1) completion
  4884. < #
  4885. < _psql()
  4886. < {
  4887. < local cur prev
  4888. <
  4889. < COMPREPLY=()
  4890. < cur=`_get_cword`
  4891. < prev=${COMP_WORDS[COMP_CWORD-1]}
  4892. <
  4893. < case "$prev" in
  4894. < -h|--host)
  4895. < _known_hosts
  4896. < return 0
  4897. < ;;
  4898. < -U|--username)
  4899. < _pg_users
  4900. < return 0
  4901. < ;;
  4902. < -d|--dbname)
  4903. < _pg_databases
  4904. < return 0
  4905. < ;;
  4906. < -@(o|f)|--output|--file)
  4907. < _filedir
  4908. < return 0
  4909. < ;;
  4910. < esac
  4911. <
  4912. < if [[ "$cur" == -* ]]; then
  4913. < # return list of available options
  4914. < COMPREPLY=( $( compgen -W '-a --echo-all -A --no-align \
  4915. < -c --command -d --dbname -e --echo-queries \
  4916. < -E --echo-hidden -f --file -F --filed-separator \
  4917. < -h --host -H --html -l --list -n -o --output \
  4918. < -p --port -P --pset -q -R --record-separator \
  4919. < -s --single-step -S --single-line -t --tuples-only \
  4920. < -T --table-attr -U --username -v --variable \
  4921. < -V --version -W --password -x --expanded -X --nopsqlrc \
  4922. < -? --help ' -- $cur ) )
  4923. < else
  4924. < # return list of available databases
  4925. < _pg_databases
  4926. < fi
  4927. < }
  4928. < complete -F _psql $default psql
  4929. ---
  4930. > COMPREPLY=( "${COMPREPLY[@]}"
  4931. > $( compgen -f -d -X "!*/?(r)dvd*" -- "${cur:-/dev/}" ) )
  4932. 4135,4137c1126
  4933. < _longopt()
  4934. < {
  4935. < local cur opt
  4936. ---
  4937. > # start of section containing completion functions for external programs
  4938. 4139c1128,1131
  4939. < cur=`_get_cword`
  4940. ---
  4941. > # a little help for FreeBSD ports users
  4942. > [ $UNAME = FreeBSD ] && complete -W 'index search fetch fetch-list extract \
  4943. > patch configure build install reinstall deinstall clean clean-depends \
  4944. > kernel buildworld' make
  4945. 4141,4169c1133,1136
  4946. < if [[ "$cur" == --*=* ]]; then
  4947. < opt=${cur%%=*}
  4948. < # cut backslash that gets inserted before '=' sign
  4949. < opt=${opt%\\*}
  4950. < cur=${cur#*=}
  4951. < _filedir
  4952. < COMPREPLY=( $( compgen -P "$opt=" -W '${COMPREPLY[@]}' -- $cur))
  4953. < return 0
  4954. < fi
  4955. <
  4956. < if [[ "$cur" == -* ]]; then
  4957. < COMPREPLY=( $( $1 --help 2>&1 | sed -e '/--/!d' \
  4958. < -e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | \
  4959. < command grep "^$cur" | sort -u ) )
  4960. < elif [[ "$1" == @(mk|rm)dir ]]; then
  4961. < _filedir -d
  4962. < else
  4963. < _filedir
  4964. < fi
  4965. < }
  4966. < # makeinfo and texi2dvi are defined elsewhere.
  4967. < for i in a2ps autoconf automake bc gprof ld nm objcopy objdump readelf strip \
  4968. < bison cpio diff patch enscript cp df dir du ln ls mkfifo mknod mv rm \
  4969. < touch vdir awk gperf grep grub indent less m4 sed shar date \
  4970. < tee who texindex cat csplit cut expand fmt fold head \
  4971. < md5sum nl od paste pr ptx sha1sum sort split tac tail tr unexpand \
  4972. < uniq wc ldd bash id irb mkdir rmdir; do
  4973. < have $i && complete -F _longopt $filenames $i
  4974. < done
  4975. ---
  4976. > # This function provides simple user@host completion
  4977. > #
  4978. > _user_at_host() {
  4979. > local cur
  4980. 4171,4175c1138,1139
  4981. < # These commands use filenames, so '-o filenames' is not needed.
  4982. < for i in env netstat seq uname units wget; do
  4983. < have $i && complete -F _longopt $default $i
  4984. < done
  4985. < unset i
  4986. ---
  4987. > COMPREPLY=()
  4988. > _get_comp_words_by_ref -n : cur
  4989. 4177,5215c1141,1147
  4990. < # gcc(1) completion
  4991. < #
  4992. < # The only unusual feature is that we don't parse "gcc --help -v" output
  4993. < # directly, because that would include the options of all the other backend
  4994. < # tools (linker, assembler, preprocessor, etc) without any indication that
  4995. < # you cannot feed such options to the gcc driver directly. (For example, the
  4996. < # linker takes a -z option, but you must type -Wl,-z for gcc.) Instead, we
  4997. < # ask the driver ("g++") for the name of the compiler ("cc1"), and parse the
  4998. < # --help output of the compiler.
  4999. < #
  5000. < have gcc &&
  5001. < _gcc()
  5002. < {
  5003. < local cur cc backend
  5004. <
  5005. < COMPREPLY=()
  5006. < cur=`_get_cword`
  5007. <
  5008. < _expand || return 0
  5009. <
  5010. < case "$1" in
  5011. < gcj)
  5012. < backend=jc1
  5013. < ;;
  5014. < gpc)
  5015. < backend=gpc1
  5016. < ;;
  5017. < *77)
  5018. < backend=f771
  5019. < ;;
  5020. < *)
  5021. < backend=cc1 # (near-)universal backend
  5022. < ;;
  5023. < esac
  5024. <
  5025. < if [[ "$cur" == -* ]]; then
  5026. < cc=$( $1 -print-prog-name=$backend )
  5027. < # sink stderr:
  5028. < # for C/C++/ObjectiveC it's useless
  5029. < # for FORTRAN/Java it's an error
  5030. < COMPREPLY=( $( $cc --help 2>/dev/null | tr '\t' ' ' | \
  5031. < sed -e '/^ *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | \
  5032. < command grep "^$cur" | sort -u ) )
  5033. < else
  5034. < _filedir
  5035. < fi
  5036. < } &&
  5037. < complete $filenames -F _gcc gcc g++ c++ g77 gcj gpc
  5038. < [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Cygwin ] && \
  5039. < [ -n "${have:-}" ] && complete $filenames -F _gcc cc
  5040. <
  5041. < # Linux cardctl(8) completion
  5042. < #
  5043. < have cardctl &&
  5044. < _cardctl()
  5045. < {
  5046. < local cur
  5047. <
  5048. < COMPREPLY=()
  5049. < cur=`_get_cword`
  5050. <
  5051. < if [ $COMP_CWORD -eq 1 ]; then
  5052. < COMPREPLY=( $( compgen -W 'status config ident suspend \
  5053. < resume reset eject insert scheme' \
  5054. < -- $cur ) )
  5055. < fi
  5056. < } &&
  5057. < complete -F _cardctl cardctl
  5058. <
  5059. < # This function is required by _dpkg() and _dpkg-reconfigure()
  5060. < #
  5061. < have dpkg && {
  5062. < _comp_dpkg_installed_packages()
  5063. < {
  5064. < grep -A 1 "Package: $1" /var/lib/dpkg/status | \
  5065. < grep -B 1 -E "ok installed|half-installed|unpacked| \
  5066. < half-configured|config-files" | \
  5067. < grep "Package: $1" | cut -d\ -f2
  5068. < }
  5069. <
  5070. < # Debian dpkg(8) completion
  5071. < #
  5072. < _dpkg()
  5073. < {
  5074. < local cur prev i
  5075. <
  5076. < COMPREPLY=()
  5077. < cur=`_get_cword`
  5078. < prev=${COMP_WORDS[COMP_CWORD-1]}
  5079. < i=$COMP_CWORD
  5080. <
  5081. < _expand || return 0
  5082. <
  5083. < # find the last option flag
  5084. < if [[ $cur != -* ]]; then
  5085. < while [[ $prev != -* && $i != 1 ]]; do
  5086. < i=$((i-1))
  5087. < prev=${COMP_WORDS[i-1]}
  5088. < done
  5089. < fi
  5090. <
  5091. < case "$prev" in
  5092. < -@(c|i|A|I|f|e|x|X|-@(install|unpack|record-avail|contents|info| \
  5093. < fsys-tarfile|field|control|extract)))
  5094. < _filedir '?(u)deb'
  5095. < return 0
  5096. < ;;
  5097. < -@(b|-build))
  5098. < _filedir -d
  5099. < return 0
  5100. < ;;
  5101. < -@(s|p|l|-@(status|print-avail|list)))
  5102. < COMPREPLY=( $( apt-cache pkgnames $cur 2>/dev/null ) )
  5103. < return 0
  5104. < ;;
  5105. < -@(S|-search))
  5106. < _filedir
  5107. < return 0
  5108. < ;;
  5109. < -@(r|L|P|-@(remove|purge|listfiles)))
  5110. < COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
  5111. < return 0
  5112. < ;;
  5113. < *)
  5114. <
  5115. < COMPREPLY=( $( compgen -W '-i --install --unpack -A --record-avail \
  5116. < --configure -r --remove -P --purge --get-selections \
  5117. < --set-selections --update-avail --merge-avail \
  5118. < --clear-avail --command-fd --forget-old-unavail -s \
  5119. < --status -p --print-avail -L --listfiles -l --list \
  5120. < -S --search -C --audit --print-architecture \
  5121. < --print-gnu-build-architecture \
  5122. < --print-installation-architecture \
  5123. < --compare-versions --help --version --force-help \
  5124. < --force-all --force-auto-select --force-downgrade \
  5125. < --force-configure-any --force-hold --force-bad-path \
  5126. < --force-not-root --force-overwrite \
  5127. < --force-overwrite-diverted --force-bad-verify \
  5128. < --force-depends-version --force-depends \
  5129. < --force-confnew --force-confold --force-confdef \
  5130. < --force-confmiss --force-conflicts --force-architecture\
  5131. < --force-overwrite-dir --force-remove-reinstreq \
  5132. < --force-remove-essential -Dh \
  5133. < --debug=help --licence --admindir= --root= --instdir= \
  5134. < -O --selected-only -E --skip-same-version \
  5135. < -G --refuse-downgrade -B --auto-deconfigure \
  5136. < --no-debsig --no-act -D --debug= --status-fd \
  5137. < -b --build -I --info -f --field -c --contents \
  5138. < -x --extract -X --vextract --fsys-tarfile -e --control \
  5139. < --ignore-depends= --abort-after' -- $cur ) )
  5140. < ;;
  5141. < esac
  5142. <
  5143. <
  5144. < }
  5145. < complete -F _dpkg $filenames dpkg dpkg-deb
  5146. < }
  5147. <
  5148. < # Debian GNU dpkg-reconfigure(8) completion
  5149. < #
  5150. < have dpkg-reconfigure &&
  5151. < _dpkg_reconfigure()
  5152. < {
  5153. < local cur prev opt
  5154. <
  5155. < COMPREPLY=()
  5156. < cur=`_get_cword`
  5157. < prev=${COMP_WORDS[COMP_CWORD-1]}
  5158. <
  5159. <
  5160. < case "$prev" in
  5161. < -@(f|-frontend))
  5162. < opt=( $( echo /usr/share/perl5/Debconf/FrontEnd/* ) )
  5163. < opt=( ${opt[@]##*/} )
  5164. < opt=( ${opt[@]%.pm} )
  5165. < COMPREPLY=( $( compgen -W '${opt[@]}' -- $cur ) )
  5166. < return 0
  5167. < ;;
  5168. < -@(p|-priority))
  5169. < COMPREPLY=( $( compgen -W 'low medium high critical' -- $cur ) )
  5170. < return 0
  5171. < ;;
  5172. < esac
  5173. <
  5174. < if [[ "$cur" == -* ]]; then
  5175. < COMPREPLY=( $( compgen -W '-f --frontend -p --priority -a --all \
  5176. < -u --unseen-only -h --help -s --showold \
  5177. < --force --terse' -- $cur ) )
  5178. < else
  5179. < COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
  5180. < fi
  5181. < } &&
  5182. < complete -F _dpkg_reconfigure $default dpkg-reconfigure
  5183. <
  5184. < # Debian dpkg-source completion
  5185. < #
  5186. < have dpkg-source &&
  5187. < _dpkg_source()
  5188. < {
  5189. < local cur prev options work i action packopts unpackopts
  5190. <
  5191. < packopts="-c -l -F -V -T -D -U -W -E -sa -i -I -sk -sp -su -sr -ss -sn -sA -sK -sP -sU -sR"
  5192. < unpackopts="-sp -sn -su"
  5193. < options=`echo "-x -b $packopts $unpackopts" | xargs echo | sort -u | xargs echo`
  5194. <
  5195. < COMPREPLY=()
  5196. < if [ "$1" != "dpkg-source" ]; then
  5197. < exit 1
  5198. < fi
  5199. < cur=`_get_cword`
  5200. < prev=${COMP_WORDS[COMP_CWORD-1]}
  5201. < action="options"
  5202. < for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
  5203. < if [[ ${COMP_WORDS[$i]} == "-x" ]]; then
  5204. < action=unpack
  5205. < elif [[ ${COMP_WORDS[$i]} == "-b" ]]; then
  5206. < action=pack
  5207. < elif [[ ${COMP_WORDS[$i]} == "-h" ]]; then
  5208. < action=help
  5209. < fi
  5210. < done
  5211. < # if currently seeing a complete option, return just itself.
  5212. < for i in $options; do
  5213. < if [ "$cur" = "$i" ]; then
  5214. < COMPREPLY=( "$cur" )
  5215. < return 0
  5216. < fi
  5217. < done
  5218. < case "$action" in
  5219. < "unpack")
  5220. < if [ "$cur" = "-" -o "$cur" = "-s" ]; then
  5221. < COMPREPLY=( $unpackots )
  5222. < return 0
  5223. < fi
  5224. < case "$prev" in
  5225. < "-x")
  5226. < COMPREPLY=( $( compgen -d -- "$cur" ) \
  5227. < $( compgen -f -X '!*.dsc' -- "$cur" ) )
  5228. < return 0
  5229. < ;;
  5230. < *)
  5231. < COMPREPLY=( $unpackopts $(compgen -d -f -- "$cur" ) )
  5232. < return 0
  5233. < ;;
  5234. < esac
  5235. < return 0
  5236. < ;;
  5237. < "pack")
  5238. < if [ "$cur" = "-" ]; then
  5239. < COMPREPLY=( $packopts )
  5240. < return 0
  5241. < fi
  5242. < if [ "$cur" = "-s" ]; then
  5243. < COMPREPLY=( "-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" \
  5244. < "-sA" "-sK" "-sP" "-sU" "-sR" )
  5245. < return 0
  5246. < fi
  5247. < case "$prev" in
  5248. < "-b")
  5249. < COMPREPLY=( $( compgen -d -- "$cur" ) )
  5250. < return 0
  5251. < ;;
  5252. < "-c"|"-l"|"-T"|"-i"|"-I")
  5253. < # -c: get controlfile
  5254. < # -l: get per-version info from this file
  5255. < # -T: read variables here, not debian/substvars
  5256. < # -i: <regexp> filter out files to ignore diffs of.
  5257. < # -I: filter out files when building tarballs.
  5258. < # return directory names and file names
  5259. < COMPREPLY=( $( compgen -d -f ) )
  5260. < return 0
  5261. < ;;
  5262. < "-F")
  5263. < # -F: force change log format
  5264. < COMPREPLY=( $( ( cd /usr/lib/dpkg/parsechangelog; compgen -f "$cur" ) ) )
  5265. < return 0
  5266. < ;;
  5267. < "-V"|"-D")
  5268. < # -V: set a substitution variable
  5269. < # we don't know anything about possible variables or values
  5270. < # so we don't try to suggest any completion.
  5271. < COMPREPLY=()
  5272. < return 0
  5273. < ;;
  5274. < "-D")
  5275. < # -D: override or add a .dsc field and value
  5276. < # if $cur doesn't contain a = yet, suggest variable names
  5277. < if echo -- "$cur" | grep -q "="; then
  5278. < # $cur contains a "="
  5279. < COMPREPLY=()
  5280. < return 0
  5281. < else
  5282. < COMPREPLY=( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files )
  5283. < return 0
  5284. < fi
  5285. < ;;
  5286. < "-U")
  5287. < # -U: remove a field
  5288. < # Suggest possible fieldnames
  5289. < COMPREPLY=( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files )
  5290. < return 0
  5291. < ;;
  5292. < *)
  5293. < COMPREPLY=( $packopts )
  5294. < return 0
  5295. < ;;
  5296. < esac
  5297. < return 0
  5298. < ;;
  5299. < *)
  5300. < # if seeing a partial option, return possible completions.
  5301. < if [ "$cur" = "-s" ]; then
  5302. < COMPREPLY=( "-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" \
  5303. < "-sA" "-sK" "-sP" "-sU" "-sR" )
  5304. < return 0
  5305. < fi
  5306. < # else return all possible options.
  5307. < COMPREPLY=( $options )
  5308. < return 0
  5309. < ;;
  5310. < esac
  5311. < } &&
  5312. < complete -F _dpkg_source dpkg-source
  5313. <
  5314. < # Debian Linux dselect(8) completion.
  5315. < #
  5316. < have dselect &&
  5317. < _dselect()
  5318. < {
  5319. < local cur prev
  5320. <
  5321. < COMPREPLY=()
  5322. < cur=`_get_cword`
  5323. < prev=${COMP_WORDS[COMP_CWORD-1]}
  5324. <
  5325. < case "$prev" in
  5326. < --admindir)
  5327. < _filedir -d
  5328. < return 0
  5329. < ;;
  5330. <
  5331. < -@(D|debug))
  5332. < _filedir
  5333. < return 0
  5334. < ;;
  5335. < esac
  5336. <
  5337. < if [[ "$cur" == -* ]]; then
  5338. < COMPREPLY=( $( compgen -W '--admindir --help --version --licence \
  5339. < --license --expert --debug' -- $cur ) )
  5340. < else
  5341. < COMPREPLY=( $( compgen -W 'access update select install config \
  5342. < remove quit' -- $cur ) )
  5343. < fi
  5344. <
  5345. <
  5346. < return 0
  5347. < } &&
  5348. < complete -F _dselect $filenames dselect
  5349. <
  5350. < # Java completion
  5351. < #
  5352. <
  5353. < # available path elements completion
  5354. < have java && {
  5355. < _java_path()
  5356. < {
  5357. < cur=${cur##*:}
  5358. < _filedir '@(jar|zip)'
  5359. < }
  5360. <
  5361. < # exact classpath determination
  5362. < _java_find_classpath()
  5363. < {
  5364. < local i
  5365. <
  5366. < # search first in current options
  5367. < for (( i=1; i < COMP_CWORD; i++ )); do
  5368. < if [[ "${COMP_WORDS[i]}" == -@(cp|classpath) ]]; then
  5369. < classpath=${COMP_WORDS[i+1]}
  5370. < break
  5371. < fi
  5372. < done
  5373. <
  5374. < # default to environment
  5375. < [ -z "$classpath" ] && classpath=$CLASSPATH
  5376. <
  5377. < # default to current directory
  5378. < [ -z "$classpath" ] && classpath=.
  5379. < }
  5380. <
  5381. < # exact sourcepath determination
  5382. < _java_find_sourcepath()
  5383. < {
  5384. < local i
  5385. <
  5386. < # search first in current options
  5387. < for (( i=1; i < COMP_CWORD; i++ )); do
  5388. < if [[ "${COMP_WORDS[i]}" == -sourcepath ]]; then
  5389. < sourcepath=${COMP_WORDS[i+1]}
  5390. < break
  5391. < fi
  5392. < done
  5393. <
  5394. < # default to classpath
  5395. < [ -z "$sourcepath" ] && _java_find_classpath
  5396. < sourcepath=$classpath
  5397. < }
  5398. <
  5399. < # available classes completion
  5400. < _java_classes()
  5401. < {
  5402. < local classpath i
  5403. <
  5404. < # find which classpath to use
  5405. < _java_find_classpath
  5406. <
  5407. < # convert package syntax to path syntax
  5408. < cur=${cur//.//}
  5409. < # parse each classpath element for classes
  5410. < for i in ${classpath//:/ }; do
  5411. < if [ -r $i ] && [[ "$i" == *.@(jar|zip) ]]; then
  5412. < if type zipinfo &> /dev/null; then
  5413. < COMPREPLY=( ${COMPREPLY[@]} $( zipinfo -1 \
  5414. < "$i" | grep "^$cur" | grep '\.class$' | \
  5415. < grep -v "\\$" ) )
  5416. < else
  5417. < COMPREPLY=( ${COMPREPLY[@]} $( jar tf "$i" \
  5418. < "$cur" | grep "\.class$" | grep -v "\\$" ) )
  5419. < fi
  5420. <
  5421. < elif [ -d $i ]; then
  5422. < i=${i%/}
  5423. < COMPREPLY=( ${COMPREPLY[@]} $( find "$i" -type f \
  5424. < -path "$i/$cur*.class" 2>/dev/null | \
  5425. < grep -v "\\$" | sed -e "s|^$i/||" ) )
  5426. < fi
  5427. < done
  5428. <
  5429. < # remove class extension
  5430. < COMPREPLY=( ${COMPREPLY[@]%.class} )
  5431. < # convert path syntax to package syntax
  5432. < COMPREPLY=( ${COMPREPLY[@]//\//.} )
  5433. < }
  5434. <
  5435. < # available packages completion
  5436. < _java_packages()
  5437. < {
  5438. < local sourcepath i
  5439. <
  5440. < # find wich sourcepath to use
  5441. < _java_find_sourcepath
  5442. <
  5443. < # convert package syntax to path syntax
  5444. < cur=${cur//.//}
  5445. < # parse each sourcepath element for packages
  5446. < for i in ${sourcepath//:/ }; do
  5447. < if [ -d $i ]; then
  5448. < COMPREPLY=( ${COMPREPLY[@]} $( command ls -F -d \
  5449. < $i/$cur* 2>/dev/null | sed -e 's|^'$i'/||' ) )
  5450. < fi
  5451. < done
  5452. < # keep only packages
  5453. < COMPREPLY=( $( echo ${COMPREPLY[@]} | tr " " "\n" | grep "/$" ) )
  5454. < # remove packages extension
  5455. < COMPREPLY=( ${COMPREPLY[@]%/} )
  5456. < # convert path syntax to package syntax
  5457. < cur=${COMPREPLY[@]//\//.}
  5458. < }
  5459. <
  5460. < # java completion
  5461. < #
  5462. < _java()
  5463. < {
  5464. < local cur prev i
  5465. <
  5466. < COMPREPLY=()
  5467. < cur=`_get_cword`
  5468. < prev=${COMP_WORDS[COMP_CWORD-1]}
  5469. <
  5470. < for ((i=1; i < $COMP_CWORD; i++)); do
  5471. < case ${COMP_WORDS[$i]} in
  5472. < -cp|-classpath)
  5473. < ((i++)) # skip the classpath string.
  5474. < ;;
  5475. < -*)
  5476. < # this is an option, not a class/jarfile name.
  5477. < ;;
  5478. < *)
  5479. < # once we've seen a class, just do filename completion
  5480. < _filedir
  5481. < return 0
  5482. < ;;
  5483. < esac
  5484. < done
  5485. <
  5486. < case $prev in
  5487. < -@(cp|classpath))
  5488. < _java_path
  5489. < return 0
  5490. < ;;
  5491. < esac
  5492. <
  5493. < if [[ "$cur" == -* ]]; then
  5494. < # relevant options completion
  5495. < COMPREPLY=( $( compgen -W '-client -hotspot -server -classic \
  5496. < -cp -classpath -D -verbose -verbose:class \
  5497. < -verbose:gc -version:jni -version \
  5498. < -showversion -? -help -X -jar \
  5499. < -ea -enableassertions -da -disableassertions \
  5500. < -esa -enablesystemassertions \
  5501. < -dsa -disablesystemassertions ' -- $cur ) )
  5502. < else
  5503. < if [[ "$prev" == -jar ]]; then
  5504. < # jar file completion
  5505. < _filedir jar
  5506. < else
  5507. < # classes completion
  5508. < _java_classes
  5509. < fi
  5510. < fi
  5511. < }
  5512. < complete -F _java $filenames java
  5513. < }
  5514. <
  5515. < # javadoc completion
  5516. < #
  5517. < have javadoc &&
  5518. < _javadoc()
  5519. < {
  5520. < COMPREPLY=()
  5521. < local cur prev
  5522. <
  5523. < cur=`_get_cword`
  5524. < prev=${COMP_WORDS[COMP_CWORD-1]}
  5525. <
  5526. < case $prev in
  5527. < -@(overview|helpfile|stylesheetfile))
  5528. < _filedir
  5529. < return 0
  5530. < ;;
  5531. < -d)
  5532. < _filedir -d
  5533. < return 0
  5534. < ;;
  5535. < -@(classpath|bootclasspath|docletpath|sourcepath|extdirs))
  5536. < _java_path
  5537. < return 0
  5538. < ;;
  5539. < esac
  5540. <
  5541. < if [[ "$cur" == -* ]]; then
  5542. < # relevant options completion
  5543. < COMPREPLY=( $( compgen -W '-overview -public -protected \
  5544. < -package -private -help -doclet -docletpath \
  5545. < -sourcepath -classpath -exclude -subpackages \
  5546. < -breakiterator -bootclasspath -source -extdirs \
  5547. < -verbose -locale -encoding -J -d -use -version \
  5548. < -author -docfilessubdirs -splitindex \
  5549. < -windowtitle -doctitle -header -footer -bottom \
  5550. < -link -linkoffline -excludedocfilessubdir \
  5551. < -group -nocomment -nodeprecated -noqualifier \
  5552. < -nosince -nodeprecatedlist -notree -noindex \
  5553. < -nohelp -nonavbar -quiet -serialwarn -tag \
  5554. < -taglet -tagletpath -charset -helpfile \
  5555. < -linksource -stylesheetfile -docencoding' -- \
  5556. < $cur ) )
  5557. < else
  5558. < # source files completion
  5559. < _filedir java
  5560. < # packages completion
  5561. < _java_packages
  5562. < fi
  5563. < } &&
  5564. < complete -F _javadoc $filenames javadoc
  5565. <
  5566. < # javac completion
  5567. < #
  5568. < have javac &&
  5569. < _javac()
  5570. < {
  5571. < COMPREPLY=()
  5572. < local cur prev
  5573. <
  5574. < cur=`_get_cword`
  5575. < prev=${COMP_WORDS[COMP_CWORD-1]}
  5576. <
  5577. < case $prev in
  5578. < -d)
  5579. < _filedir -d
  5580. < return 0
  5581. < ;;
  5582. < -@(classpath|bootclasspath|sourcepath|extdirs))
  5583. < _java_path
  5584. < return 0
  5585. < ;;
  5586. < esac
  5587. <
  5588. < if [[ "$cur" == -* ]]; then
  5589. < # relevant options completion
  5590. < COMPREPLY=( $( compgen -W '-g -g:none -g:lines -g:vars\
  5591. < -g:source -O -nowarn -verbose -deprecation -classpath\
  5592. < -sourcepath -bootclasspath -extdirs -d -encoding -source\
  5593. < -target -help' -- $cur ) )
  5594. < else
  5595. < # source files completion
  5596. < _filedir java
  5597. < fi
  5598. < } &&
  5599. < complete -F _javac $filenames javac
  5600. <
  5601. < # PINE address-book completion
  5602. < #
  5603. < have pine &&
  5604. < _pineaddr()
  5605. < {
  5606. < local cur
  5607. <
  5608. < COMPREPLY=()
  5609. < cur=`_get_cword`
  5610. <
  5611. < COMPREPLY=( $( compgen -W '$( awk "{print \$1}" ~/.addressbook 2>/dev/null)' \
  5612. < -- $cur ) )
  5613. < } &&
  5614. < complete -F _pineaddr $default pine
  5615. <
  5616. < # mutt completion
  5617. < #
  5618. < # Mutt doesn't have an "addressbook" like Pine, but it has aliases and
  5619. < # a "query" function to retrieve addresses, so that's what we use here.
  5620. < have mutt || have muttng && {
  5621. < _muttaddr()
  5622. < {
  5623. < _muttaliases
  5624. < _muttquery
  5625. < return 0
  5626. < }
  5627. <
  5628. < _muttconffiles()
  5629. < {
  5630. < local file sofar
  5631. < local -a newconffiles
  5632. <
  5633. < sofar=" $1 "
  5634. < shift
  5635. < while [[ "$1" ]]; do
  5636. < newconffiles=( $(sed -rn 's|^source[[:space:]]+([^[:space:]]+).*$|\1|p' $(eval echo $1) ) )
  5637. < for file in ${newconffiles[@]}; do
  5638. < [[ ! "$file" ]] || [[ "${sofar/ ${file} / }" != "$sofar" ]] &&
  5639. < continue
  5640. < sofar="$sofar $file"
  5641. < sofar=" $(eval _muttconffiles \"$sofar\" $file) "
  5642. < done
  5643. < shift
  5644. < done
  5645. < echo $sofar
  5646. < }
  5647. <
  5648. < _muttaliases()
  5649. < {
  5650. < local cur muttrc
  5651. < local -a conffiles aliases
  5652. < cur=`_get_cword`
  5653. <
  5654. < [ -f ~/.${muttcmd}/${muttcmd}rc ] && muttrc="~/.${muttcmd}/${muttcmd}rc"
  5655. < [ -f ~/.${muttcmd}rc ] && muttrc="~/.${muttcmd}rc"
  5656. < [ -z "$muttrc" ] && return 0
  5657. <
  5658. < conffiles=( $(eval _muttconffiles $muttrc $muttrc) )
  5659. < aliases=( $( sed -rn 's|^alias[[:space:]]+([^[:space:]]+).*$|\1|p' \
  5660. < $(eval echo ${conffiles[@]}) ) )
  5661. < COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "${aliases[*]}" -- $cur ) )
  5662. <
  5663. < return 0
  5664. < }
  5665. <
  5666. < _muttquery()
  5667. < {
  5668. < local cur querycmd
  5669. < local -a queryresults
  5670. < cur=`_get_cword`
  5671. <
  5672. < querycmd="$( $muttcmd -Q query_command | sed -r 's|^query_command=\"(.*)\"$|\1|; s|%s|'$cur'|' )"
  5673. < if [ -z "$cur" -o -z "$querycmd" ]; then
  5674. < queryresults=()
  5675. < else
  5676. < queryresults=( $( $querycmd | \
  5677. < sed -nr '2,$s|^([^[:space:]]+).*|\1|p' ) )
  5678. < fi
  5679. <
  5680. < COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "${queryresults[*]}" \
  5681. < -- $cur ) )
  5682. <
  5683. < return 0
  5684. < }
  5685. <
  5686. < _muttfiledir()
  5687. < {
  5688. < local cur folder spoolfile
  5689. < cur=`_get_cword`
  5690. <
  5691. < # This is currently not working so well. Perhaps this function should
  5692. < # just call _filedir() for the moment.
  5693. < if [[ $cur == [=+]* ]]; then
  5694. < folder="$( $muttcmd -Q folder | sed -r 's|^folder=\"(.*)\"$|\1|' )"
  5695. < : folder:=~/Mail
  5696. <
  5697. < # Match any file in $folder beginning with $cur
  5698. < # (minus the leading '=' sign).
  5699. < COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) )
  5700. < COMPREPLY=( ${COMPREPLY[@]#$folder/} )
  5701. < return 0
  5702. < elif [ "$cur" == !* ]; then
  5703. < spoolfile="$( $muttcmd -Q spoolfile | sed -r 's|^spoolfile=\"(.*)\"$|\1|' )"
  5704. < [ ! -z "$spoolfile" ] && eval cur="${cur/^!/$spoolfile}";
  5705. < fi
  5706. < _filedir
  5707. <
  5708. < return 0
  5709. < }
  5710. <
  5711. < _mutt()
  5712. < {
  5713. < local cur prev
  5714. < cur=`_get_cword`
  5715. < prev=${COMP_WORDS[COMP_CWORD-1]}
  5716. <
  5717. < COMPREPLY=()
  5718. <
  5719. < [ ${COMP_WORDS[0]} == muttng ] && muttcmd="muttng" || muttcmd="mutt"
  5720. <
  5721. < case "$cur" in
  5722. < -*)
  5723. < COMPREPLY=( $( compgen -W '-A -a -b -c -e -f -F -H -i -m -n \
  5724. < -p -Q -R -s -v -x -y -z -Z -h' \
  5725. < -- $cur ) )
  5726. < return 0
  5727. < ;;
  5728. < *)
  5729. < case "$prev" in
  5730. < -@(a|f|F|H|i))
  5731. < _muttfiledir
  5732. < return 0
  5733. < ;;
  5734. < -A)
  5735. < _muttaliases
  5736. < return 0
  5737. < ;;
  5738. < -@(e|m|Q|s|h|p|R|v|y|z|Z))
  5739. < return 0
  5740. < ;;
  5741. < *)
  5742. < _muttaddr
  5743. < return 0
  5744. < ;;
  5745. < esac
  5746. < ;;
  5747. < esac
  5748. <
  5749. < }
  5750. < complete -F _mutt $default $filenames mutt muttng
  5751. < }
  5752. <
  5753. < _configure_func()
  5754. < {
  5755. < local cur
  5756. <
  5757. < COMPREPLY=()
  5758. < cur=`_get_cword`
  5759. <
  5760. < # if $COMP_CONFIGURE_HINTS is not null, then completions of the form
  5761. < # --option=SETTING will include 'SETTING' as a contextual hint
  5762. < [[ "$cur" != -* ]] && return 0
  5763. <
  5764. < if [ -n "$COMP_CONFIGURE_HINTS" ]; then
  5765. < COMPREPLY=( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' | grep ^$cur ) )
  5766. <
  5767. < else
  5768. < COMPREPLY=( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,=].*//g' | grep ^$cur ) )
  5769. < fi
  5770. < }
  5771. < complete -F _configure_func $default configure
  5772. <
  5773. < # Debian reportbug(1) completion
  5774. < #
  5775. < have reportbug &&
  5776. < _reportbug()
  5777. < {
  5778. < local cur prev
  5779. <
  5780. < COMPREPLY=()
  5781. < cur=`_get_cword`
  5782. < prev=${COMP_WORDS[COMP_CWORD-1]}
  5783. <
  5784. < case "$prev" in
  5785. < -f|--filename|-i|--include|--mta|-o|--output)
  5786. < _filedir
  5787. < return 0
  5788. < ;;
  5789. < -B|--bts)
  5790. < COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \
  5791. < $cur ))
  5792. < return 0
  5793. < ;;
  5794. < -e|--editor|--mua)
  5795. < COMP_WORDS=(COMP_WORDS[0] $cur)
  5796. < COMP_CWORD=1
  5797. < _command
  5798. < return 0
  5799. < ;;
  5800. < --mode)
  5801. < COMPREPLY=( $( compgen -W "novice standard expert" -- $cur ) )
  5802. < return 0
  5803. < ;;
  5804. < -S|--severity)
  5805. < COMPREPLY=( $( compgen -W "grave serious important normal \
  5806. < minor wishlist" -- $cur ) )
  5807. < return 0
  5808. < ;;
  5809. < -u|--ui|--interface)
  5810. < COMPREPLY=( $( compgen -W "newt text gnome" -- $cur ) )
  5811. < return 0
  5812. < ;;
  5813. < -t|--type)
  5814. < COMPREPLY=( $( compgen -W "gnats debbugs" -- $cur ) )
  5815. < return 0
  5816. < ;;
  5817. < -T|--tags)
  5818. < COMPREPLY=( $( compgen -W "none patch security upstream sid \
  5819. < woody potato sarge fixed" -- $cur ))
  5820. < return 0
  5821. < ;;
  5822. < *)
  5823. < ;;
  5824. < esac
  5825. <
  5826. < COMPREPLY=($( compgen -W '-h --help -v --version -a --af -b \
  5827. < --no-query-bts --query-bts -B --bts -c --configure \
  5828. < --no-config-files --check-available -d --debug \
  5829. < --no-check-available -e --editor --email -f \
  5830. < --filename -g --gnupg -H --header -i --include -j \
  5831. < --justification -l --ldap --no-ldap -L --list-cc -m \
  5832. < --maintonly --mode --mua --mta --mutt -n --mh --nmh \
  5833. < -o --output -p --print -P --pgp --proxy --http_proxy\
  5834. < -q --quiet -Q --query-only --realname --report-quiet \
  5835. < --reply-to --replyto -s --subject -S --severity \
  5836. < --smtphost -t --type -T --tags --template -V -x \
  5837. < --no-cc --package-version -z --no-compress \
  5838. < --ui --interface -u \
  5839. < wnpp boot-floppies kernel-image' -- $cur ) \
  5840. < $( apt-cache pkgnames -- $cur 2> /dev/null ) )
  5841. < _filedir
  5842. < return 0
  5843. < } &&
  5844. < complete -F _reportbug $filenames reportbug
  5845. <
  5846. < # Debian querybts(1) completion
  5847. < #
  5848. < have querybts &&
  5849. < _querybts()
  5850. < {
  5851. < local cur prev
  5852. <
  5853. < COMPREPLY=()
  5854. < cur=`_get_cword`
  5855. < prev=${COMP_WORDS[COMP_CWORD-1]}
  5856. <
  5857. < case "$prev" in
  5858. < -B|--bts)
  5859. < COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \
  5860. < $cur ))
  5861. < return 0
  5862. < ;;
  5863. < -u|--ui|--interface)
  5864. < COMPREPLY=($( compgen -W "newt text gnome" -- $cur ))
  5865. < return 0
  5866. < ;;
  5867. < *)
  5868. < ;;
  5869. < esac
  5870. <
  5871. < COMPREPLY=($( compgen -W '-h --help -v --version -A --archive \
  5872. < -B --bts -l --ldap --no-ldap --proxy= --http_proxy= \
  5873. < -s --source -w --web -u --ui --interface \
  5874. < wnpp boot-floppies' -- $cur ) \
  5875. < $( apt-cache pkgnames -- $cur 2> /dev/null ) )
  5876. < } &&
  5877. < complete -F _querybts $filenames querybts
  5878. <
  5879. < # update-alternatives completion
  5880. < #
  5881. < have update-alternatives && {
  5882. < installed_alternatives()
  5883. < {
  5884. < local admindir
  5885. < # find the admin dir
  5886. < for i in alternatives dpkg/alternatives rpm/alternatives; do
  5887. < [ -d /var/lib/$i ] && admindir=/var/lib/$i && break
  5888. < done
  5889. < for (( i=1; i < COMP_CWORD; i++ )); do
  5890. < if [[ "${COMP_WORDS[i]}" == --admindir ]]; then
  5891. < admindir=${COMP_WORDS[i+1]}
  5892. < break
  5893. < fi
  5894. < done
  5895. < COMPREPLY=( $( command ls $admindir | grep "^$cur" ) )
  5896. < }
  5897. <
  5898. < _update_alternatives()
  5899. < {
  5900. < local cur prev mode args i
  5901. <
  5902. < COMPREPLY=()
  5903. < cur=`_get_cword`
  5904. < prev=${COMP_WORDS[COMP_CWORD-1]}
  5905. <
  5906. < case "$prev" in
  5907. < --@(altdir|admindir))
  5908. < _filedir -d
  5909. < return 0
  5910. < ;;
  5911. < --@(help|version))
  5912. < return 0
  5913. < ;;
  5914. < esac
  5915. <
  5916. < # find wich mode to use and how many real args used so far
  5917. < for (( i=1; i < COMP_CWORD; i++ )); do
  5918. < if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all) ]]; then
  5919. < mode=${COMP_WORDS[i]}
  5920. < args=$(($COMP_CWORD - i))
  5921. < break
  5922. < fi
  5923. < done
  5924. <
  5925. < case $mode in
  5926. < --install)
  5927. < case $args in
  5928. < 1)
  5929. < _filedir
  5930. < ;;
  5931. < 2)
  5932. < installed_alternatives
  5933. < ;;
  5934. < 3)
  5935. < _filedir
  5936. < ;;
  5937. < esac
  5938. < ;;
  5939. < --remove)
  5940. < case $args in
  5941. < 1)
  5942. < installed_alternatives
  5943. < ;;
  5944. < 2)
  5945. < _filedir
  5946. < ;;
  5947. < esac
  5948. < ;;
  5949. < --auto)
  5950. < installed_alternatives
  5951. < ;;
  5952. < --remove-all)
  5953. < installed_alternatives
  5954. < ;;
  5955. < --display)
  5956. < installed_alternatives
  5957. < ;;
  5958. < --config)
  5959. < installed_alternatives
  5960. < ;;
  5961. < *)
  5962. < COMPREPLY=( $( compgen -W '--verbose --quiet --help --version \
  5963. < --altdir --admindir' -- $cur ) \
  5964. < $( compgen -W '--install --remove --auto --display \
  5965. < --config' -- $cur ) )
  5966. < esac
  5967. < }
  5968. < complete -F _update_alternatives update-alternatives
  5969. < }
  5970. <
  5971. < # Python completion
  5972. < #
  5973. < have python &&
  5974. < _python()
  5975. < {
  5976. < local prev cur
  5977. <
  5978. < COMPREPLY=()
  5979. < cur=`_get_cword`
  5980. < prev=${COMP_WORDS[COMP_CWORD-1]##*/}
  5981. <
  5982. < case "$prev" in
  5983. < -Q)
  5984. < COMPREPLY=( $( compgen -W "old new warn warnall" -- $cur ) )
  5985. < return 0
  5986. < ;;
  5987. < -W)
  5988. < COMPREPLY=( $( compgen -W "ignore default all module once error" -- $cur ) )
  5989. < return 0
  5990. < ;;
  5991. < -c)
  5992. < _filedir '@(py|pyc|pyo)'
  5993. < return 0
  5994. < ;;
  5995. < !(python|-?))
  5996. < [[ ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]] && _filedir
  5997. < ;;
  5998. < esac
  5999. <
  6000. <
  6001. < # if '-c' is already given, complete all kind of files.
  6002. < for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
  6003. < if [[ ${COMP_WORDS[i]} == -c ]]; then
  6004. < _filedir
  6005. < fi
  6006. < done
  6007. <
  6008. <
  6009. < if [[ "$cur" != -* ]]; then
  6010. < _filedir '@(py|pyc|pyo)'
  6011. < else
  6012. < COMPREPLY=( $( compgen -W "- -d -E -h -i -O -Q -S -t -u \
  6013. < -U -v -V -W -x -c" -- $cur ) )
  6014. < fi
  6015. <
  6016. <
  6017. <
  6018. < return 0
  6019. < } &&
  6020. < complete -F _python $filenames python
  6021. <
  6022. < # Perl completion
  6023. < #
  6024. < have perl &&
  6025. < {
  6026. < _perlmodules()
  6027. < {
  6028. < 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 ) )
  6029. ---
  6030. > if [[ $cur == *@* ]]; then
  6031. > _known_hosts_real "$cur"
  6032. > else
  6033. > COMPREPLY=( $( compgen -u -- "$cur" ) )
  6034. > fi
  6035. >
  6036. > return 0
  6037. 5216a1149
  6038. > shopt -u hostcomplete && complete -F _user_at_host -o nospace talk ytalk finger
  6039. 5218c1151,1153
  6040. < _perl()
  6041. ---
  6042. > # NOTE: Using this function as a helper function is deprecated. Use
  6043. > # `_known_hosts_real' instead.
  6044. > _known_hosts()
  6045. 5220,5221c1155
  6046. < local cur prev prefix temp
  6047. <
  6048. ---
  6049. > local options
  6050. 5223,5232c1157,1209
  6051. < cur=`_get_cword`
  6052. < prev=${COMP_WORDS[COMP_CWORD-1]}
  6053. < prefix=""
  6054. <
  6055. < # completing an option (may or may not be separated by a space)
  6056. < if [[ "$cur" == -?* ]]; then
  6057. < temp=$cur
  6058. < prev=${temp:0:2}
  6059. < cur=${temp:2}
  6060. < prefix=$prev
  6061. ---
  6062. >
  6063. > # NOTE: Using `_known_hosts' as a helper function and passing options
  6064. > # to `_known_hosts' is deprecated: Use `_known_hosts_real' instead.
  6065. > [[ "$1" == -a || "$2" == -a ]] && options=-a
  6066. > [[ "$1" == -c || "$2" == -c ]] && options="$options -c"
  6067. > _known_hosts_real $options "$(_get_cword :)"
  6068. > } # _known_hosts()
  6069. >
  6070. > # Helper function for completing _known_hosts.
  6071. > # This function performs host completion based on ssh's config and known_hosts
  6072. > # files, as well as hostnames reported by avahi-browse. Also hosts from
  6073. > # HOSTFILE (compgen -A hostname) are added, unless
  6074. > # COMP_KNOWN_HOSTS_WITH_HOSTFILE is set to an empty value.
  6075. > # Usage: _known_hosts_real [OPTIONS] CWORD
  6076. > # Options: -a Use aliases
  6077. > # -c Use `:' suffix
  6078. > # -F configfile Use `configfile' for configuration settings
  6079. > # -p PREFIX Use PREFIX
  6080. > # Return: Completions, starting with CWORD, are added to COMPREPLY[]
  6081. > _known_hosts_real()
  6082. > {
  6083. > local configfile flag prefix
  6084. > local cur curd awkcur user suffix aliases i host
  6085. > local -a kh khd config
  6086. >
  6087. > local OPTIND=1
  6088. > while getopts "acF:p:" flag "$@"; do
  6089. > case $flag in
  6090. > a) aliases='yes' ;;
  6091. > c) suffix=':' ;;
  6092. > F) configfile=$OPTARG ;;
  6093. > p) prefix=$OPTARG ;;
  6094. > esac
  6095. > done
  6096. > [ $# -lt $OPTIND ] && echo "error: $FUNCNAME: missing mandatory argument CWORD"
  6097. > cur=${!OPTIND}; let "OPTIND += 1"
  6098. > [ $# -ge $OPTIND ] && echo "error: $FUNCNAME("$@"): unprocessed arguments:"\
  6099. > $(while [ $# -ge $OPTIND ]; do printf '%s\n' ${!OPTIND}; shift; done)
  6100. >
  6101. > [[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}
  6102. > kh=()
  6103. >
  6104. > # ssh config files
  6105. > if [ -n "$configfile" ]; then
  6106. > [ -r "$configfile" ] &&
  6107. > config=( "${config[@]}" "$configfile" )
  6108. > else
  6109. > [ -r /etc/ssh/ssh_config ] &&
  6110. > config=( "${config[@]}" "/etc/ssh/ssh_config" )
  6111. > [ -r "${HOME}/.ssh/config" ] &&
  6112. > config=( "${config[@]}" "${HOME}/.ssh/config" )
  6113. > [ -r "${HOME}/.ssh2/config" ] &&
  6114. > config=( "${config[@]}" "${HOME}/.ssh2/config" )
  6115. 5235,5250c1212,1228
  6116. < # only handle module completion for now
  6117. < case "$prev" in
  6118. < -I|-x)
  6119. < COMPREPLY=( $( compgen -d -P "$prev" -- "$cur" ) )
  6120. < return 0
  6121. < ;;
  6122. < -m|-M)
  6123. < _perlmodules
  6124. < return 0
  6125. < ;;
  6126. < esac
  6127. <
  6128. < # handle case where first parameter is not a dash option
  6129. < if [[ "${COMP_WORDS[COMP_CWORD]}" != -* ]]; then
  6130. < _filedir
  6131. < return 0
  6132. ---
  6133. > # Known hosts files from configs
  6134. > if [ ${#config[@]} -gt 0 ]; then
  6135. > local OIFS=$IFS IFS=$'\n'
  6136. > local -a tmpkh
  6137. > # expand paths (if present) to global and user known hosts files
  6138. > # TODO(?): try to make known hosts files with more than one consecutive
  6139. > # spaces in their name work (watch out for ~ expansion
  6140. > # breakage! Alioth#311595)
  6141. > tmpkh=( $( awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t]+", "") { print $0 }' "${config[@]}" | sort -u ) )
  6142. > for i in "${tmpkh[@]}"; do
  6143. > # Remove possible quotes
  6144. > i=${i//\"}
  6145. > # Eval/expand possible `~' or `~user'
  6146. > __expand_tilde_by_ref i
  6147. > [ -r "$i" ] && kh=( "${kh[@]}" "$i" )
  6148. > done
  6149. > IFS=$OIFS
  6150. 5253,5258c1231,1243
  6151. < # complete using basic options
  6152. < COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p \
  6153. < -n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) )
  6154. < return 0
  6155. < }
  6156. < complete -F _perl $filenames perl
  6157. ---
  6158. > # Global known_hosts files
  6159. > if [ -z "$configfile" ]; then
  6160. > [ -r /etc/ssh/ssh_known_hosts ] &&
  6161. > kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts )
  6162. > [ -r /etc/ssh/ssh_known_hosts2 ] &&
  6163. > kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts2 )
  6164. > [ -r /etc/known_hosts ] &&
  6165. > kh=( "${kh[@]}" /etc/known_hosts )
  6166. > [ -r /etc/known_hosts2 ] &&
  6167. > kh=( "${kh[@]}" /etc/known_hosts2 )
  6168. > [ -d /etc/ssh2/knownhosts ] &&
  6169. > khd=( "${khd[@]}" /etc/ssh2/knownhosts/*pub )
  6170. > fi
  6171. 5260,5262c1245,1253
  6172. < _perldoc()
  6173. < {
  6174. < local cur prev prefix temp
  6175. ---
  6176. > # User known_hosts files
  6177. > if [ -z "$configfile" ]; then
  6178. > [ -r ~/.ssh/known_hosts ] &&
  6179. > kh=( "${kh[@]}" ~/.ssh/known_hosts )
  6180. > [ -r ~/.ssh/known_hosts2 ] &&
  6181. > kh=( "${kh[@]}" ~/.ssh/known_hosts2 )
  6182. > [ -d ~/.ssh2/hostkeys ] &&
  6183. > khd=( "${khd[@]}" ~/.ssh2/hostkeys/*pub )
  6184. > fi
  6185. 5264,5274c1255,1303
  6186. < COMPREPLY=()
  6187. < cur=`_get_cword`
  6188. < prev=${COMP_WORDS[COMP_CWORD-1]}
  6189. < prefix=""
  6190. <
  6191. < # completing an option (may or may not be separated by a space)
  6192. < if [[ "$cur" == -?* ]]; then
  6193. < temp=$cur
  6194. < prev=${temp:0:2}
  6195. < cur=${temp:2}
  6196. < prefix=$prev
  6197. ---
  6198. > # If we have known_hosts files to use
  6199. > if [[ ${#kh[@]} -gt 0 || ${#khd[@]} -gt 0 ]]; then
  6200. > # Escape slashes and dots in paths for awk
  6201. > awkcur=${cur//\//\\\/}
  6202. > awkcur=${awkcur//\./\\\.}
  6203. > curd=$awkcur
  6204. >
  6205. > if [[ "$awkcur" == [0-9]*.* ]]; then
  6206. > # Digits followed by a dot - just search for that
  6207. > awkcur="^$awkcur.*"
  6208. > elif [[ "$awkcur" == [0-9]* ]]; then
  6209. > # Digits followed by no dot - search for digits followed
  6210. > # by a dot
  6211. > awkcur="^$awkcur.*\."
  6212. > elif [ -z "$awkcur" ]; then
  6213. > # A blank - search for a dot or an alpha character
  6214. > awkcur="[a-z.]"
  6215. > else
  6216. > awkcur="^$awkcur"
  6217. > fi
  6218. >
  6219. > if [ ${#kh[@]} -gt 0 ]; then
  6220. > # FS needs to look for a comma separated list
  6221. > COMPREPLY=( "${COMPREPLY[@]}" $( awk 'BEGIN {FS=","}
  6222. > /^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \
  6223. > gsub(" .*$", "", $i); \
  6224. > gsub("[\\[\\]]", "", $i); \
  6225. > gsub(":[0-9]+$", "", $i); \
  6226. > if ($i ~ /'"$awkcur"'/) {print $i} \
  6227. > }}' "${kh[@]}" 2>/dev/null ) )
  6228. > fi
  6229. > if [ ${#khd[@]} -gt 0 ]; then
  6230. > # Needs to look for files called
  6231. > # .../.ssh2/key_22_<hostname>.pub
  6232. > # dont fork any processes, because in a cluster environment,
  6233. > # there can be hundreds of hostkeys
  6234. > for i in "${khd[@]}" ; do
  6235. > if [[ "$i" == *key_22_$curd*.pub && -r "$i" ]]; then
  6236. > host=${i/#*key_22_/}
  6237. > host=${host/%.pub/}
  6238. > COMPREPLY=( "${COMPREPLY[@]}" $host )
  6239. > fi
  6240. > done
  6241. > fi
  6242. >
  6243. > # apply suffix and prefix
  6244. > for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
  6245. > COMPREPLY[i]=$prefix$user${COMPREPLY[i]}$suffix
  6246. > done
  6247. 5277,6410c1306,1330
  6248. < # complete builtin perl functions
  6249. < case $prev in
  6250. < -f)
  6251. < COMPREPLY=( $( compgen -W 'chomp chop chr crypt hex index lc \
  6252. < lcfirst length oct ord pack q qq reverse rindex sprintf \
  6253. < substr tr uc ucfirst y m pos quotemeta s split study qr abs \
  6254. < atan2 cos exp hex int log oct rand sin sqrt srand pop push \
  6255. < shift splice unshift grep join map qw reverse sort unpack \
  6256. < delete each exists keys values binmode close closedir \
  6257. < dbmclose dbmopen die eof fileno flock format getc print \
  6258. < printf read readdir rewinddir seek seekdir select syscall \
  6259. < sysread sysseek syswrite tell telldir truncate warn write \
  6260. < pack read syscall sysread syswrite unpack vec -X chdir chmod \
  6261. < chown chroot fcntl glob ioctl link lstat mkdir open opendir \
  6262. < readlink rename rmdir stat symlink umask unlink utime caller \
  6263. < continue do dump eval exit goto last next redo return \
  6264. < sub wantarray caller import local my our package use defined \
  6265. < formline reset scalar undef \
  6266. < alarm exec fork getpgrp getppid getpriority kill pipe qx \
  6267. < setpgrp setpriority sleep system times wait waitpid \
  6268. < import no package require use bless dbmclose dbmopen package \
  6269. < ref tie tied untie use accept bind connect getpeername \
  6270. < getsockname getsockopt listen recv send setsockopt shutdown \
  6271. < socket socketpair msgctl msgget msgrcv msgsnd semctl semget \
  6272. < semop shmctl shmget shmread shmwrite endgrent endhostent \
  6273. < endnetent endpwent getgrent getgrgid getgrnam getlogin \
  6274. < getpwent getpwnam getpwuid setgrent setpwent endprotoent \
  6275. < endservent gethostbyaddr gethostbyname gethostent \
  6276. < getnetbyaddr getnetbyname getnetent getprotobyname \
  6277. < getprotobynumber getprotoent getservbyname getservbyport \
  6278. < getservent sethostent setnetent setprotoent setservent \
  6279. < gmtime localtime time times' -- $cur ) )
  6280. < return 0
  6281. < ;;
  6282. < esac
  6283. <
  6284. < case $cur in
  6285. < -*)
  6286. < COMPREPLY=( $( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- $cur ))
  6287. < return 0
  6288. < ;;
  6289. < */*)
  6290. < return 0
  6291. < ;;
  6292. < *)
  6293. < _perlmodules
  6294. < 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 ) )
  6295. <
  6296. < return 0
  6297. < ;;
  6298. < esac
  6299. < }
  6300. < complete -F _perldoc $default perldoc
  6301. < }
  6302. <
  6303. < # rcs(1) completion
  6304. < #
  6305. < have rcs &&
  6306. < _rcs()
  6307. < {
  6308. < local cur prev file dir i
  6309. <
  6310. < COMPREPLY=()
  6311. < cur=`_get_cword`
  6312. < prev=${COMP_WORDS[COMP_CWORD-1]}
  6313. <
  6314. < file=${cur##*/}
  6315. < dir=${cur%/*}
  6316. <
  6317. < # deal with relative directory
  6318. < [ "$file" = "$dir" ] && dir=.
  6319. <
  6320. < COMPREPLY=( $( compgen -f "$dir/RCS/$file" ) )
  6321. <
  6322. < for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
  6323. < file=${COMPREPLY[$i]##*/}
  6324. < dir=${COMPREPLY[$i]%RCS/*}
  6325. < COMPREPLY[$i]=$dir$file
  6326. < done
  6327. <
  6328. < COMPREPLY=( "${COMPREPLY[@]}" $( compgen -G "$dir/$file*,v" ) )
  6329. <
  6330. < for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
  6331. < COMPREPLY[$i]=${COMPREPLY[$i]%,v}
  6332. < done
  6333. <
  6334. < # default to files if nothing returned and we're checking in.
  6335. < # otherwise, default to directories
  6336. < [ ${#COMPREPLY[@]} -eq 0 -a $1 = ci ] && _filedir || _filedir -d
  6337. < } &&
  6338. < complete -F _rcs $filenames ci co rlog rcs rcsdiff
  6339. <
  6340. < # lilo(8) completion
  6341. < #
  6342. < have lilo && {
  6343. < _lilo_labels()
  6344. < {
  6345. < COMPREPLY=( $( awk -F'=' '/label/ {print $2}' \
  6346. < /etc/lilo.conf | sed -e 's/"//g' | grep "^$cur" ) )
  6347. < }
  6348. <
  6349. < _lilo()
  6350. < {
  6351. < local cur prev
  6352. <
  6353. < COMPREPLY=()
  6354. < cur=`_get_cword`
  6355. < prev=${COMP_WORDS[COMP_CWORD-1]}
  6356. <
  6357. < case $prev in
  6358. < -@(C|i|m|s|S))
  6359. < _filedir
  6360. < return 0
  6361. < ;;
  6362. < -r)
  6363. < _filedir -d
  6364. < return 0
  6365. < ;;
  6366. < -@(I|D|R))
  6367. < # label completion
  6368. < _lilo_labels
  6369. < return 0
  6370. < ;;
  6371. < -@(A|b|M|u|U))
  6372. < # device completion
  6373. < cur=${cur:=/dev/}
  6374. < _filedir
  6375. < return 0
  6376. < ;;
  6377. < -T)
  6378. < # topic completion
  6379. < COMPREPLY=( $( compgen -W 'help ChRul EBDA geom geom= \
  6380. < table= video' -- $cur ) )
  6381. < return 0
  6382. < ;;
  6383. < esac
  6384. <
  6385. < if [[ "$cur" == -* ]]; then
  6386. < # relevant options completion
  6387. < COMPREPLY=( $( compgen -W '-A -b -c -C -d -f -g -i -I -l -L -m \
  6388. < -M -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- \
  6389. < $cur ) )
  6390. < fi
  6391. < }
  6392. < complete -F _lilo lilo
  6393. < }
  6394. <
  6395. < # links completion
  6396. < #
  6397. < have links &&
  6398. < _links()
  6399. < {
  6400. < local cur
  6401. <
  6402. < COMPREPLY=()
  6403. < cur=`_get_cword`
  6404. <
  6405. < case "$cur" in
  6406. < --*)
  6407. < COMPREPLY=( $( compgen -W '--help' -- $cur ) )
  6408. < ;;
  6409. < -*)
  6410. < COMPREPLY=( $( compgen -W '-async-dns -max-connections \
  6411. < -max-connections-to-host -retries \
  6412. < -receive-timeout -unrestartable-receive-timeout\
  6413. < -format-cache-size -memory-cache-size \
  6414. < -http-proxy -ftp-proxy -download-dir \
  6415. < -assume-codepage -anonymous -dump -no-connect \
  6416. < -source -version -help' -- $cur ) )
  6417. < ;;
  6418. < *)
  6419. < if [ -r ~/.links/links.his ]; then
  6420. < COMPREPLY=( $( compgen -W '$( < ~/.links/links.his )' \
  6421. < -- $cur ) )
  6422. < fi
  6423. < _filedir '@(htm|html)'
  6424. < return 0
  6425. < ;;
  6426. < esac
  6427. <
  6428. < return 0
  6429. < } &&
  6430. < complete -F _links $filenames links
  6431. <
  6432. < [ $UNAME = FreeBSD ] && {
  6433. < # FreeBSD package management tool completion
  6434. < #
  6435. < _pkg_delete()
  6436. < {
  6437. < local cur pkgdir prev
  6438. <
  6439. < pkgdir=${PKG_DBDIR:-/var/db/pkg}/
  6440. < cur=`_get_cword`
  6441. < prev=${COMP_WORDS[COMP_CWORD-1]}
  6442. <
  6443. < [ "$prev" = "-o" -o "$prev" = "-p" -o "$prev" = "-W" ] && return 0
  6444. <
  6445. < COMPREPLY=( $( compgen -d $pkgdir$cur ) )
  6446. < COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
  6447. <
  6448. < return 0
  6449. < }
  6450. < complete -F _pkg_delete $dirnames pkg_delete pkg_info
  6451. < have pkg_deinstall && complete -F _pkg_delete $dirnames pkg_deinstall
  6452. <
  6453. < # FreeBSD kernel module commands
  6454. < #
  6455. < _kldload()
  6456. < {
  6457. < local cur moddir
  6458. <
  6459. < moddir=/modules/
  6460. < [ -d $moddir ] || moddir=/boot/kernel/
  6461. < cur=`_get_cword`
  6462. <
  6463. < COMPREPLY=( $( compgen -f $moddir$cur ) )
  6464. < COMPREPLY=( ${COMPREPLY[@]#$moddir} )
  6465. < COMPREPLY=( ${COMPREPLY[@]%.ko} )
  6466. <
  6467. < return 0
  6468. < }
  6469. < complete -F _kldload $filenames kldload
  6470. <
  6471. < _kldunload()
  6472. < {
  6473. < local cur
  6474. < cur=`_get_cword`
  6475. < COMPREPLY=( $(kldstat | sed -ne "s/^.*[ \t]\+\($cur[a-z_]\+\).ko$/\1/p") )
  6476. < }
  6477. < complete -F _kldunload $filenames kldunload
  6478. < }
  6479. <
  6480. < # FreeBSD portupgrade completion
  6481. < #
  6482. < have portupgrade &&
  6483. < _portupgrade()
  6484. < {
  6485. < local cur pkgdir prev
  6486. <
  6487. < pkgdir=${PKG_DBDIR:-/var/db/pkg}/
  6488. < cur=`_get_cword`
  6489. < prev=${COMP_WORDS[COMP_CWORD-1]}
  6490. <
  6491. < [ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0
  6492. <
  6493. < COMPREPLY=( $( compgen -d $pkgdir$cur ) )
  6494. < COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
  6495. < COMPREPLY=( ${COMPREPLY[@]%-*} )
  6496. <
  6497. < return 0
  6498. < } &&
  6499. < complete -F _portupgrade $dirnames portupgrade
  6500. <
  6501. < # FreeBSD portinstall completion
  6502. < #
  6503. < have portinstall &&
  6504. < _portinstall()
  6505. < {
  6506. < local cur portsdir prev indexfile
  6507. < local -a COMPREPLY2
  6508. <
  6509. < portsdir=${PORTSDIR:-/usr/ports}/
  6510. < cur=`_get_cword`
  6511. < prev=${COMP_WORDS[COMP_CWORD-1]}
  6512. < # First try INDEX-5
  6513. < indexfile=$portsdir/INDEX-5
  6514. < # Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x
  6515. < [ "${OSTYPE%.*}" = "freebsd5" -a -f $indexfile ] ||
  6516. < indexfile=$portsdir/INDEX
  6517. <
  6518. < [ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0
  6519. <
  6520. < COMPREPLY=( $( egrep "^$cur" < $indexfile | cut -d'|' -f1 ) )
  6521. < COMPREPLY2=( $( egrep "^[^\|]+\|$portsdir$cur" < $indexfile | \
  6522. < cut -d'|' -f2 ) )
  6523. < COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
  6524. < COMPREPLY=( ${COMPREPLY[@]} ${COMPREPLY2[@]} )
  6525. <
  6526. < return 0
  6527. < } &&
  6528. < complete -F _portinstall $dirnames portinstall
  6529. <
  6530. < # Slackware Linux removepkg completion
  6531. < #
  6532. < have removepkg && [ -f /etc/slackware-version ] &&
  6533. < _removepkg()
  6534. < {
  6535. < local packages cur
  6536. <
  6537. < COMPREPLY=()
  6538. < cur=`_get_cword`
  6539. <
  6540. < COMPREPLY=( $( (cd /var/log/packages; compgen -f -- "$cur") ) )
  6541. < } &&
  6542. < complete -F _removepkg $filenames removepkg &&
  6543. < complete $dirnames -f -X '!*.tgz' installpkg upgradepkg explodepkg
  6544. <
  6545. < # look(1) completion
  6546. < #
  6547. < have look &&
  6548. < _look()
  6549. < {
  6550. < local cur
  6551. <
  6552. < COMPREPLY=()
  6553. < cur=`_get_cword`
  6554. <
  6555. < if [ $COMP_CWORD = 1 ]; then
  6556. < COMPREPLY=( $( compgen -W '$(look $cur)' ) )
  6557. < fi
  6558. < } &&
  6559. < complete -F _look $default look
  6560. <
  6561. < # ypcat(1) and ypmatch(1) completion
  6562. < #
  6563. < have ypmatch &&
  6564. < _ypmatch()
  6565. < {
  6566. < local cur map
  6567. <
  6568. < COMPREPLY=()
  6569. < cur=`_get_cword`
  6570. <
  6571. < [ $1 = ypcat ] && [ $COMP_CWORD -gt 1 ] && return 0
  6572. < [ $1 = ypmatch ] && [ $COMP_CWORD -gt 2 ] && return 0
  6573. <
  6574. < if [ $1 = ypmatch ] && [ $COMP_CWORD -eq 1 ] && \
  6575. < [ ${#COMP_WORDS[@]} -eq 3 ]; then
  6576. < map=${COMP_WORDS[2]}
  6577. < COMPREPLY=( $( compgen -W '$( ypcat $map | \
  6578. < cut -d':' -f 1 )' -- $cur) )
  6579. < else
  6580. < [ $1 = ypmatch ] && [ $COMP_CWORD -ne 2 ] && return 0
  6581. < COMPREPLY=( $( compgen -W \
  6582. < '$( echo $(ypcat -x | cut -d"\"" -f 2))' -- $cur))
  6583. < fi
  6584. <
  6585. < return 0
  6586. < } &&
  6587. < complete -F _ypmatch ypmatch ypcat
  6588. <
  6589. < # mplayer(1) completion
  6590. < #
  6591. < have mplayer && {
  6592. < _mplayer_options_list()
  6593. < {
  6594. < cur=${cur%\\}
  6595. < COMPREPLY=( $( $1 $2 help 2> /dev/null | \
  6596. < sed -e '1,/^Available/d' | awk '{print $1}' | \
  6597. < sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' | \
  6598. < grep "^$cur" ) )
  6599. < }
  6600. <
  6601. < _mplayer()
  6602. < {
  6603. < local cmd cur prev skinsdir IFS=$' \t\n' i j k=0
  6604. <
  6605. < COMPREPLY=()
  6606. < cmd=${COMP_WORDS[0]}
  6607. < cur=`_get_cword`
  6608. < prev=${COMP_WORDS[COMP_CWORD-1]}
  6609. <
  6610. < case "$prev" in
  6611. < -@(ac|afm|vc|vfm|ao|vo|vop|fstype))
  6612. < _mplayer_options_list mplayer $prev
  6613. < return 0
  6614. < ;;
  6615. < -@(oac|ovc|of))
  6616. < _mplayer_options_list mencoder $prev
  6617. < return 0
  6618. < ;;
  6619. < -audiofile)
  6620. < _filedir '@(mp3|MP3|mpg|MPG|ogg|OGG|wav|WAV|mid|MID|flac|FLAC|mka|MKA)'
  6621. < return 0
  6622. < ;;
  6623. < -font)
  6624. < _filedir '@(desc|ttf)'
  6625. < return 0
  6626. < ;;
  6627. < -sub)
  6628. < _filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js)'
  6629. < return 0
  6630. < ;;
  6631. < -vobsub)
  6632. < _filedir '@(idx|IDX|ifo|IFO|sub|SUB)'
  6633. < IFS=$'\t\n'
  6634. < COMPREPLY=( $( for i in ${COMPREPLY[@]}; do
  6635. < if [ -f $i -a -r $i ]; then
  6636. < echo ${i%.*}
  6637. < else
  6638. < echo $i
  6639. < fi
  6640. < done ) )
  6641. < IFS=$' \t\n'
  6642. < return 0
  6643. < ;;
  6644. < -ifo)
  6645. < _filedir '@(ifo|IFO)'
  6646. < return 0
  6647. < ;;
  6648. < -cuefile)
  6649. < _filedir '@(bin|BIN|cue|CUE)'
  6650. < return 0
  6651. < ;;
  6652. < -skin)
  6653. < # if you don't have installed mplayer in /usr/local you
  6654. < # may want to set the MPLAYER_SKINS_DIR global variable
  6655. < if [ -n "$MPLAYER_SKINS_DIR" ]; then
  6656. < skinsdir=$MPLAYER_SKINS_DIR
  6657. < else
  6658. < skinsdir=/usr/local/share/mplayer/Skin
  6659. < fi
  6660. <
  6661. < IFS=$'\t\n'
  6662. < for i in ~/.mplayer/Skin $skinsdir; do
  6663. < if [ -d $i -a -r $i ]; then
  6664. < for j in $( compgen -d $i/$cur ); do
  6665. < COMPREPLY[$k]=${j#$i/}
  6666. < k=$((++k))
  6667. < done
  6668. < fi
  6669. < done
  6670. < IFS=$' \t\n'
  6671. < return 0
  6672. < ;;
  6673. < -@(mixer|@(cdrom|dvd)-device|dvdauth|fb|zrdev))
  6674. < cur=${cur:=/dev/}
  6675. < _filedir
  6676. < return 0
  6677. < ;;
  6678. < -@(edl?(out)|lircconf|menu-cfg|playlist|csslib|dumpfile)| \
  6679. < -@(subfile|vobsub|aofile|fbmodeconfig|include|o|dvdkey)| \
  6680. < -passlogfile)
  6681. < _filedir
  6682. < return 0
  6683. < ;;
  6684. < -@(auto@(q|sync)|loop|menu-root|speed|sstep|aid|alang)| \
  6685. < -@(?(@(audio|sub)-)demuxer|bandwidth|cache|chapter)| \
  6686. < -@(dvd?(angle)|fps|frames|mc|passwd|user|sb|srate|ss|vcd)| \
  6687. < -@(vi?(d|vo)|ffactor|sid|slang|spu@(align|aa|gauss))| \
  6688. < -@(vobsubid|delay|bpp|brightness|contrast|dfbopts|display)| \
  6689. < -@(fbmode|geometry|guiwid|hue|icelayer|screen[wh]|wid)| \
  6690. < -@(monitor@(aspect|-@(dotclock|[hv]freq))|panscan|saturation)| \
  6691. < -@(xineramascreen|zr@(crop|norm|quality|[xy]doff|[vh]dec))| \
  6692. < -@(aspect|pp|x|y|xy|z|stereo|audio-@(density|delay|preload))| \
  6693. < -@(endpos|osdlevel|ffourcc|sws|channels|skiplimit|format)| \
  6694. < -@(ofps|aa@(driver|@(osd|sub)color)|vobsubout?(i@(ndex|d)))| \
  6695. < -sub@(-bg-@(alpha|color)|cp|delay|fps|pos|align|width)| \
  6696. < -sub@(font-@(blur|outline|autoscale|encoding|@(osd|text)-scale)))
  6697. < return 0
  6698. < ;;
  6699. < -lavdopts)
  6700. < COMPREPLY=( $( compgen -W 'ec er= bug= idct= gray' \
  6701. < -- $cur ) )
  6702. < return 0
  6703. < ;;
  6704. < -lavcopts)
  6705. < COMPREPLY=( $( compgen -W 'vcodec= vqmin= vqscale= \
  6706. < vqmax= mbqmin= mbqmax= vqdiff= \
  6707. < vmax_b_frames= vme= vhq v4mv \
  6708. < keyint= vb_strategy= vpass= \
  6709. < aspect= vbitrate= vratetol= \
  6710. < vrc_maxrate= vrc_minrate= \
  6711. < vrc_buf_size= vb_qfactor= vi_qfactor= \
  6712. < vb_qoffset= vi_qoffset= vqblur= \
  6713. < vqcomp= vrc_eq= vrc_override= \
  6714. < vrc_init_cplx= vqsquish= vlelim= \
  6715. < vcelim= vstrict= vdpart vpsize= gray \
  6716. < vfdct= idct= lumi_mask= dark_mask= \
  6717. < tcplx_mask= scplx_mask= naq ildct \
  6718. < format= pred qpel precmp= cmp= \
  6719. < subcmp= predia= dia= trell last_pred= \
  6720. < preme= subq= psnr mpeg_quant aic umv' \
  6721. < -- $cur ) )
  6722. < return 0
  6723. < ;;
  6724. < -ssf)
  6725. < COMPREPLY=( $( compgen -W 'lgb= cgb= ls= cs= chs= \
  6726. < cvs=' -- $cur ) )
  6727. < return 0
  6728. < ;;
  6729. < -jpeg)
  6730. < COMPREPLY=( $( compgen -W 'noprogressive progressive \
  6731. < nobaseline baseline optimize= \
  6732. < smooth= quality= outdir=' -- $cur ) )
  6733. < return 0
  6734. < ;;
  6735. < -xvidopts)
  6736. < COMPREPLY=( $( compgen -W 'dr2 nodr2' -- $cur ) )
  6737. < return 0
  6738. < ;;
  6739. < -xvidencopts)
  6740. < COMPREPLY=( $( compgen -W 'pass= bitrate= \
  6741. < fixed_quant= me_quality= 4mv \
  6742. < rc_reaction_delay_factor= \
  6743. < rc_averaging_period= rc_buffer= \
  6744. < quant_range= min_key_interval= \
  6745. < max_key_interval= mpeg_quant \
  6746. < mod_quant lumi_mask hintedme \
  6747. < hintfile debug keyframe_boost= \
  6748. < kfthreshold= kfreduction=' -- $cur ) )
  6749. < return 0
  6750. < ;;
  6751. < -divx4opts)
  6752. < COMPREPLY=( $( compgen -W 'br= key= deinterlace q= \
  6753. < min_quant= max_quant= rc_period= \
  6754. < rc_reaction_period= crispness= \
  6755. < rc_reaction_ratio= pass= vbrpass= \
  6756. < help' -- $cur ) )
  6757. < return 0
  6758. < ;;
  6759. < -info)
  6760. < COMPREPLY=( $( compgen -W 'name= artist= genre= \
  6761. < subject= copyright= srcform= \
  6762. < comment= help' -- $cur ) )
  6763. < return 0
  6764. < ;;
  6765. < -lameopts)
  6766. < COMPREPLY=( $( compgen -W 'vbr= abr cbr br= q= aq= \
  6767. < ratio= vol= mode= padding= fast \
  6768. < preset= help' -- $cur ) )
  6769. < return 0
  6770. < ;;
  6771. < -rawaudio)
  6772. < COMPREPLY=( $( compgen -W 'on channels= rate= \
  6773. < samplesize= format=' -- $cur ) )
  6774. < return 0
  6775. < ;;
  6776. < -rawvideo)
  6777. < COMPREPLY=( $( compgen -W 'on fps= sqcif qcif cif \
  6778. < 4cif pal ntsc w= h= y420 yv12 yuy2 \
  6779. < y8 format= size=' -- $cur ) )
  6780. < return 0
  6781. < ;;
  6782. < -aop)
  6783. < COMPREPLY=( $( compgen -W 'list= delay= format= fout= \
  6784. < volume= mul= softclip' -- $cur ) )
  6785. < return 0
  6786. < ;;
  6787. < -dxr2)
  6788. < COMPREPLY=( $( compgen -W 'ar-mode= iec958-encoded \
  6789. < iec958-decoded mute ucode= 75ire bw \
  6790. < color interlaced macrovision= norm= \
  6791. < square-pixel ccir601-pixel cr-left= \
  6792. < cr-right= cr-top= cr-bot= ck-rmin= \
  6793. < ck-gmin= ck-bmin= ck-rmax= ck-gmax= \
  6794. < ck-bmax= ck-r= ck-g= ck-b= \
  6795. < ignore-cache= ol-osd= olh-cor= \
  6796. < olw-cor= olx-cor= oly-cor= overlay \
  6797. < overlay-ratio= update-cache' -- $cur ))
  6798. < return 0
  6799. < ;;
  6800. < -tv)
  6801. < COMPREPLY=( $( compgen -W 'on noaudio driver= device= \
  6802. < input= freq= outfmt= width= height= \
  6803. < buffersize= norm= channel= chanlist= \
  6804. < audiorate= forceaudio alsa amode= \
  6805. < forcechan= adevice= audioid= volume= \
  6806. < bass= treble= balance= fps= \
  6807. < channels= immediatemode=' -- $cur ) )
  6808. < return 0
  6809. < ;;
  6810. < -mf)
  6811. < COMPREPLY=( $( compgen -W 'on w= h= fps= type=' \
  6812. < -- $cur ) )
  6813. < return 0
  6814. < ;;
  6815. < -cdda)
  6816. < COMPREPLY=( $( compgen -W 'speed= paranoia= \
  6817. < generic-dev= sector-size= overlap= \
  6818. < toc-bias toc-offset= skip noskip' \
  6819. < -- $cur ) )
  6820. < return 0
  6821. < ;;
  6822. < -input)
  6823. < COMPREPLY=( $( compgen -W 'conf= ar-delay ar-rate \
  6824. < keylist cmdlist js-dev file' -- $cur ) )
  6825. < return 0
  6826. < ;;
  6827. < -af)
  6828. < COMPREPLY=( $( compgen -W 'resample resample= \
  6829. < channels channels= format format= \
  6830. < volume volume= delay delay= pan \
  6831. < pan= sub sub= surround surround=' \
  6832. < -- $cur ) )
  6833. < return 0
  6834. < ;;
  6835. < -af-adv)
  6836. < COMPREPLY=( $( compgen -W 'force= list=' -- $cur ) )
  6837. < return 0
  6838. < ;;
  6839. < esac
  6840. <
  6841. < case "$cur" in
  6842. < -*)
  6843. < COMPREPLY=( $( compgen -W '-aid -alang -audio-demuxer \
  6844. < -audiofile -cdrom-device -cache -cdda \
  6845. < -channels -chapter -csslib -demuxer \
  6846. < -dvd -dvd-device -dvdangle -dvdauth \
  6847. < -dvdkey -dvdnav -forceidx -fps -frames \
  6848. < -hr-mp3-seek -idx -mc -mf -ni -nobps \
  6849. < -passwd -rawaudio -rtsp-stream-over-tcp\
  6850. < -skipopening -sb -srate -ss -tv -user \
  6851. < -vcd -vid -vivo -ifo -ffactor -font \
  6852. < -noautosub -nooverlapsub -sid -slang \
  6853. < -sub -subcc -subcp -sub-demuxer \
  6854. < -subdelay -subfont-autoscale \
  6855. < -subfont-blur -subfont-encoding \
  6856. < -subfont-osd-scale -subfont-outline \
  6857. < -subfont-text-scale -subfps -subfile \
  6858. < -subpos -unicode -utf8 -vobsub \
  6859. < -vobsubid -ac -afm -aspect -flip \
  6860. < -lavdopts -noaspect -nosound -pp -ssf \
  6861. < -stereo -sws -vc -vfm -vop -xvidopts\
  6862. < -xy -zoom -bandwidth -cuefile \
  6863. < -noextbased -rawvideo -overlapsub \
  6864. < -sub-bg-alpha -sub-bg-color -subalign \
  6865. < -subwidth -sub-no-text-pp -spualign \
  6866. < -spuaa -spugauss -pphelp -verbose -v \
  6867. < -noni -noidx -nohr-mp3-seek -extbased \
  6868. < -bps -oldpp -nozoom -noflip -nounicode \
  6869. < -noutf8' -- $cur ) )
  6870. < # add mplayer specific options
  6871. < [[ "$cmd" == @(?(g)mplayer) ]] && COMPREPLY=( ${COMPREPLY[@]} \
  6872. < $(compgen -W '-autoq -autosync -benchmark \
  6873. < -framedrop -h -help -hardframedrop \
  6874. < -identify -input -lircconf -loop \
  6875. < -nojoystick -nolirc -nortc -playlist \
  6876. < -quiet -really-quiet -rnd -sdp -skin \
  6877. < -slave -softsleep -speed -sstep \
  6878. < -use-stdin -dumpaudio -dumpfile \
  6879. < -dumpstream -dumpvideo -dumpmicrodvdsub\
  6880. < -dumpmpsub -dumpsrtsub -dumpjacosub \
  6881. < -dumpsami -dumpsub -osdlevel -af \
  6882. < -af-adv -ao -aofile -aop -delay -mixer \
  6883. < -nowaveheader -bpp -brightness \
  6884. < -contrast -display -double -dr -dxr2 \
  6885. < -fb -fbmode -fbmodeconfig -forcexv -fs \
  6886. < -geometry -hue -icelayer -jpeg \
  6887. < -monitor-dotclock -monitor-hfreq \
  6888. < -monitor-vfreq -monitoraspect \
  6889. < -nograbpointer -noslices -panscan \
  6890. < -rootwin -saturation -screenw -screenh \
  6891. < -stop-xscreensaver -vm -vo -vsync -wid \
  6892. < -xineramascreen -z -zrbw -zrcrop \
  6893. < -zrdev -zrfd -zrhelp -zrnorm -zrquality \
  6894. < -zrvdec -zrhdec -zrxdoff -zrydoff -y \
  6895. < -edl -edlout -enqueue -fixed-vo \
  6896. < -menu -menu-root -menu-cfg -shuffle \
  6897. < -format -aahelp -dfbopts -fstype \
  6898. < -guiwid -nokeepaspect -x --help \
  6899. < -aaosdcolor -aasubcolor -aadriver \
  6900. < -aaextended -aaeight' -- $cur) )
  6901. < # add mencoder specific options
  6902. < [[ "$cmd" = mencoder ]] && COMPREPLY=( ${COMPREPLY[@]} \
  6903. < $(compgen -W '-audio-density -audio-delay \
  6904. < -audio-preload -divx4opts -endpos \
  6905. < -ffourcc -include -info -lameopts \
  6906. < -lavcopts -noskip -o -oac -ofps -ovc \
  6907. < -passlogfile -skiplimit -vobsubout \
  6908. < -vobsuboutindex -vobsuboutid \
  6909. < -xvidencopts -of --verbose' -- $cur) )
  6910. < ;;
  6911. < *)
  6912. < _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|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)'
  6913. < ;;
  6914. < esac
  6915. <
  6916. < return 0
  6917. < }
  6918. < complete $filenames -F _mplayer mplayer mencoder gmplayer kplayer
  6919. < }
  6920. <
  6921. < # KDE dcop completion
  6922. < #
  6923. < have dcop &&
  6924. < _dcop()
  6925. < {
  6926. < local cur compstr
  6927. <
  6928. < COMPREPLY=()
  6929. < cur=`_get_cword`
  6930. < if [ -z $cur ]; then
  6931. < compstr=${COMP_WORDS[*]}
  6932. < else
  6933. < compstr=$( command echo ${COMP_WORDS[*]} | sed "s/ $cur$//" )
  6934. < fi
  6935. < COMPREPLY=( $( compgen -W '$( command $compstr | sed s/\(.*\)// )' -- $cur ) )
  6936. < } &&
  6937. < complete -F _dcop dcop
  6938. <
  6939. < # wvdial(1) completion
  6940. < #
  6941. < have wvdial &&
  6942. < _wvdial()
  6943. < {
  6944. < local cur prev config i IFS=$'\t\n'
  6945. <
  6946. < COMPREPLY=()
  6947. < cur=`_get_cword`
  6948. < prev=${COMP_WORDS[COMP_CWORD-1]}
  6949. <
  6950. < case $prev in
  6951. < --config)
  6952. < _filedir
  6953. < return 0
  6954. < ;;
  6955. < esac
  6956. <
  6957. < case $cur in
  6958. < -*)
  6959. < COMPREPLY=( $( compgen -W '--config --chat \
  6960. < --remotename --help --version --no-syslog' \
  6961. < -- $cur ) )
  6962. < ;;
  6963. < *)
  6964. < # start with global and personal config files
  6965. < config="/etc/wvdial.conf"$'\t'"$HOME/.wvdialrc"
  6966. < # replace with command line config file if present
  6967. < for (( i=1; i < COMP_CWORD; i++ )); do
  6968. < if [[ "${COMP_WORDS[i]}" == "--config" ]]; then
  6969. < config=${COMP_WORDS[i+1]}
  6970. < break
  6971. < fi
  6972. < done
  6973. < # parse config files for sections and
  6974. < # remove default section
  6975. < COMPREPLY=( $( sed -ne \
  6976. < "s|^\[Dialer \($cur.*\)\]$|\1|p" \
  6977. < $config 2>/dev/null |grep -v '^Defaults$'))
  6978. < # escape spaces
  6979. < COMPREPLY=${COMPREPLY// /\\ }
  6980. < ;;
  6981. < esac
  6982. <
  6983. < } &&
  6984. < complete -F _wvdial wvdial
  6985. <
  6986. < # gpg(1) completion
  6987. < #
  6988. < have gpg &&
  6989. < _gpg()
  6990. < {
  6991. < local cur prev
  6992. <
  6993. < COMPREPLY=()
  6994. < cur=`_get_cword`
  6995. < prev=${COMP_WORDS[COMP_CWORD-1]}
  6996. <
  6997. < case "$prev" in
  6998. < -@(s|-sign|-clearsign|-decrypt-files|-load-extension))
  6999. < _filedir
  7000. < return 0
  7001. < ;;
  7002. < --@(export|@(?(l|nr|nrl)sign|edit)-key))
  7003. < # return list of public keys
  7004. < COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*/\([^ ]*\).*\(<\([^>]*\)>\).*$@\1 \3@p')" -- "$cur" ))
  7005. < return 0
  7006. < ;;
  7007. < -@(r|-recipient))
  7008. < COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ))
  7009. < if [ -e ~/.gnupg/gpg.conf ]; then
  7010. < COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf )" -- "$cur") )
  7011. < fi
  7012. < return 0
  7013. < ;;
  7014. < esac
  7015. <
  7016. < if [[ "$cur" == -* ]]; then
  7017. < COMPREPLY=( $( compgen -W '-s -b -e -f -c -d -a -r -u -Z -o -v\
  7018. < -q -n -N $(gpg --dump-options)' -- $cur ) )
  7019. < fi
  7020. <
  7021. < } &&
  7022. < complete -F _gpg $default gpg
  7023. <
  7024. < # iconv(1) completion
  7025. < #
  7026. < have iconv &&
  7027. < _iconv()
  7028. < {
  7029. < local cur prev
  7030. <
  7031. < COMPREPLY=()
  7032. < cur=`_get_cword`
  7033. < prev=${COMP_WORDS[COMP_CWORD-1]}
  7034. <
  7035. < case "$prev" in
  7036. < -@(f|t|-@(from|to)-code))
  7037. < COMPREPLY=( $( compgen -W \
  7038. < '$( iconv --list | sed -e "s@//@@;" )' -- "$cur" ) )
  7039. < return 0
  7040. < ;;
  7041. < esac
  7042. <
  7043. <
  7044. < if [[ "$cur" = -* ]]; then
  7045. < COMPREPLY=( $( compgen -W '--from-code -f --to-code -t --list
  7046. < --output -o --verbose' -- "$cur" ) )
  7047. < return 0
  7048. < fi
  7049. < } &&
  7050. < complete -F _iconv $default iconv
  7051. <
  7052. < # dict(1) completion
  7053. < #
  7054. < { have dict || have rdict; } && {
  7055. < _dictdata()
  7056. < {
  7057. < dict $host $port $1 2>/dev/null | sed -ne \
  7058. < 's/^['$'\t '']['$'\t '']*\([^'$'\t '']*\).*$/\1/p'
  7059. < }
  7060. <
  7061. < _dict()
  7062. < {
  7063. < local cur prev host port db dictfile
  7064. <
  7065. < COMPREPLY=()
  7066. < cur=`_get_cword`
  7067. < prev=${COMP_WORDS[COMP_CWORD-1]}
  7068. < dictfile=/usr/share/dict/words
  7069. <
  7070. < for (( i=1; i < COMP_CWORD; i++ )); do
  7071. < case "${COMP_WORDS[i]}" in
  7072. < -@(h|--host))
  7073. < host=${COMP_WORDS[i+1]}
  7074. < [ -n "$host" ] && host="-h $host"
  7075. < i=$((++i))
  7076. < ;;
  7077. < -@(p|-port))
  7078. < port=${COMP_WORDS[i+1]}
  7079. < [ -n "$port" ] && port="-p $port"
  7080. < i=$((++i))
  7081. < ;;
  7082. < -@(d|-database))
  7083. < db=${COMP_WORDS[i+1]}
  7084. < [ -n "$db" ] && host="-d $db"
  7085. < i=$((++i))
  7086. < ;;
  7087. < *)
  7088. < ;;
  7089. < esac
  7090. < done
  7091. <
  7092. < if [[ "$cur" = -* ]]; then
  7093. < COMPREPLY=( $( compgen -W '-h --host -p --port -d --database \
  7094. < -m --match -s --strategy -c --config -C \
  7095. < --nocorrect -D --dbs -S --strats -H \
  7096. < --serverhelp -i --info -I --serverinfo \
  7097. < -a --noauth -u --user -k --key -V --version \
  7098. < -L --license --help -v --verbose -r --raw \
  7099. < -P --pager --debug --html --pipesize --client' \
  7100. < -- "$cur" ) )
  7101. < return 0
  7102. < fi
  7103. <
  7104. < case "$prev" in
  7105. < -@(d|-database|i|info))
  7106. < COMPREPLY=( $( compgen -W '$( _dictdata -D )' -- "$cur" ) )
  7107. < return 0
  7108. < ;;
  7109. < -@(s|-strategy))
  7110. < COMPREPLY=( $( compgen -W '$( _dictdata -S )' -- "$cur" ) )
  7111. < return 0
  7112. < ;;
  7113. < *)
  7114. < ;;
  7115. < esac
  7116. <
  7117. < [ -r $dictfile ] && \
  7118. < COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) )
  7119. < }
  7120. < complete -F _dict $default dict rdict
  7121. < }
  7122. <
  7123. < # cdrecord(1) completion
  7124. < #
  7125. < have cdrecord &&
  7126. < _cdrecord()
  7127. < {
  7128. < local cur prev i generic_options track_options track_mode
  7129. <
  7130. < COMPREPLY=()
  7131. < cur=`_get_cword`
  7132. < prev=${COMP_WORDS[COMP_CWORD-1]}
  7133. <
  7134. < # foo=bar style option
  7135. < if [[ "$cur" == *=* ]]; then
  7136. < prev=${cur/=*/}
  7137. < cur=${cur/*=/}
  7138. < case "$prev" in
  7139. < @(text|cue)file)
  7140. < _filedir
  7141. < return 0
  7142. < ;;
  7143. < blank)
  7144. < COMPREPLY=( $( compgen -W 'help all fast \
  7145. < track unreserve trtail unclose session' \
  7146. < -- $cur ) )
  7147. < return 0
  7148. < ;;
  7149. < driveropts)
  7150. < COMPREPLY=( $( compgen -W 'burnfree noburnfree\
  7151. < varirec= audiomaster forcespeed noforcespeed\
  7152. < speedread nospeedread singlesession \
  7153. < nosinglesession hidecdr nohidecdr tattooinfo\
  7154. < tattoofile=' -- $cur ) )
  7155. < return 0
  7156. < ;;
  7157. < esac
  7158. < fi
  7159. <
  7160. < generic_options=(-version -v -V -d -silent -s -force -immed -dummy \
  7161. < -dao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc \
  7162. < -atip -fix -nofix -waiti -load -lock -eject -format \
  7163. < -setdropts -checkdrive -prcap -inq -scanbus -reset \
  7164. < -abort -overburn -ignsize -useinfo -packet -noclose \
  7165. < -text debug= kdebug= kd= minbuf= speed= blank= fs= \
  7166. < dev= gracetime= timeout= driver= driveropts= \
  7167. < defpregap= pktsize= mcn= textfile= cuefile=)
  7168. < track_options=(-audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi \
  7169. < -isosize -pad padsize= -nopad -shorttrack -noshorttrack\
  7170. < pregap= -preemp -nopreemp -copy -nocopy -scms tcsize= \
  7171. < isrc= index=)
  7172. < # look if previous was either a file or a track option
  7173. < track_mode=0
  7174. < if [ $COMP_CWORD -gt 1 ]; then
  7175. < if [ -f "$prev" ]; then
  7176. < track_mode=1
  7177. < else
  7178. < for (( i=0; i < ${#track_options[@]}; i++ )); do
  7179. < if [[ "${track_options[i]}" == "$prev" ]]; then
  7180. < track_mode=1
  7181. < break
  7182. < fi
  7183. < done
  7184. < fi
  7185. < fi
  7186. <
  7187. < # files are always eligible completion
  7188. < _filedir
  7189. < # track options are always available
  7190. < COMPREPLY=( ${COMPREPLY[@]} $( compgen -W '${track_options[@]}' -- $cur ) )
  7191. < # general options are no more available after file or track option
  7192. < if [ $track_mode -eq 0 ]; then
  7193. < COMPREPLY=( ${COMPREPLY[@]} \
  7194. < $( compgen -W '${generic_options[@]}' -- $cur ) )
  7195. < fi
  7196. <
  7197. < } &&
  7198. < complete -F _cdrecord $filenames cdrecord
  7199. <
  7200. < # mkisofs(8) completion
  7201. < #
  7202. < have mkisofs &&
  7203. < _mkisofs()
  7204. < {
  7205. < local cur prev
  7206. <
  7207. < COMPREPLY=()
  7208. < cur=`_get_cword`
  7209. < prev=${COMP_WORDS[COMP_CWORD-1]}
  7210. <
  7211. < case "$prev" in
  7212. < -@(o|abstract|biblio|check-session|copyright|log-file|root-info|prep-boot|*-list))
  7213. < _filedir
  7214. < return 0
  7215. < ;;
  7216. < -*-charset)
  7217. < COMPREPLY=( $( mkisofs -input-charset help 2>&1 | \
  7218. < tail +3 | grep "^$cur") )
  7219. < return 0
  7220. < ;;
  7221. < -uid)
  7222. < _uids
  7223. < return 0
  7224. < ;;
  7225. < -gid)
  7226. < _gids
  7227. < return 0
  7228. < ;;
  7229. < esac
  7230. <
  7231. < if [[ "$cur" == -* ]]; then
  7232. < COMPREPLY=( $( compgen -W '-abstract -A -allow-lowercase \
  7233. < -allow-multidot -biblio -cache-inodes \
  7234. < -no-cache-inodes -b -eltorito-alt-boot -B -G \
  7235. < -hard-disk-boot -no-emul-boot -no-boot \
  7236. < -boot-load-seg -boot-load-size \
  7237. < -boot-info-table -C -c -check-oldname \
  7238. < -check-session -copyright -d -D -dir-mode \
  7239. < -dvd-video -f -file-mode -gid -gui \
  7240. < -graft-points -hide -hide-list -hidden \
  7241. < -hidden-list -hide-joliet -hide-joliet-list \
  7242. < -hide-joliet-trans-tbl -hide-rr-moved \
  7243. < -input-charset -output-charset -iso-level -J \
  7244. < -joliet-long -jcharset -l -L -log-file -m \
  7245. < -exclude-list -max-iso9660-filenames -M -N \
  7246. < -new-dir-mode -nobak -no-bak -force-rr -no-rr \
  7247. < -no-split-symlink-components \
  7248. < -no-split-symlink-fields -o -pad -no-pad \
  7249. < -path-list -P -p -print-size -quiet -R -r \
  7250. < -relaxed-filenames -sort -split-output \
  7251. < -stream-media-size -stream-file-name -sysid -T\
  7252. < -table-name -ucs-level -udf -uid \
  7253. < -use-fileversion -U -no-iso-translate -V \
  7254. < -volset -volset-size -volset-seqno -v -x -z \
  7255. < -hfs -apple -map -magic -hfs-creator \
  7256. < -hfs-type -probe -no-desktop -mac-name \
  7257. < -boot-hfs-file -part -auto -cluster-size \
  7258. < -hide-hfs -hide-hfs-list -hfs-volid \
  7259. < -icon-position -root-info -prep-boot \
  7260. < -input-hfs-charset -output-hfs-charset \
  7261. < -hfs-unlock -hfs-bless -hfs-parms --cap \
  7262. < --netatalk --double --ethershare --ushare \
  7263. < --exchange --sgi --xinet --macbin --single \
  7264. < --dave --sfm --osx-double --osx-hfs' -- $cur ))
  7265. < else
  7266. < _filedir
  7267. < fi
  7268. <
  7269. < } &&
  7270. < complete -F _mkisofs $filenames mkisofs
  7271. <
  7272. < # mc(1) completion
  7273. < #
  7274. < have mc &&
  7275. < _mc()
  7276. < {
  7277. < local cur prev
  7278. <
  7279. < COMPREPLY=()
  7280. < cur=`_get_cword`
  7281. < prev=${COMP_WORDS[COMP_CWORD-1]}
  7282. <
  7283. < # -name value style option
  7284. < case "$prev" in
  7285. < -@(e|v|l|P))
  7286. < _filedir
  7287. < return 0
  7288. < ;;
  7289. < esac
  7290. <
  7291. < # --name=value style option
  7292. < if [[ "$cur" == *=* ]]; then
  7293. < prev=${cur/=*/}
  7294. < cur=${cur/*=/}
  7295. < case "$prev" in
  7296. < --@(edit|view|ftplog|printwd))
  7297. < _filedir
  7298. < return 0
  7299. < ;;
  7300. < esac
  7301. < fi
  7302. <
  7303. < if [[ "$cur" == -* ]]; then
  7304. < COMPREPLY=( $( compgen -W '-a --stickchars -b --nocolor -c \
  7305. < --color -C --colors= -d --nomouse -e --edit= -f \
  7306. < --datadir -k --resetsoft -l --ftplog= -P --printwd= \
  7307. < -s --slow -t --termcap -u --nosubshell -U --subshell \
  7308. < -v --view= -V --version -x --xterm -h --help' -- $cur ) )
  7309. < else
  7310. < _filedir -d
  7311. < fi
  7312. < } &&
  7313. < complete -F _mc $filenames mc
  7314. <
  7315. < # yum(8) completion
  7316. < #
  7317. < have yum && {
  7318. < _yum()
  7319. < {
  7320. < local cur prev special
  7321. <
  7322. < COMPREPLY=()
  7323. < cur=`_get_cword`
  7324. < prev=${COMP_WORDS[COMP_CWORD-1]}
  7325. <
  7326. < for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
  7327. < if [[ ${COMP_WORDS[i]} == @(install|update|upgrade|remove|erase|deplist) ]]; then
  7328. < special=${COMP_WORDS[i]}
  7329. < fi
  7330. < done
  7331. <
  7332. < if [ -n "$special" ]; then
  7333. < case $special in
  7334. < install|deplist)
  7335. < COMPREPLY=( $( compgen -W '$( yum -C list | cut -d" " -f1 )' -- $cur ) )
  7336. < return 0
  7337. < ;;
  7338. < *)
  7339. < _rpm_installed_packages
  7340. < return 0
  7341. < ;;
  7342. < esac
  7343. < fi
  7344. <
  7345. < case $cur in
  7346. < --*)
  7347. < COMPREPLY=( $( compgen -W '--installroot --version --help --enablerepo --disablerepo --exclude --obsoletes --noplugins' -- $cur ) )
  7348. < return 0
  7349. < ;;
  7350. < -*)
  7351. < COMPREPLY=( $( compgen -W '-c -e -d -y -t -R -C -h' -- $cur ) )
  7352. < return 0
  7353. < ;;
  7354. < esac
  7355. <
  7356. < case $prev in
  7357. < list)
  7358. < COMPREPLY=( $( compgen -W 'all available updates installed extras obsoletes recent' -- $cur ) )
  7359. < ;;
  7360. < clean)
  7361. < COMPREPLY=( $( compgen -W 'packages headers metadata cache dbcache all' -- $cur ) )
  7362. < ;;
  7363. < localinstall)
  7364. < _filedir rpm
  7365. < ;;
  7366. < -c)
  7367. < _filedir
  7368. < ;;
  7369. < --installroot)
  7370. < _filedir -d
  7371. < ;;
  7372. < *)
  7373. < COMPREPLY=( $( compgen -W 'install update check-update upgrade remove list \
  7374. < search info provides clean groupinstall groupupdate \
  7375. < grouplist deplist erase groupinfo groupremove \
  7376. < localinstall localupdate makecache resolvedep \
  7377. < shell whatprovides' -- $cur ) )
  7378. < ;;
  7379. < esac
  7380. < }
  7381. < complete -F _yum $filenames yum
  7382. ---
  7383. > # append any available aliases from config files
  7384. > if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then
  7385. > local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" )
  7386. > COMPREPLY=( "${COMPREPLY[@]}" $( compgen -P "$prefix$user" \
  7387. > -S "$suffix" -W "$hosts" -- "$cur" ) )
  7388. > fi
  7389. >
  7390. > # Add hosts reported by avahi-browse, if it's available.
  7391. > # The original call to avahi-browse also had "-k", to avoid lookups into
  7392. > # avahi's services DB. We don't need the name of the service, and if it
  7393. > # contains ";", it may mistify the result. But on Gentoo (at least),
  7394. > # -k isn't available (even if mentioned in the manpage), so...
  7395. > if type avahi-browse >&/dev/null; then
  7396. > COMPREPLY=( "${COMPREPLY[@]}" $( \
  7397. > compgen -P "$prefix$user" -S "$suffix" -W \
  7398. > "$( avahi-browse -cpr _workstation._tcp 2>/dev/null | \
  7399. > awk -F';' '/^=/ { print $7 }' | sort -u )" -- "$cur" ) )
  7400. > fi
  7401. >
  7402. > # Add results of normal hostname completion, unless
  7403. > # `COMP_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value.
  7404. > if [ -n "${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1}" ]; then
  7405. > COMPREPLY=( "${COMPREPLY[@]}"
  7406. > $( compgen -A hostname -P "$prefix$user" -S "$suffix" -- "$cur" ) )
  7407. > fi
  7408. 6412c1332,1341
  7409. < # yum-arch(8) completion
  7410. ---
  7411. > __ltrim_colon_completions "$prefix$user$cur"
  7412. >
  7413. > return 0
  7414. > } # _known_hosts_real()
  7415. > complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 ping \
  7416. > ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig mtr \
  7417. > ssh-installkeys showmount
  7418. >
  7419. > # This meta-cd function observes the CDPATH variable, so that cd additionally
  7420. > # completes on directories under those specified in CDPATH.
  7421. 6414c1343
  7422. < _yum_arch()
  7423. ---
  7424. > _cd()
  7425. 6416,6418c1345,1346
  7426. < local cur
  7427. < COMPREPLY=()
  7428. < cur=`_get_cword`
  7429. ---
  7430. > local cur IFS=$'\t\n' i j k
  7431. > _get_comp_words_by_ref cur
  7432. 6420,6427c1348,1352
  7433. < case "$cur" in
  7434. < -*)
  7435. < COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l -q' -- $cur ) )
  7436. < ;;
  7437. < *)
  7438. < _filedir -d
  7439. < ;;
  7440. < esac
  7441. ---
  7442. > # try to allow variable completion
  7443. > if [[ "$cur" == ?(\\)\$* ]]; then
  7444. > COMPREPLY=( $( compgen -v -P '$' -- "${cur#?(\\)$}" ) )
  7445. > return 0
  7446. > fi
  7447. 6429c1354,1386
  7448. < return 0
  7449. ---
  7450. > # Enable -o filenames option, see Debian bug #272660
  7451. > compgen -f /non-existing-dir/ >/dev/null
  7452. >
  7453. > # Use standard dir completion if no CDPATH or parameter starts with /,
  7454. > # ./ or ../
  7455. > if [[ -z "${CDPATH:-}" || "$cur" == ?(.)?(.)/* ]]; then
  7456. > _filedir -d
  7457. > return 0
  7458. > fi
  7459. >
  7460. > local -r mark_dirs=$(_rl_enabled mark-directories && echo y)
  7461. > local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y)
  7462. >
  7463. > # we have a CDPATH, so loop on its contents
  7464. > for i in ${CDPATH//:/$'\t'}; do
  7465. > # create an array of matched subdirs
  7466. > k="${#COMPREPLY[@]}"
  7467. > for j in $( compgen -d $i/$cur ); do
  7468. > if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
  7469. > j="${j}/"
  7470. > fi
  7471. > COMPREPLY[k++]=${j#$i/}
  7472. > done
  7473. > done
  7474. >
  7475. > _filedir -d
  7476. >
  7477. > if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
  7478. > i=${COMPREPLY[0]}
  7479. > if [[ "$i" == "$cur" && $i != "*/" ]]; then
  7480. > COMPREPLY[0]="${i}/"
  7481. > fi
  7482. > fi
  7483. 6430a1388
  7484. > return 0
  7485. 6432c1390,1409
  7486. < complete -F _yum_arch $filenames yum-arch
  7487. ---
  7488. > if shopt -q cdable_vars; then
  7489. > complete -v -F _cd -o nospace cd
  7490. > else
  7491. > complete -F _cd -o nospace cd
  7492. > fi
  7493. >
  7494. > # a wrapper method for the next one, when the offset is unknown
  7495. > _command()
  7496. > {
  7497. > local offset i
  7498. >
  7499. > # find actual offset, as position of the first non-option
  7500. > offset=1
  7501. > for (( i=1; i <= COMP_CWORD; i++ )); do
  7502. > if [[ "${COMP_WORDS[i]}" != -* ]]; then
  7503. > offset=$i
  7504. > break
  7505. > fi
  7506. > done
  7507. > _command_offset $offset
  7508. 6435c1412,1415
  7509. < # ImageMagick completion
  7510. ---
  7511. > # A meta-command completion function for commands like sudo(8), which need to
  7512. > # first complete on a command, then complete according to that command's own
  7513. > # completion definition - currently not quite foolproof (e.g. mount and umount
  7514. > # don't work properly), but still quite useful.
  7515. 6437,6438c1417
  7516. < have convert && {
  7517. < _ImageMagick()
  7518. ---
  7519. > _command_offset()
  7520. 6440,8777c1419,1420
  7521. < local prev
  7522. < prev=${COMP_WORDS[COMP_CWORD-1]}
  7523. <
  7524. < case "$prev" in
  7525. < -channel)
  7526. < COMPREPLY=( $( compgen -W 'Red Green Blue Opacity \
  7527. < Matte Cyan Magenta Yellow Black' -- $cur ) )
  7528. < return 0
  7529. < ;;
  7530. < -colormap)
  7531. < COMPREPLY=( $( compgen -W 'shared private' -- $cur ) )
  7532. < return 0
  7533. < ;;
  7534. < -colorspace)
  7535. < COMPREPLY=( $( compgen -W 'GRAY OHTA RGB Transparent \
  7536. < XYZ YCbCr YIQ YPbPr YUV CMYK' -- $cur ) )
  7537. < return 0
  7538. < ;;
  7539. < -compose)
  7540. < COMPREPLY=( $( compgen -W 'Over In Out Atop Xor Plus \
  7541. < Minus Add Subtract Difference Multiply Bumpmap\
  7542. < Copy CopyRed CopyGreen CopyBlue CopyOpacity' \
  7543. < -- $cur ) )
  7544. < return 0
  7545. < ;;
  7546. < -compress)
  7547. < COMPREPLY=( $( compgen -W 'None BZip Fax Group4 JPEG \
  7548. < Lossless LZW RLE Zip' -- $cur ) )
  7549. < return 0
  7550. < ;;
  7551. < -dispose)
  7552. < COMPREPLY=( $( compgen -W 'Undefined None Background \
  7553. < Previous' -- $cur ) )
  7554. < return 0
  7555. < ;;
  7556. < -encoding)
  7557. < COMPREPLY=( $( compgen -W 'AdobeCustom AdobeExpert \
  7558. < AdobeStandard AppleRoman BIG5 GB2312 Latin2 \
  7559. < None SJIScode Symbol Unicode Wansung' -- $cur))
  7560. < return 0
  7561. < ;;
  7562. < -endian)
  7563. < COMPREPLY=( $( compgen -W 'MSB LSB' -- $cur ) )
  7564. < return 0
  7565. < ;;
  7566. < -filter)
  7567. < COMPREPLY=( $( compgen -W 'Point Box Triangle Hermite \
  7568. < Hanning Hamming Blackman Gaussian Quadratic \
  7569. < Cubic Catrom Mitchell Lanczos Bessel Sinc' \
  7570. < -- $cur ) )
  7571. < return 0
  7572. < ;;
  7573. < -format)
  7574. < COMPREPLY=( $( convert -list format | \
  7575. < awk '/ [r-][w-][+-] / {print $1}' | \
  7576. < tr -d '*' | tr [:upper:] [:lower:] | \
  7577. < grep "^$cur" ) )
  7578. < return 0
  7579. < ;;
  7580. < -gravity)
  7581. < COMPREPLY=( $( compgen -W 'Northwest North NorthEast \
  7582. < West Center East SouthWest South SouthEast' \
  7583. < -- $cur ) )
  7584. < return 0
  7585. < ;;
  7586. < -intent)
  7587. < COMPREPLY=( $( compgen -W 'Absolute Perceptual \
  7588. < Relative Saturation' -- $cur ) )
  7589. < return 0
  7590. < ;;
  7591. < -interlace)
  7592. < COMPREPLY=( $( compgen -W 'None Line Plane Partition' \
  7593. < -- $cur ) )
  7594. < return 0
  7595. < ;;
  7596. < -limit)
  7597. < COMPREPLY=( $( compgen -W 'Disk File Map Memory' \
  7598. < -- $cur ) )
  7599. < return 0
  7600. < ;;
  7601. < -list)
  7602. < COMPREPLY=( $( compgen -W 'Delegate Format Magic \
  7603. < Module Resource Type' -- $cur ) )
  7604. < return 0
  7605. < ;;
  7606. < -map)
  7607. < COMPREPLY=( $( compgen -W 'best default gray red \
  7608. < green blue' -- $cur ) )
  7609. < _filedir
  7610. < return 0
  7611. < ;;
  7612. < -noise)
  7613. < COMPREPLY=( $( compgen -W 'Uniform Gaussian \
  7614. < Multiplicative \
  7615. < Impulse Laplacian Poisson' -- $cur ) )
  7616. < return 0
  7617. < ;;
  7618. < -preview)
  7619. < COMPREPLY=( $( compgen -W 'Rotate Shear Roll Hue \
  7620. < Saturation Brightness Gamma Spiff \
  7621. < Dull Grayscale Quantize Despeckle \
  7622. < ReduceNoise AddNoise Sharpen Blur \
  7623. < Treshold EdgeDetect Spread Shade \
  7624. < Raise Segment Solarize Swirl Implode \
  7625. < Wave OilPaint CharcoalDrawing JPEG' \
  7626. < -- $cur ) )
  7627. < return 0
  7628. < ;;
  7629. < -@(mask|profile|texture|tile|write))
  7630. < _filedir
  7631. < return 0
  7632. < ;;
  7633. < -type)
  7634. < COMPREPLY=( $( compgen -W 'Bilevel Grayscale Palette \
  7635. < PaletteMatte TrueColor TrueColorMatte \
  7636. < ColorSeparation ColorSeparationlMatte \
  7637. < Optimize' -- $cur ) )
  7638. < return 0
  7639. < ;;
  7640. < -units)
  7641. < COMPREPLY=( $( compgen -W 'Undefined PixelsPerInch \
  7642. < PixelsPerCentimeter' -- $cur ) )
  7643. < return 0
  7644. < ;;
  7645. < -virtual-pixel)
  7646. < COMPREPLY=( $( compgen -W 'Constant Edge mirror tile' \
  7647. < -- $cur ) )
  7648. < return 0
  7649. < ;;
  7650. < -visual)
  7651. < COMPREPLY=( $( compgen -W 'StaticGray GrayScale \
  7652. < StaticColor PseudoColor TrueColor \
  7653. < DirectColor defaut visualid' -- $cur ))
  7654. < return 0
  7655. < ;;
  7656. < esac
  7657. < }
  7658. <
  7659. < _convert()
  7660. < {
  7661. < local cur
  7662. <
  7663. < COMPREPLY=()
  7664. < cur=`_get_cword`
  7665. <
  7666. < _ImageMagick
  7667. <
  7668. < if [[ "$cur" == -* ]]; then
  7669. < COMPREPLY=( $( compgen -W '-adjoin -affine -antialias -append \
  7670. < -authenticate -average -background -black-threshold \
  7671. < -blue-primary -blur -border -bordercolor -channel \
  7672. < -charcoal -chop -clip -coalesce -colorize -colors \
  7673. < -colorspace -comment -compress -contrast -convolve \
  7674. < -crop -cycle -debug -deconstruct -delay -density \
  7675. < -depth -despeckle -display -dispose -dither -draw \
  7676. < -edge -emboss -encoding -endian -enhance -equalize \
  7677. < -extract -fill -filter -flatten -flip -flop -font \
  7678. < -frame -fuzz -gamma -gaussian -geometry \
  7679. < -green-primary -gravity -help -implode -intent \
  7680. < -interlace -label -lat -level -limit -list -log -loop \
  7681. < -map -mask -matte -median -modulate -monochrome \
  7682. < -morph -mosaic -negate -noop -noise -normalize \
  7683. < -opaque -ordered-dither -page -paint -ping -pointsize \
  7684. < -preview -profile -quality -raise -random-threshold \
  7685. < -region -raise -red-primary -render -resize -resample \
  7686. < -roll -rotate -sample -sampling-factor -scale -scene \
  7687. < -seed -segment -shade -sharpen -shave -shear -size \
  7688. < -solarize -spread -stroke -strokewidth -swirl \
  7689. < -texture -threshold -thumbnail -tile -transform \
  7690. < -transparent -treedepth -trim -type -undercolor \
  7691. < -units -unsharp -verbose -version -view \
  7692. < -virtual-pixel -wave -white-point -white-threshold \
  7693. < -write' -- $cur ) )
  7694. < elif [[ "$cur" == +* ]]; then
  7695. < COMPREPLY=( $( compgen -W '+adjoin +append +compress \
  7696. < +contrast +debug +dither +endian +gamma +label +map \
  7697. < +mask +matte +negate +noise +page +raise +render \
  7698. < +write' -- $cur ) )
  7699. < else
  7700. < _filedir
  7701. < fi
  7702. < }
  7703. < complete -F _convert $filenames convert
  7704. <
  7705. < _mogrify()
  7706. < {
  7707. < local cur
  7708. <
  7709. < COMPREPLY=()
  7710. < cur=`_get_cword`
  7711. <
  7712. < _ImageMagick
  7713. <
  7714. < if [[ "$cur" == -* ]]; then
  7715. < COMPREPLY=( $( compgen -W '-affine -antialias -authenticate \
  7716. < -background -black-threshold -blue-primary -blur \
  7717. < -border -bordercolor -channel -charcoal -chop \
  7718. < -colorize -colors -colorspace -comment -compress \
  7719. < -contrast -convolve -crop -cycle -debug -delay \
  7720. < -density -depth -despeckle -display -dispose -dither \
  7721. < -draw -edge -emboss -encoding -endian -enhance \
  7722. < -equalize -extract -fill -filter -flip -flop -font \
  7723. < -format -frame -fuzz -gamma -gaussian -geometry \
  7724. < -green-primary -implode -interlace -help -label -lat \
  7725. < -level -limit -list -log -loop -map -mask -matte \
  7726. < -median -modulate -monochrome -negate -noop \
  7727. < -normalize -opaque -page -paint -fill -ordered-dither \
  7728. < -pointsize -profile -quality -raise -random-threshold \
  7729. < -red-primary -region -resample -resize -roll -rotate \
  7730. < -sample -sampling-factor -scale -scene -seed -segment \
  7731. < -shade -sharpen -shear -size -solarize -spread \
  7732. < -stroke -strokewidth -swirl -texture -threshold \
  7733. < -thumbnail -tile -transform -transparent -treedepth \
  7734. < -trim -type -undercolor -units -unsharp -verbose \
  7735. < -version -view -virtual-pixel -wave -white-point \
  7736. < -white-threshold' -- $cur ) )
  7737. < elif [[ "$cur" == +* ]]; then
  7738. < COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
  7739. < +endian +gamma +label +map +mask +matte +negate +page \
  7740. < +raise' -- $cur ) )
  7741. < else
  7742. < _filedir
  7743. < fi
  7744. < }
  7745. < complete -F _mogrify $filenames mogrify
  7746. <
  7747. < _display()
  7748. < {
  7749. < local cur
  7750. <
  7751. < COMPREPLY=()
  7752. < cur=`_get_cword`
  7753. <
  7754. < _ImageMagick
  7755. <
  7756. < if [[ "$cur" == -* ]]; then
  7757. < COMPREPLY=( $( compgen -W '-authenticate -backdrop -border \
  7758. < -colormap -colors -colorspace -comment -compress \
  7759. < -contrast -crop -debug -delay -density -depth \
  7760. < -despeckle -display -dispose -dither -edge -endian \
  7761. < -enhance -extract -filter -flip -flop -frame -gamma \
  7762. < -geometry -help -immutable -interlace -label -limit \
  7763. < -log -map -matte -monochrome -negate -noop -page \
  7764. < -quality -raise -remote -roll -rotate -sample \
  7765. < -sampling-factor -scene -segment -sharpen -size \
  7766. < -texture -treedepth -trim -update -verbose -version \
  7767. < -virtual-pixel -window -window_group -write' -- $cur))
  7768. < elif [[ "$cur" == +* ]]; then
  7769. < COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
  7770. < +endian +gamma +label +map +matte +negate +page \
  7771. < +raise +write' -- $cur ) )
  7772. < else
  7773. < _filedir
  7774. < fi
  7775. < }
  7776. < complete -F _display $filenames display
  7777. <
  7778. < _animate()
  7779. < {
  7780. < local cur
  7781. <
  7782. < COMPREPLY=()
  7783. < cur=`_get_cword`
  7784. <
  7785. < _ImageMagick
  7786. <
  7787. < if [[ "$cur" == -* ]]; then
  7788. < COMPREPLY=( $( compgen -W '-authenticate -backdrop -colormap \
  7789. < -colors -colorspace -crop -debug -delay -density \
  7790. < -depth -display -dither -extract -gamma -geometry \
  7791. < -help -interlace -limit -log -matte -map -monochrome \
  7792. < -noop -pause -remote -rotate -sampling-factor -scene \
  7793. < -size -treedepth -trim -verbose -version -visual \
  7794. < -virtual-pixel -window' -- $cur ) )
  7795. < elif [[ "$cur" == +* ]]; then
  7796. < COMPREPLY=( $( compgen -W '+debug +dither +gamma +map +matte' -- $cur ) )
  7797. < else
  7798. < _filedir
  7799. < fi
  7800. < }
  7801. < complete -F _animate $filenames animate
  7802. <
  7803. < _identify()
  7804. < {
  7805. < local cur
  7806. <
  7807. < COMPREPLY=()
  7808. < cur=`_get_cword`
  7809. <
  7810. < _ImageMagick
  7811. <
  7812. < if [[ "$cur" == -* ]]; then
  7813. < COMPREPLY=( $( compgen -W '-authenticate -debug -density \
  7814. < -depth -extract -format -help -interlace -limit -list \
  7815. < -log -size -sampling-factor -verbose -version \
  7816. < -virtual-pixel' -- $cur ) )
  7817. < elif [[ "$cur" == +* ]]; then
  7818. < COMPREPLY=( $( compgen -W '+debug ' -- $cur ) )
  7819. < else
  7820. < _filedir
  7821. < fi
  7822. < }
  7823. < complete -F _identify $filenames identify
  7824. <
  7825. < _montage()
  7826. < {
  7827. < local cur
  7828. <
  7829. < COMPREPLY=()
  7830. < cur=`_get_cword`
  7831. <
  7832. < _ImageMagick
  7833. <
  7834. < if [[ "$cur" == -* ]]; then
  7835. < COMPREPLY=( $( compgen -W '-adjoin -affine -authenticate \
  7836. < -blue-primary -blur -colors -colorspace -comment \
  7837. < -compose -compress -crop -debug -density -depth \
  7838. < -display -dispose -dither -draw -encoding -endian \
  7839. < -extract -fill -filter -flip -flop -frame -gamma \
  7840. < -geometry -gravity -green-primary -interlace -help \
  7841. < -label -limit -log -matte -mode -monochrome -noop \
  7842. < -page -pointsize -quality -red-primary -resize \
  7843. < -rotate -sampling-factor -scene -shadow -size \
  7844. < -stroke -texture -thumbnail -tile -transform \
  7845. < -transparent -treedepth -trim -type -verbose \
  7846. < -version -virtual-pixel -white-point' -- $cur ) )
  7847. < elif [[ "$cur" == +* ]]; then
  7848. < COMPREPLY=( $( compgen -W '+adjoin +compress +debug +dither \
  7849. < +endian +gamma +label +matte +page' -- $cur ) )
  7850. < else
  7851. < _filedir
  7852. < fi
  7853. < }
  7854. < complete -F _montage $filenames montage
  7855. <
  7856. < _composite()
  7857. < {
  7858. < local cur
  7859. <
  7860. < COMPREPLY=()
  7861. < cur=`_get_cword`
  7862. <
  7863. < _ImageMagick
  7864. <
  7865. < if [[ "$cur" == -* ]]; then
  7866. < COMPREPLY=( $( compgen -W '-affine -authenticate \
  7867. < -blue-primary -colors -colorspace -comment -compose \
  7868. < -compress -debug -density -depth -displace -display \
  7869. < -dispose -dissolve -dither -encoding -endian -extract \
  7870. < -filter -font -geometry -gravity -green-primary -help \
  7871. < -interlace -label -limit -log -matte -monochrome \
  7872. < -negate -page -profile -quality -red-primary -rotate \
  7873. < -resize -sampling-factor -scene -sharpen -size \
  7874. < -stegano -stereo -thumbnail -tile -transform \
  7875. < -treedepth -type -units -unsharp -verbose -version \
  7876. < -virtual-pixel -watermark -white-point -write' \
  7877. < -- $cur ) )
  7878. < elif [[ "$cur" == +* ]]; then
  7879. < COMPREPLY=( $( compgen -W '+compress +debug +dither +endian +label \
  7880. < +matte +negate +page +write' -- $cur ) )
  7881. < else
  7882. < _filedir
  7883. < fi
  7884. < }
  7885. < complete -F _composite $filenames composite
  7886. < }
  7887. <
  7888. < # dd(1) completion
  7889. < #
  7890. < have dd &&
  7891. < _dd()
  7892. < {
  7893. < local cur
  7894. <
  7895. < COMPREPLY=()
  7896. < cur=`_get_cword`
  7897. <
  7898. < case "$cur" in
  7899. < if=*|of=*)
  7900. < cur=${cur#*=}
  7901. < _filedir
  7902. < return 0
  7903. < ;;
  7904. < conv=*)
  7905. < cur=${cur#*=}
  7906. < COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock \
  7907. < lcase notrunc ucase swab noerror sync' \
  7908. < -- $cur ) )
  7909. < return 0
  7910. < ;;
  7911. < esac
  7912. <
  7913. < _expand || return 0
  7914. <
  7915. < COMPREPLY=( $( compgen -W '--help --version' -- $cur ) \
  7916. < $( compgen -W 'bs cbs conv count ibs if obs of seek skip'\
  7917. < -S '=' -- $cur ) )
  7918. < } &&
  7919. < complete -F _dd $nospace $filenames dd
  7920. <
  7921. < # CUPS cancel(1) completion
  7922. < #
  7923. < have cancel &&
  7924. < _cancel()
  7925. < {
  7926. < local cur
  7927. <
  7928. < COMPREPLY=()
  7929. < cur=`_get_cword`
  7930. <
  7931. < COMPREPLY=( $( lpstat | cut -d' ' -f1 | grep "^$cur" ) )
  7932. < } &&
  7933. < complete -F _cancel $filenames cancel
  7934. <
  7935. < # aspell(1) completion
  7936. < #
  7937. < have aspell && {
  7938. < _aspell_dictionary()
  7939. < {
  7940. < local datadir
  7941. < datadir=/usr/lib/aspell
  7942. < COMPREPLY=( $( command ls $datadir/*.@(multi|alias) ) )
  7943. < COMPREPLY=( ${COMPREPLY[@]%.@(multi|alias)} )
  7944. < COMPREPLY=( $( compgen -W '${COMPREPLY[@]#$datadir/}' -- $cur ) )
  7945. < }
  7946. <
  7947. < _aspell()
  7948. < {
  7949. < local cur prev
  7950. <
  7951. < COMPREPLY=()
  7952. < cur=`_get_cword`
  7953. < prev=${COMP_WORDS[COMP_CWORD-1]}
  7954. <
  7955. < # --name value style option
  7956. < case "$prev" in
  7957. < @(-c|-p|check))
  7958. < _filedir
  7959. < return 0
  7960. < ;;
  7961. < @(dump|create|merge))
  7962. < COMPREPLY=( $( compgen -W 'master personal repl' -- $cur ) )
  7963. < return 0
  7964. < ;;
  7965. < -d)
  7966. < _aspell_dictionary
  7967. < return 0
  7968. < ;;
  7969. < esac
  7970. <
  7971. < # --name=value style option
  7972. < if [[ "$cur" == *=* ]]; then
  7973. < prev=${cur/=*/}
  7974. < cur=${cur/*=/}
  7975. < case "$prev" in
  7976. < --@(conf|personal|repl|per-conf))
  7977. < _filedir
  7978. < return 0
  7979. < ;;
  7980. < --@(conf-dir|data-dir|dict-dir|home-dir|local-data-dir|prefix))
  7981. < _filedir -d
  7982. < return 0
  7983. < ;;
  7984. < --master)
  7985. < _aspell_dictionary
  7986. < return 0
  7987. < ;;
  7988. < --mode)
  7989. < COMPREPLY=( $( compgen -W 'none url email sgml tex' -- $cur ) )
  7990. < return 0
  7991. < ;;
  7992. < --sug-mode)
  7993. < COMPREPLY=( $( compgen -W 'ultra fast normal bad-speller' -- $cur ) )
  7994. < return 0
  7995. < ;;
  7996. < --keymapping)
  7997. < COMPREPLY=( $( compgen -W 'aspell ispell' -- $cur ) )
  7998. < return 0
  7999. < ;;
  8000. < esac
  8001. < fi
  8002. <
  8003. < if [[ "$cur" == -* ]]; then
  8004. < COMPREPLY=( $( compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= \
  8005. < --encoding= --add-filter= --rem-filter= --mode= -e \
  8006. < -H -t --add-extra-dicts= --rem-extra-dicts= \
  8007. < --home-dir= -W --ignore= --ignore-accents \
  8008. < --dont-ignore-accents --ignore-case --dont-ignore-case \
  8009. < --ignore-repl --dont-ignore-repl --jargon= --keyboard= \
  8010. < --lang= --language-tag= --local-data-dir= -d --master= \
  8011. < --module= --add-module-search-order= \
  8012. < --rem-module-search-order= --per-conf= -p --personal= \
  8013. < --prefix= --repl= -C -B --run-together --dont-run-together \
  8014. < --run-together-limit= --run-together-min= --save-repl \
  8015. < --dont-save-repl --set-prefix --dont-set-prefix --size= \
  8016. < --spelling= --strip-accents --dont-strip-accents \
  8017. < --sug-mode= --add-word-list-path= --rem-word-list-path= \
  8018. < -b -x --backup -b|-x --dont-backup --reverse --dont-reverse \
  8019. < --time --dont-time --keymapping= --add-email-quote= \
  8020. < --rem-email-quote= --email-margin= --add-tex-command= \
  8021. < --rem-tex-command= --tex-check-comments \
  8022. < --dont-tex-check-comments --add-tex-extension= \
  8023. < --rem-tex-extension= --add-sgml-check= --rem-sgml-check= \
  8024. < --add-sgml-extension= --rem-sgml-extension=' -- $cur ) )
  8025. < else
  8026. < COMPREPLY=( $( compgen -W '-? help -c check -a pipe -l list \
  8027. < config config soundslike filter -v version dump \
  8028. < create merge' -- $cur ) )
  8029. < fi
  8030. <
  8031. < }
  8032. < complete -F _aspell $default aspell
  8033. < }
  8034. <
  8035. < # xmms(1) completion
  8036. < #
  8037. < have xmms &&
  8038. < _xmms()
  8039. < {
  8040. < local cur
  8041. <
  8042. < COMPREPLY=()
  8043. < cur=`_get_cword`
  8044. <
  8045. < if [[ "$cur" == -* ]]; then
  8046. < COMPREPLY=( $( compgen -W '-h --help -r --rew -p --play \
  8047. < -u --pause -s --stop -t --play-pause -f --fwd -e \
  8048. < --enqueue -m --show-main-window -i --sm-client-id \
  8049. < -v --version' -- $cur ) )
  8050. < else
  8051. < _filedir '@(mp[23]|MP[23]|ogg|OGG|wav|WAV|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)'
  8052. <
  8053. < fi
  8054. <
  8055. < } &&
  8056. < complete -F _xmms $filenames xmms
  8057. <
  8058. < # info(1) completion
  8059. < #
  8060. < have info &&
  8061. < _info()
  8062. < {
  8063. < local cur infopath UNAME
  8064. <
  8065. < COMPREPLY=()
  8066. < cur=`_get_cword`
  8067. <
  8068. < _expand || return 0
  8069. <
  8070. < # default completion if parameter contains /
  8071. < if [[ "$cur" == */* ]]; then
  8072. < _filedir
  8073. < return 0
  8074. < fi
  8075. <
  8076. < infopath='/usr/share/info'
  8077. <
  8078. < if [ "${INFOPATH: -1:1}" == ':' ]; then
  8079. < infopath=${INFOPATH}${infopath}
  8080. < elif [ ${INFOPATH:+set} ]; then
  8081. < infopath=$INFOPATH
  8082. < fi
  8083. <
  8084. < infopath=$infopath:
  8085. < if [ -n "$cur" ]; then
  8086. < infopath="${infopath//://$cur* }"
  8087. < else
  8088. < infopath="${infopath//:// }"
  8089. < fi
  8090. <
  8091. < # redirect stderr for when path doesn't exist
  8092. < COMPREPLY=( $( eval command ls "$infopath" 2>/dev/null ) )
  8093. < # weed out directory path names and paths to info pages
  8094. < COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
  8095. < # weed out info dir file
  8096. < for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do
  8097. < if [ "${COMPREPLY[$i]}" == 'dir' ]; then
  8098. < unset COMPREPLY[$i];
  8099. < fi;
  8100. < done
  8101. < # strip suffix from info pages
  8102. < COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2)} )
  8103. < COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
  8104. <
  8105. < return 0
  8106. < } &&
  8107. < complete -F _info $filenames info
  8108. <
  8109. < # dhclient(1) completion
  8110. < #
  8111. < have dhclient && _dhclient()
  8112. < {
  8113. < local cur prev
  8114. <
  8115. < COMPREPLY=()
  8116. < cur=`_get_cword`
  8117. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8118. <
  8119. < case "$prev" in
  8120. < -@(cf|lf|pf|sf))
  8121. < _filedir
  8122. < return 0
  8123. < ;;
  8124. < -s)
  8125. < _known_hosts
  8126. < return 0
  8127. < ;;
  8128. < esac
  8129. <
  8130. < if [[ "$cur" == -* ]]; then
  8131. < COMPREPLY=( $( compgen -W '-p -d -q -1 -r -lf -pf \
  8132. < -cf -sf -s -g -n -nw -w' -- $cur ) )
  8133. < else
  8134. < _available_interfaces
  8135. < fi
  8136. < } &&
  8137. < complete -F _dhclient dhclient
  8138. <
  8139. < # lvm(8) completion
  8140. < #
  8141. < have lvm && {
  8142. < _volumegroups()
  8143. < {
  8144. < COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \
  8145. < sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- $cur ) )
  8146. < }
  8147. <
  8148. < _physicalvolumes()
  8149. < {
  8150. < COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \
  8151. < sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- $cur ) )
  8152. < }
  8153. <
  8154. < _logicalvolumes()
  8155. < {
  8156. < COMPREPLY=( $(compgen -W "$( lvscan 2>/dev/null | \
  8157. < sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- $cur ) )
  8158. < }
  8159. <
  8160. < _units()
  8161. < {
  8162. < COMPREPLY=( $( compgen -W 'h s b k m g t H K M G T' -- $cur ) )
  8163. < }
  8164. <
  8165. < _sizes()
  8166. < {
  8167. < COMPREPLY=( $( compgen -W 'k K m M g G t T' -- $cur ) )
  8168. < }
  8169. <
  8170. < _args()
  8171. < {
  8172. < args=0
  8173. < if [[ "${COMP_WORDS[0]}" == lvm ]]; then
  8174. < offset=2
  8175. < else
  8176. < offset=1
  8177. < fi
  8178. < for (( i=$offset; i < COMP_CWORD; i++ )); do
  8179. < if [[ "${COMP_WORDS[i]}" != -* ]]; then
  8180. < args=$(($args + 1))
  8181. < fi
  8182. < done
  8183. < }
  8184. <
  8185. < _lvmdiskscan()
  8186. < {
  8187. < local cur
  8188. <
  8189. < COMPREPLY=()
  8190. < cur=`_get_cword`
  8191. <
  8192. < if [[ "$cur" == -* ]]; then
  8193. < COMPREPLY=( $( compgen -W '-d --debug -h -? --help -l \
  8194. < --lvmpartition -v --verbose --version' -- $cur ) )
  8195. < fi
  8196. < }
  8197. < complete -F _lvmdiskscan lvmdiskscan
  8198. <
  8199. < _pvscan()
  8200. < {
  8201. < local cur
  8202. <
  8203. < COMPREPLY=()
  8204. < cur=`_get_cword`
  8205. <
  8206. < if [[ "$cur" == -* ]]; then
  8207. < COMPREPLY=( $( compgen -W '-d --debug -e \
  8208. < --exported -n --novolumegroup -h -? \
  8209. < --help --ignorelockingfailure -P \
  8210. < --partial -s --short -u --uuid -v \
  8211. < --verbose --version' -- $cur ) )
  8212. < fi
  8213. < }
  8214. < complete -F _pvscan pvscan
  8215. <
  8216. < _pvs()
  8217. < {
  8218. < local cur prev
  8219. <
  8220. < COMPREPLY=()
  8221. < cur=`_get_cword`
  8222. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8223. <
  8224. < case "$prev" in
  8225. < -@(o|O|-options|-sort))
  8226. < COMPREPLY=( $( compgen -W 'pv_fmt pv_uuid \
  8227. < pv_size pv_free pv_used pv_name \
  8228. < pv_attr pv_pe_count \
  8229. < pv_pe_alloc_count' -- $cur ) )
  8230. < return 0
  8231. < ;;
  8232. < --units)
  8233. < _units
  8234. < return 0
  8235. < ;;
  8236. < esac
  8237. <
  8238. < if [[ "$cur" == -* ]]; then
  8239. < COMPREPLY=( $( compgen -W '--aligned -a --all -d --debug \
  8240. < -h -? --help --ignorelockingfailure --noheadings \
  8241. < --nosuffix -o --options -O --sort \
  8242. < --separator --unbuffered --units \
  8243. < -v --verbose --version' -- $cur ) )
  8244. < else
  8245. < _physicalvolumes
  8246. < fi
  8247. < }
  8248. < complete -F _pvs pvs
  8249. <
  8250. < _pvdisplay()
  8251. < {
  8252. < local cur prev
  8253. <
  8254. < COMPREPLY=()
  8255. < cur=`_get_cword`
  8256. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8257. <
  8258. < case "$prev" in
  8259. < --units)
  8260. < _units
  8261. < return 0
  8262. < ;;
  8263. < esac
  8264. <
  8265. < if [[ "$cur" == -* ]]; then
  8266. < COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
  8267. < -v --verbose -d --debug -h --help --version' -- $cur ) )
  8268. < else
  8269. < _physicalvolumes
  8270. < fi
  8271. < }
  8272. < complete -F _pvdisplay pvdisplay
  8273. <
  8274. < _pvchange()
  8275. < {
  8276. < local cur prev
  8277. <
  8278. < COMPREPLY=()
  8279. < cur=`_get_cword`
  8280. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8281. <
  8282. < case "$prev" in
  8283. < -@(A|x|-autobackup|--allocatable))
  8284. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8285. < return 0
  8286. < ;;
  8287. < esac
  8288. <
  8289. < if [[ "$cur" == -* ]]; then
  8290. < COMPREPLY=( $( compgen -W '-a --all -A --autobackup \
  8291. < -d --debug -h --help -t --test -u --uuid -x \
  8292. < --allocatable -v --verbose --addtag --deltag \
  8293. < --version' -- $cur ) )
  8294. < else
  8295. < _physicalvolumes
  8296. < fi
  8297. < }
  8298. < complete -F _pvchange pvchange
  8299. <
  8300. < _pvcreate()
  8301. < {
  8302. < local cur prev
  8303. <
  8304. < COMPREPLY=()
  8305. < cur=`_get_cword`
  8306. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8307. <
  8308. < case "$prev" in
  8309. < --restorefile)
  8310. < _filedir
  8311. < return 0
  8312. < ;;
  8313. < -@(M|-metadatatype))
  8314. < COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
  8315. < return 0
  8316. < ;;
  8317. < --metadatacopies)
  8318. < COMPREPLY=( $( compgen -W '0 1 2' -- $cur ) )
  8319. < return 0
  8320. < ;;
  8321. < --@(metadatasize|setphysicalvolumesize))
  8322. < _sizes
  8323. < return 0
  8324. < ;;
  8325. < esac
  8326. <
  8327. < if [[ "$cur" == -* ]]; then
  8328. < COMPREPLY=( $( compgen -W '--restorefile -d --debug -f \
  8329. < --force -h -? --help --labelsector -M --metadatatype \
  8330. < --metadatacopies --metadatasize \
  8331. < --setphysicalvolumesize -t --test -u --uuid uuid -v \
  8332. < --verbose -y --yes --version' -- $cur ) )
  8333. < else
  8334. < _physicalvolumes
  8335. < fi
  8336. < }
  8337. < complete -F _pvcreate pvcreate
  8338. <
  8339. < _pvmove()
  8340. < {
  8341. < local cur prev
  8342. <
  8343. < COMPREPLY=()
  8344. < cur=`_get_cword`
  8345. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8346. <
  8347. < case "$prev" in
  8348. < -@(A|-autobackup))
  8349. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8350. < return 0
  8351. < ;;
  8352. < -@(n|-name))
  8353. < _logicalvolumes
  8354. < return 0
  8355. < esac
  8356. <
  8357. < if [[ "$cur" == -* ]]; then
  8358. < COMPREPLY=( $( compgen -W '--abort -A --autobackup \
  8359. < -b --background -d --debug -f --force -h -? \
  8360. < --help -i --interval -t --test -v --verbose \
  8361. < --version -n --name' -- $cur ) )
  8362. < else
  8363. < _physicalvolumes
  8364. < fi
  8365. < }
  8366. < complete -F _pvmove pvmove
  8367. <
  8368. < _pvremove()
  8369. < {
  8370. < local cur
  8371. <
  8372. < COMPREPLY=()
  8373. < cur=`_get_cword`
  8374. <
  8375. < if [[ "$cur" == -* ]]; then
  8376. < COMPREPLY=( $( compgen -W '-d --debug -f --force -h -? \
  8377. < --help -y --yes -t --test -v --verbose \
  8378. < --version' -- $cur ) )
  8379. < else
  8380. < _physicalvolumes
  8381. < fi
  8382. < }
  8383. < complete -F _pvremove pvremove
  8384. <
  8385. < _vgscan()
  8386. < {
  8387. < local cur
  8388. <
  8389. < COMPREPLY=()
  8390. < cur=`_get_cword`
  8391. <
  8392. < if [[ "$cur" == -* ]]; then
  8393. < COMPREPLY=( $( compgen -W '-d --debug -h --help \
  8394. < --ignorelockingfailure --mknodes -P \
  8395. < --partial -v --verbose --version' -- $cur ) )
  8396. < fi
  8397. < }
  8398. < complete -F _vgscan vgscan
  8399. <
  8400. < _vgs()
  8401. < {
  8402. < local cur prev
  8403. <
  8404. < COMPREPLY=()
  8405. < cur=`_get_cword`
  8406. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8407. <
  8408. < case "$prev" in
  8409. < -@(o|O|-options|-sort))
  8410. < COMPREPLY=( $( compgen -W 'vg_fmt vg_uuid vg_name \
  8411. < vg_attr vg_size vg_free vg_sysid \
  8412. < vg_extent_size vg_extent_count vg_free_count \
  8413. < max_lv max_pv pv_count lv_count snap_count \
  8414. < vg_seqno' -- $cur ) )
  8415. < return 0
  8416. < ;;
  8417. < --units)
  8418. < _units
  8419. < return 0
  8420. < ;;
  8421. < esac
  8422. <
  8423. < if [[ "$cur" == -* ]]; then
  8424. < COMPREPLY=( $( compgen -W '--aligned -d --debug \
  8425. < -h --help --ignorelockingfailure --noheadings \
  8426. < --nosuffix -o --options -O --sort -P --partial \
  8427. < --separator --unbuffered --units \
  8428. < -v --verbose --version' -- $cur ) )
  8429. < else
  8430. < _volumegroups
  8431. < fi
  8432. < }
  8433. < complete -F _vgs vgs
  8434. <
  8435. < _vgdisplay()
  8436. < {
  8437. < local cur prev
  8438. <
  8439. < COMPREPLY=()
  8440. < cur=`_get_cword`
  8441. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8442. <
  8443. < case "$prev" in
  8444. < --units)
  8445. < _units
  8446. < return 0
  8447. < ;;
  8448. < esac
  8449. <
  8450. < if [[ "$cur" == -* ]]; then
  8451. < COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
  8452. < -P --partial -A --activevolumegroups -v --verbose \
  8453. < -d --debug -h --help --version' -- $cur ) )
  8454. < else
  8455. < _volumegroups
  8456. < fi
  8457. < }
  8458. < complete -F _vgdisplay vgdisplay
  8459. <
  8460. < _vgchange()
  8461. < {
  8462. < local cur prev
  8463. <
  8464. < COMPREPLY=()
  8465. < cur=`_get_cword`
  8466. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8467. <
  8468. < case "$prev" in
  8469. < -@(a|A|x|-available|-autobackup|-resizeable))
  8470. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8471. < return 0
  8472. < ;;
  8473. < esac
  8474. <
  8475. < if [[ "$cur" == -* ]]; then
  8476. < COMPREPLY=( $( compgen -W '-A --autobackup --alloc -P \
  8477. < --partial -d --debug -h --help --ignorelockingfailure \
  8478. < -t --test -u --uuid -v --verbose --version -a \
  8479. < --available -x --resizeable -l --logicalvolume \
  8480. < --addtag --deltag' -- $cur ) )
  8481. < else
  8482. < _volumegroups
  8483. < fi
  8484. < }
  8485. < complete -F _vgchange vgchange
  8486. <
  8487. < _vgcreate()
  8488. < {
  8489. < local cur prev
  8490. <
  8491. < COMPREPLY=()
  8492. < cur=`_get_cword`
  8493. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8494. <
  8495. < case "$prev" in
  8496. < -@(A|-autobackup))
  8497. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8498. < return 0
  8499. < ;;
  8500. < -@(M|-metadatatype))
  8501. < COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
  8502. < return 0
  8503. < ;;
  8504. < -@(s|-physicalextentsize))
  8505. < _sizes
  8506. < return 0
  8507. < ;;
  8508. < esac
  8509. <
  8510. < if [[ "$cur" == -* ]]; then
  8511. < COMPREPLY=( $( compgen -W '-A --autobackup --addtag \
  8512. < --alloc -d --debug -h --help -l --maxlogicalvolumes \
  8513. < -M --metadatatype -p --maxphysicalvolumes -s \
  8514. < --physicalextentsize -t --test -v --verbose \
  8515. < --version' -- $cur ) )
  8516. < else
  8517. < _args
  8518. < if [ $args -eq 0 ]; then
  8519. < _volumegroups
  8520. < else
  8521. < _physicalvolumes
  8522. < fi
  8523. < fi
  8524. < }
  8525. < complete -F _vgcreate vgcreate
  8526. <
  8527. < _vgremove()
  8528. < {
  8529. < local cur
  8530. <
  8531. < COMPREPLY=()
  8532. < cur=`_get_cword`
  8533. <
  8534. < if [[ "$cur" == -* ]]; then
  8535. < COMPREPLY=( $( compgen -W '-d --debug -h --help -t --test \
  8536. < -v --verbose --version' -- $cur ) )
  8537. < else
  8538. < _volumegroups
  8539. < fi
  8540. < }
  8541. < complete -F _vgremove vgremove
  8542. <
  8543. < _vgrename()
  8544. < {
  8545. < local cur prev
  8546. <
  8547. < COMPREPLY=()
  8548. < cur=`_get_cword`
  8549. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8550. <
  8551. < case "$prev" in
  8552. < -@(A|-autobackup))
  8553. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8554. < return 0
  8555. < ;;
  8556. < esac
  8557. <
  8558. < if [[ "$cur" == -* ]]; then
  8559. < COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
  8560. < -? --help -t --test -v --verbose --version' -- $cur ) )
  8561. < else
  8562. < _volumegroups
  8563. < fi
  8564. < }
  8565. < complete -F _vgrename vgrename
  8566. <
  8567. < _vgreduce()
  8568. < {
  8569. < local cur prev
  8570. <
  8571. < COMPREPLY=()
  8572. < cur=`_get_cword`
  8573. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8574. <
  8575. < case "$prev" in
  8576. < -@(A|-autobackup))
  8577. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8578. < return 0
  8579. < ;;
  8580. < esac
  8581. <
  8582. < if [[ "$cur" == -* ]]; then
  8583. < COMPREPLY=( $( compgen -W '-a --all -A --autobackup -d \
  8584. < --debug -h --help --removemissing -t --test -v \
  8585. < --verbose --version' -- $cur ) )
  8586. <
  8587. < else
  8588. < _args
  8589. < if [ $args -eq 0 ]; then
  8590. < _volumegroups
  8591. < else
  8592. < _physicalvolumes
  8593. < fi
  8594. < fi
  8595. < }
  8596. < complete -F _vgreduce vgreduce
  8597. <
  8598. < _vgextend()
  8599. < {
  8600. < local cur prev
  8601. <
  8602. < COMPREPLY=()
  8603. < cur=`_get_cword`
  8604. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8605. <
  8606. < case "$prev" in
  8607. < -@(A|-autobackup))
  8608. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8609. < return 0
  8610. < ;;
  8611. < -@(L|-size))
  8612. < _sizes
  8613. < return 0
  8614. < ;;
  8615. < esac
  8616. <
  8617. < if [[ "$cur" == -* ]]; then
  8618. < COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
  8619. < -? --help -t --test -v --verbose --version' -- $cur ) )
  8620. < else
  8621. < _args
  8622. < if [ $args -eq 0 ]; then
  8623. < _volumegroups
  8624. < else
  8625. < _physicalvolumes
  8626. < fi
  8627. < fi
  8628. < }
  8629. < complete -F _vgextend vgextend
  8630. <
  8631. < _vgport()
  8632. < {
  8633. < local cur prev
  8634. <
  8635. < COMPREPLY=()
  8636. < cur=`_get_cword`
  8637. <
  8638. < if [[ "$cur" == -* ]]; then
  8639. < COMPREPLY=( $( compgen -W '-a --all -d --debug -h \
  8640. < -? --help -v --verbose --version' -- $cur ) )
  8641. < else
  8642. < _volumegroups
  8643. < fi
  8644. < }
  8645. < complete -F _vgport vgimport vgexport
  8646. <
  8647. < _vgck()
  8648. < {
  8649. < local cur prev
  8650. <
  8651. < COMPREPLY=()
  8652. < cur=`_get_cword`
  8653. <
  8654. < if [[ "$cur" == -* ]]; then
  8655. < COMPREPLY=( $( compgen -W '-d --debug -h \
  8656. < -? --help -v --verbose --version' -- $cur ) )
  8657. < else
  8658. < _volumegroups
  8659. < fi
  8660. < }
  8661. < complete -F _vgck vgck
  8662. <
  8663. < _vgconvert()
  8664. < {
  8665. < local cur prev
  8666. <
  8667. < COMPREPLY=()
  8668. < cur=`_get_cword`
  8669. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8670. <
  8671. < case "$prev" in
  8672. < -@(M|-metadatatype))
  8673. < COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
  8674. < return 0
  8675. < ;;
  8676. < --metadatacopies)
  8677. < COMPREPLY=( $( compgen -W '0 1 2' -- $cur ) )
  8678. < return 0
  8679. < ;;
  8680. < --metadatasize)
  8681. < _sizes
  8682. < return 0
  8683. < ;;
  8684. < esac
  8685. <
  8686. < if [[ "$cur" == -* ]]; then
  8687. < COMPREPLY=( $( compgen -W '-d --debug -h --help --labelsector \
  8688. < -M --metadatatype --metadatacopies --metadatasize \
  8689. < -t --test -v --verbose --version' -- $cur ) )
  8690. < else
  8691. < _volumegroups
  8692. < fi
  8693. < }
  8694. < complete -F _vgconvert vgconvert
  8695. <
  8696. < _vgcfgbackup()
  8697. < {
  8698. < local cur prev
  8699. <
  8700. < COMPREPLY=()
  8701. < cur=`_get_cword`
  8702. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8703. <
  8704. < case "$prev" in
  8705. < -@(f|-file))
  8706. < _filedir
  8707. < return 0
  8708. < ;;
  8709. < esac
  8710. <
  8711. < if [[ "$cur" == -* ]]; then
  8712. < COMPREPLY=( $( compgen -W '-d --debug -f --file -h --help \
  8713. < --ignorelockingfailure -P --partial -v --verbose \
  8714. < --version' -- $cur ) )
  8715. < else
  8716. < _volumegroups
  8717. < fi
  8718. < }
  8719. < complete -F _vgcfgbackup vgcfgbackup
  8720. <
  8721. < _vgcfgrestore()
  8722. < {
  8723. < local cur prev
  8724. <
  8725. < COMPREPLY=()
  8726. < cur=`_get_cword`
  8727. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8728. <
  8729. < case "$prev" in
  8730. < -@(f|-file))
  8731. < _filedir
  8732. < return 0
  8733. < ;;
  8734. < -@(M|-metadatatype))
  8735. < COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
  8736. < return 0
  8737. < ;;
  8738. < -@(n|-name))
  8739. < _volumegroups
  8740. < return 0
  8741. < ;;
  8742. < esac
  8743. <
  8744. < if [[ "$cur" == -* ]]; then
  8745. < COMPREPLY=( $( compgen -W '-d --debug -f --file -l --list \
  8746. < -h --help -M --Metadatatype -n --name -t --test \
  8747. < -v --verbose --version' -- $cur ) )
  8748. < else
  8749. < _volumegroups
  8750. < fi
  8751. < }
  8752. < complete -F _vgcfgrestore vgcfgrestore
  8753. <
  8754. < _vgmerge()
  8755. < {
  8756. < local cur prev
  8757. <
  8758. < COMPREPLY=()
  8759. < cur=`_get_cword`
  8760. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8761. <
  8762. < case "$prev" in
  8763. < -@(A|-autobackup))
  8764. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8765. < return 0
  8766. < ;;
  8767. < esac
  8768. <
  8769. < if [[ "$cur" == -* ]]; then
  8770. < COMPREPLY=( $( compgen -W '-A --autobackup -d --debug \
  8771. < -h --help -l --list -t --test -v --verbose \
  8772. < --version' -- $cur ) )
  8773. < else
  8774. < _volumegroups
  8775. < fi
  8776. < }
  8777. < complete -F _vgmerge vgmerge
  8778. <
  8779. < _vgsplit()
  8780. < {
  8781. < local cur prev
  8782. <
  8783. < COMPREPLY=()
  8784. < cur=`_get_cword`
  8785. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8786. <
  8787. < case "$prev" in
  8788. < -@(A|-autobackup))
  8789. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8790. < return 0
  8791. < ;;
  8792. < -@(M|-metadatatype))
  8793. < COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
  8794. < return 0
  8795. < ;;
  8796. < esac
  8797. <
  8798. < if [[ "$cur" == -* ]]; then
  8799. < COMPREPLY=( $( compgen -W '-A --autobackup -d --debug \
  8800. < -h --help -l --list -M --metadatatype -t --test \
  8801. < -v --verbose --version' -- $cur ) )
  8802. < else
  8803. < _args
  8804. < if [ $args -eq 0 -o $args -eq 1 ]; then
  8805. < _volumegroups
  8806. < else
  8807. < _physicalvolumes
  8808. < fi
  8809. < fi
  8810. < }
  8811. < complete -F _vgsplit vgsplit
  8812. <
  8813. < _vgmknodes()
  8814. < {
  8815. < local cur
  8816. <
  8817. < COMPREPLY=()
  8818. < cur=`_get_cword`
  8819. <
  8820. < if [[ "$cur" == -* ]]; then
  8821. < COMPREPLY=( $( compgen -W '-d --debug -h --help -v --verbose \
  8822. < --version' -- $cur ) )
  8823. < else
  8824. < _volumegroups
  8825. < fi
  8826. < }
  8827. < complete -F _vgmknodes vgmknodes
  8828. <
  8829. < _lvscan()
  8830. < {
  8831. < local cur
  8832. <
  8833. < COMPREPLY=()
  8834. < cur=`_get_cword`
  8835. <
  8836. < if [[ "$cur" == -* ]]; then
  8837. < COMPREPLY=( $( compgen -W '-b --blockdevice -d --debug \
  8838. < -h -? --help --ignorelockingfailure -P \
  8839. < --partial -v --verbose --version' -- $cur ) )
  8840. < fi
  8841. < }
  8842. < complete -F _lvscan lvscan
  8843. <
  8844. < _lvs()
  8845. < {
  8846. < local cur prev
  8847. <
  8848. < COMPREPLY=()
  8849. < cur=`_get_cword`
  8850. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8851. <
  8852. < case "$prev" in
  8853. < -@(o|O|-options|-sort))
  8854. < COMPREPLY=( $( compgen -W 'lv_uuid lv_name \
  8855. < lv_attr lv_minor lv_size seg_count \
  8856. < origin snap_percent segtype stripes \
  8857. < stripesize chunksize seg_start \
  8858. < seg_size' -- $cur ) )
  8859. < return 0
  8860. < ;;
  8861. < --units)
  8862. < _units
  8863. < return 0
  8864. < ;;
  8865. < esac
  8866. <
  8867. < if [[ "$cur" == -* ]]; then
  8868. < COMPREPLY=( $( compgen -W '--aligned -d --debug \
  8869. < -h --help --ignorelockingfailure --noheadings \
  8870. < --nosuffix -o --options -O --sort -P --partial \
  8871. < --segments --separator --unbuffered --units \
  8872. < -v --verbose --version' -- $cur ) )
  8873. < else
  8874. < _logicalvolumes
  8875. < fi
  8876. < }
  8877. < complete -F _lvs lvs
  8878. <
  8879. < _lvdisplay()
  8880. < {
  8881. < local cur prev
  8882. <
  8883. < COMPREPLY=()
  8884. < cur=`_get_cword`
  8885. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8886. <
  8887. < case "$prev" in
  8888. < --units)
  8889. < _units
  8890. < return 0
  8891. < ;;
  8892. < esac
  8893. <
  8894. < if [[ "$cur" == -* ]]; then
  8895. < COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
  8896. < -P --partial -m --maps -v --verbose -d --debug -h \
  8897. < --help --version' -- $cur ) )
  8898. < else
  8899. < _logicalvolumes
  8900. < fi
  8901. < }
  8902. < complete -F _lvdisplay lvdisplay
  8903. <
  8904. < _lvchange()
  8905. < {
  8906. < local cur prev
  8907. <
  8908. < COMPREPLY=()
  8909. < cur=`_get_cword`
  8910. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8911. <
  8912. < case "$prev" in
  8913. < -@(a|A|C|M|-available|-autobackup|-continguous|-persistent))
  8914. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8915. < return 0
  8916. < ;;
  8917. < -@(p|-permission))
  8918. < COMPREPLY=( $( compgen -W 'r rw' -- $cur ) )
  8919. < return 0
  8920. < ;;
  8921. < esac
  8922. <
  8923. < if [[ "$cur" == -* ]]; then
  8924. < COMPREPLY=( $( compgen -W '-A --autobackup -a --available \
  8925. < --addtag --alloc -C --contiguous -d --debug --deltag \
  8926. < -f --force -h --help --ignorelockingfailure -M \
  8927. < --persistent --major major --minor minor -P --partial \
  8928. < -p --permission -r --readahead --refresh -t --test \
  8929. < -v --verbose --version' -- $cur ) )
  8930. < else
  8931. < _logicalvolumes
  8932. < fi
  8933. < }
  8934. < complete -F _lvchange lvchange
  8935. <
  8936. < _lvcreate()
  8937. < {
  8938. < local cur prev
  8939. <
  8940. < COMPREPLY=()
  8941. < cur=`_get_cword`
  8942. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8943. <
  8944. < case "$prev" in
  8945. < -@(A|C|M|Z|-autobackup|-continguous|-persistent|-zero))
  8946. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8947. < return 0
  8948. < ;;
  8949. < -@(L|-size))
  8950. < _sizes
  8951. < return 0
  8952. < ;;
  8953. < -@(p|-permission))
  8954. < COMPREPLY=( $( compgen -W 'r rw' -- $cur ) )
  8955. < return 0
  8956. < ;;
  8957. < -@(n|-name))
  8958. < _logicalvolumes
  8959. < return 0
  8960. < ;;
  8961. < esac
  8962. <
  8963. < if [[ "$cur" == -* ]]; then
  8964. < COMPREPLY=( $( compgen -W '-A --autobackup --addtag --alloc \
  8965. < -C --contiguous -d --debug -h -? --help -i --stripes \
  8966. < -I --stripesize -l --extents -L --size -M --persistent \
  8967. < --major --minor -n --name -p --permission -r \
  8968. < --readahead -t --test --type -v --verbose -Z --zero \
  8969. < --version' -- $cur ) )
  8970. < else
  8971. < _args
  8972. < if [ $args -eq 0 ]; then
  8973. < _volumegroups
  8974. < else
  8975. < _physicalvolumes
  8976. < fi
  8977. < fi
  8978. < }
  8979. < complete -F _lvcreate lvcreate
  8980. <
  8981. < _lvremove()
  8982. < {
  8983. < local cur prev
  8984. <
  8985. < COMPREPLY=()
  8986. < cur=`_get_cword`
  8987. < prev=${COMP_WORDS[COMP_CWORD-1]}
  8988. <
  8989. < case "$prev" in
  8990. < -@(A|-autobackup))
  8991. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  8992. < return 0
  8993. < ;;
  8994. < esac
  8995. <
  8996. < if [[ "$cur" == -* ]]; then
  8997. < COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -f \
  8998. < --force -h -? --help -t --test -v --verbose \
  8999. < --version' -- $cur ) )
  9000. < else
  9001. < _logicalvolumes
  9002. < fi
  9003. < }
  9004. < complete -F _lvremove lvremove
  9005. <
  9006. < _lvrename()
  9007. < {
  9008. < local cur prev
  9009. <
  9010. < COMPREPLY=()
  9011. < cur=`_get_cword`
  9012. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9013. <
  9014. < case "$prev" in
  9015. < -@(A|-autobackup))
  9016. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  9017. < return 0
  9018. < ;;
  9019. < esac
  9020. <
  9021. < if [[ "$cur" == -* ]]; then
  9022. < COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
  9023. < -? --help -t --test -v --verbose --version' -- $cur ) )
  9024. < else
  9025. < _logicalvolumes
  9026. < fi
  9027. < }
  9028. < complete -F _lvrename lvrename
  9029. <
  9030. < _lvreduce()
  9031. < {
  9032. < local cur prev
  9033. <
  9034. < COMPREPLY=()
  9035. < cur=`_get_cword`
  9036. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9037. <
  9038. < case "$prev" in
  9039. < -@(A|-autobackup))
  9040. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  9041. < return 0
  9042. < ;;
  9043. < -@(L|-size))
  9044. < _sizes
  9045. < return 0
  9046. < ;;
  9047. < esac
  9048. <
  9049. < if [[ "$cur" == -* ]]; then
  9050. < COMPREPLY=( $( compgen -W '-A --autobackup -d \
  9051. < --debug -f --force -h --help -l --extents \
  9052. < -L --size -n --nofsck -r --resizefs -t --test \
  9053. < -v --verbose --version' -- $cur ) )
  9054. < else
  9055. < _logicalvolumes
  9056. < fi
  9057. < }
  9058. < complete -F _lvreduce lvreduce
  9059. <
  9060. < _lvresize()
  9061. < {
  9062. < local cur prev
  9063. <
  9064. < COMPREPLY=()
  9065. < cur=`_get_cword`
  9066. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9067. <
  9068. < case "$prev" in
  9069. < -@(A|-autobackup))
  9070. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  9071. < return 0
  9072. < ;;
  9073. < -@(L|-size))
  9074. < _sizes
  9075. < return 0
  9076. < ;;
  9077. < esac
  9078. <
  9079. < if [[ "$cur" == -* ]]; then
  9080. < COMPREPLY=( $( compgen -W '-A --autobackup --alloc -d \
  9081. < --debug -h --help -i --stripes -I --stripesize \
  9082. < -l --extents -L --size -n --nofsck -r --resizefs \
  9083. < -t --test --type -v --verbose --version' -- $cur ) )
  9084. < else
  9085. < _args
  9086. < if [ $args -eq 0 ]; then
  9087. < _logicalvolumes
  9088. < else
  9089. < _physicalvolumes
  9090. < fi
  9091. < fi
  9092. < }
  9093. < complete -F _lvresize lvresize
  9094. <
  9095. < _lvextend()
  9096. < {
  9097. < local cur prev
  9098. <
  9099. < COMPREPLY=()
  9100. < cur=`_get_cword`
  9101. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9102. <
  9103. < case "$prev" in
  9104. < -@(A|-autobackup))
  9105. < COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
  9106. < return 0
  9107. < ;;
  9108. < -@(L|-size))
  9109. < _sizes
  9110. < return 0
  9111. < ;;
  9112. < esac
  9113. <
  9114. < if [[ "$cur" == -* ]]; then
  9115. < COMPREPLY=( $( compgen -W '-A --autobackup --alloc -d \
  9116. < --debug -h --help -i --stripes -I --stripesize \
  9117. < -l --extents -L --size -n --nofsck -r --resizefs \
  9118. < -t --test --type -v --verbose --version' -- $cur ) )
  9119. < else
  9120. < _args
  9121. < if [ $args -eq 0 ]; then
  9122. < _logicalvolumes
  9123. < else
  9124. < _physicalvolumes
  9125. < fi
  9126. < fi
  9127. < }
  9128. < complete -F _lvextend lvextend
  9129. <
  9130. < _lvm()
  9131. < {
  9132. < local prev
  9133. <
  9134. < COMPREPLY=()
  9135. < cur=`_get_cword`
  9136. <
  9137. < if [ $COMP_CWORD -eq 1 ]; then
  9138. < COMPREPLY=( $( compgen -W 'dumpconfig help lvchange \
  9139. < lvcreate lvdisplay lvextend lvmchange \
  9140. < lvmdiskscan lvmsadc lvmsar lvreduce \
  9141. < lvremove lvrename lvresize lvs lvscan \
  9142. < pvchange pvcreate pvdata pvdisplay pvmove \
  9143. < pvremove pvresize pvs pvscan vgcfgbackup \
  9144. < vgcfgrestore vgchange vgck vgconvert \
  9145. < vgcreate vgdisplay vgexport vgextend \
  9146. < vgimport vgmerge vgmknodes vgreduce \
  9147. < vgremove vgrename vgs vgscan vgsplit \
  9148. < version' -- $cur ) )
  9149. < else
  9150. < case ${COMP_WORDS[1]} in
  9151. < pvchange)
  9152. < _pvchange
  9153. < ;;
  9154. < pvcreate)
  9155. < _pvcreate
  9156. < ;;
  9157. < pvdisplay)
  9158. < _pvdisplay
  9159. < ;;
  9160. < pvmove)
  9161. < _pvmove
  9162. < ;;
  9163. < pvremove)
  9164. < _pvremove
  9165. < ;;
  9166. < pvresize)
  9167. < _pvresize
  9168. < ;;
  9169. < pvs)
  9170. < _pvs
  9171. < ;;
  9172. < pvscan)
  9173. < _pvscan
  9174. < ;;
  9175. < vgcfgbackup)
  9176. < _vgcfgbackup
  9177. < ;;
  9178. < vgcfgrestore)
  9179. < _vgcfgrestore
  9180. < ;;
  9181. < vgchange)
  9182. < _vgchange
  9183. < ;;
  9184. < vgck)
  9185. < _vgck
  9186. < ;;
  9187. < vgconvert)
  9188. < _vgconvert
  9189. < ;;
  9190. < vgcreate)
  9191. < _vgcreate
  9192. < ;;
  9193. < vgdisplay)
  9194. < _vgdisplay
  9195. < ;;
  9196. < vgexport)
  9197. < _vgexport
  9198. < ;;
  9199. < vgextend)
  9200. < _vgextend
  9201. < ;;
  9202. < vgimport)
  9203. < _vgimport
  9204. < ;;
  9205. < vgmerge)
  9206. < _vgmerge
  9207. < ;;
  9208. < vgmknodes)
  9209. < _vgmknodes
  9210. < ;;
  9211. < vgreduce)
  9212. < _vgreduce
  9213. < ;;
  9214. < vgremove)
  9215. < _vgremove
  9216. < ;;
  9217. < vgrename)
  9218. < _vgrename
  9219. < ;;
  9220. < vgs)
  9221. < _vgs
  9222. < ;;
  9223. < vgscan)
  9224. < _vgscan
  9225. < ;;
  9226. < vgsplit)
  9227. < _vgsplit
  9228. < ;;
  9229. < lvchange)
  9230. < _lvchange
  9231. < ;;
  9232. < lvcreate)
  9233. < _lvcreate
  9234. < ;;
  9235. < lvdisplay)
  9236. < _lvdisplay
  9237. < ;;
  9238. < lvextend)
  9239. < _lvextend
  9240. < ;;
  9241. < lvreduce)
  9242. < _lvreduce
  9243. < ;;
  9244. < lvremove)
  9245. < _lvremove
  9246. < ;;
  9247. < lvrename)
  9248. < _lvrename
  9249. < ;;
  9250. < lvresize)
  9251. < _lvresize
  9252. < ;;
  9253. < lvs)
  9254. < _lvs
  9255. < ;;
  9256. < lvscan)
  9257. < _lvscan
  9258. < ;;
  9259. < esac
  9260. < fi
  9261. < }
  9262. < complete -F _lvm lvm
  9263. < }
  9264. <
  9265. < # mkinitrd(8) completion
  9266. < #
  9267. < have mkinitrd &&
  9268. < _mkinitrd()
  9269. < {
  9270. < local cur args
  9271. <
  9272. < COMPREPLY=()
  9273. < cur=`_get_cword`
  9274. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9275. <
  9276. < # --name value style option
  9277. < case "$prev" in
  9278. < --preload)
  9279. < _modules
  9280. < return 0
  9281. < ;;
  9282. < esac
  9283. <
  9284. < # --name=value style option
  9285. < if [[ "$cur" == *=* ]]; then
  9286. < prev=${cur/=*/}
  9287. < cur=${cur/*=/}
  9288. < case "$prev" in
  9289. < --@(with|builtin))
  9290. < _modules
  9291. < return 0
  9292. < ;;
  9293. < --@(fstab|dsdt))
  9294. < _filedir
  9295. < return 0
  9296. < ;;
  9297. < --tmpdir)
  9298. < _filedir -d
  9299. < return 0
  9300. < ;;
  9301. < esac
  9302. < fi
  9303. <
  9304. <
  9305. < if [[ "$cur" == -* ]]; then
  9306. < COMPREPLY=( $( compgen -W '--version -v -f --preload \
  9307. < --with= --omit-scsi-modules --omit-raid-modules \
  9308. < --images-version --fstab= --nocompress --builtin= \
  9309. < --nopivot --noudev --allow-missing --tmpdir= \
  9310. < --initrdfs= --dsdt= --lvm-version= --froce-usb' \
  9311. < -- $cur ) )
  9312. < else
  9313. < _count_args
  9314. <
  9315. < case $args in
  9316. < 1)
  9317. < _filedir
  9318. < ;;
  9319. < 2)
  9320. < COMPREPLY=( $( command ls /lib/modules | grep "^$cur" ) )
  9321. < ;;
  9322. < esac
  9323. < fi
  9324. <
  9325. < } &&
  9326. < complete -F _mkinitrd mkinitrd
  9327. <
  9328. < # pkgconfig(1) completion
  9329. < #
  9330. < have pkg-config &&
  9331. < _pkg_config()
  9332. < {
  9333. < local cur
  9334. <
  9335. < COMPREPLY=()
  9336. < cur=`_get_cword`
  9337. <
  9338. < if [[ "$cur" == -* ]]; then
  9339. < # return list of available options
  9340. < COMPREPLY=( $( compgen -W '-version --modversion \
  9341. < --atleast-pkgconfig-version= --libs --libs-only-l \
  9342. < --libs-only-other --libs-only-L --cflags \
  9343. < --cflags-only-I --cflags-only-other --variable= \
  9344. < --define-variable= --exists --uninstalled \
  9345. < --atleast-version= --exact-version= --max-version= \
  9346. < --list-all --debug --print-errors --silence-errors \
  9347. < --errors-to-stdout -? --help --usage' -- $cur))
  9348. < else
  9349. < COMPREPLY=( $( pkg-config --list-all 2>/dev/null | \
  9350. < awk '{print $1}' | grep "^$cur" ) )
  9351. < fi
  9352. < } &&
  9353. < complete -F _pkg_config pkg-config
  9354. <
  9355. <
  9356. < # cpio(1) completion
  9357. < #
  9358. < have cpio && {
  9359. < _cpio_format()
  9360. < {
  9361. < COMPREPLY=( $( compgen -W 'bin odc newc crc tar ustar hpbin hpodc' -- $cur ) )
  9362. < }
  9363. <
  9364. < _cpio()
  9365. < {
  9366. < local cur
  9367. <
  9368. < COMPREPLY=()
  9369. < cur=`_get_cword`
  9370. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9371. <
  9372. < # --name value style option
  9373. < case $prev in
  9374. < -H)
  9375. < _cpio_format
  9376. < return 0
  9377. < ;;
  9378. < -@(E|F|I))
  9379. < _filedir
  9380. < return 0
  9381. < ;;
  9382. < -R)
  9383. < _usergroup
  9384. < return 0
  9385. < ;;
  9386. < esac
  9387. <
  9388. < # --name=value style option
  9389. < if [[ "$cur" == *=* ]]; then
  9390. < prev=${cur/=*/}
  9391. < cur=${cur/*=/}
  9392. < case $prev in
  9393. < --format)
  9394. < _cpio_format
  9395. < return 0
  9396. < ;;
  9397. < --@(file|pattern-file))
  9398. < _filedir
  9399. < return 0
  9400. < ;;
  9401. < --owner)
  9402. < _usergroup
  9403. < return 0
  9404. < ;;
  9405. < --rsh-command)
  9406. < COMPREPLY=( $( compgen -c -- $cur ) )
  9407. < return 0
  9408. < ;;
  9409. < esac
  9410. < fi
  9411. <
  9412. < if [ $COMP_CWORD -eq 1 ]; then
  9413. < COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through' -- $cur) )
  9414. < else
  9415. < case ${COMP_WORDS[1]} in
  9416. < -@(o|-create))
  9417. < if [[ "$cur" == -* ]]; then
  9418. < COMPREPLY=( $( compgen -W '-0 -a -c -v -A -B\
  9419. < -L -V -C -H -M -O -F --file= --format=\
  9420. < --message= --null --reset-access-time\
  9421. < --verbose --dot --append --block-size=\
  9422. < --dereference --io-size= --quiet\
  9423. < --force-local --rsh-command= --help\
  9424. < --version' -- $cur ) )
  9425. < fi
  9426. < ;;
  9427. < -@(i|-extract))
  9428. < if [[ "$cur" == -* ]]; then
  9429. < COMPREPLY=( $( compgen -W '-b -c -d -f -m -n -r\
  9430. < -t -s -u -v -B -S -V -C -E -H -M -R -I\
  9431. < -F --file= --make-directories\
  9432. < --nonmatching\
  9433. < --preserve-modification-time\
  9434. < --numeric-uid-gid --rename -t --list\
  9435. < --swap-bytes --swap --dot\
  9436. < --unconditional --verbose --block-size=\
  9437. < --swap-halfwords --io-size=\
  9438. < --pattern-file= --format= --owner=\
  9439. < --no-preserve-owner --message=\
  9440. < --force-local --no-absolute-filenames\
  9441. < --sparse --only-verify-crc --quiet\
  9442. < --rsh-command= --help\
  9443. < --version' -- $cur ) )
  9444. < fi
  9445. < ;;
  9446. < -@(p|-pass-through))
  9447. < if [[ "$cur" == -* ]]; then
  9448. < COMPREPLY=( $( compgen -W '-0 -a -d -l -m -u -v\
  9449. < -L -V -R --null --reset-access-time\
  9450. < --make-directories --link --quiet\
  9451. < --preserve-modification-time\
  9452. < --unconditional --verbose --dot\
  9453. < --dereference --owner=\
  9454. < --no-preserve-owner --sparse --help\
  9455. < --version' -- $cur ) )
  9456. < else
  9457. < _filedir -d
  9458. < fi
  9459. < ;;
  9460. < esac
  9461. < fi
  9462. < }
  9463. < complete -F _cpio cpio
  9464. < }
  9465. <
  9466. < # id(1) completion
  9467. < #
  9468. < have id &&
  9469. < _id()
  9470. < {
  9471. < local cur
  9472. <
  9473. < COMPREPLY=()
  9474. < cur=`_get_cword`
  9475. <
  9476. < if [[ "$cur" == -* ]]; then
  9477. < COMPREPLY=( $( compgen -W '-a -g --group -G --groups -n --name\
  9478. < -r --real -u --user --help --version' -- $cur ) )
  9479. < else
  9480. < COMPREPLY=( $( compgen -u $cur ) )
  9481. < fi
  9482. < } &&
  9483. < complete -F _id id
  9484. <
  9485. < # getent(1) completion
  9486. < #
  9487. < have getent &&
  9488. < _getent()
  9489. < {
  9490. < local cur prev
  9491. <
  9492. < COMPREPLY=()
  9493. < cur=`_get_cword`
  9494. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9495. <
  9496. < case $prev in
  9497. < passwd)
  9498. < COMPREPLY=( $( compgen -u $cur ) )
  9499. < return 0
  9500. < ;;
  9501. < group)
  9502. < COMPREPLY=( $( compgen -g $cur ) )
  9503. < return 0
  9504. < ;;
  9505. < services)
  9506. < COMPREPLY=( $( compgen -s $cur ) )
  9507. < return 0
  9508. < ;;
  9509. < hosts)
  9510. < COMPREPLY=( $( compgen -A hostname $cur ) )
  9511. < return 0
  9512. < ;;
  9513. < protocols)
  9514. < COMPREPLY=( $( getent protocols | awk '{print $1}' | grep "^$cur" ) )
  9515. < return 0
  9516. < ;;
  9517. < networks)
  9518. < COMPREPLY=( $( getent networks | awk '{print $1}' | grep "^$cur" ) )
  9519. < return 0
  9520. < ;;
  9521. < esac
  9522. <
  9523. <
  9524. < if [ $COMP_CWORD -eq 1 ]; then
  9525. < COMPREPLY=( $( compgen -W 'passwd group hosts services protocols networks' -- $cur ) )
  9526. < fi
  9527. < } &&
  9528. < complete -F _getent getent
  9529. <
  9530. < # ntpdate(1) completion
  9531. < #
  9532. < have ntpdate &&
  9533. < _ntpdate()
  9534. < {
  9535. < local cur prev
  9536. <
  9537. < COMPREPLY=()
  9538. < cur=`_get_cword`
  9539. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9540. <
  9541. < case $prev in
  9542. < -k)
  9543. < _filedir
  9544. < return 0
  9545. < ;;
  9546. < -U)
  9547. < COMPREPLY=( $( compgen -u $cur ) )
  9548. < return 0
  9549. < ;;
  9550. < esac
  9551. <
  9552. < if [[ "$cur" == -* ]]; then
  9553. < COMPREPLY=( $( compgen -W '-4 -6 -b -B -d -Q -q -s -u -v -a\
  9554. < -e -k -p -o -r -t' -- $cur ) )
  9555. < else
  9556. < _known_hosts
  9557. < fi
  9558. < } &&
  9559. < complete -F _ntpdate ntpdate
  9560. <
  9561. < # smartctl(8) completion
  9562. < #
  9563. < have smartctl && {
  9564. < _smartctl_quietmode()
  9565. < {
  9566. < COMPREPLY=( $( compgen -W 'errorsonly silent' -- $cur ) )
  9567. < }
  9568. < _smartctl_device()
  9569. < {
  9570. < COMPREPLY=( $( compgen -W 'ata scsi 3ware' -- $cur ) )
  9571. < }
  9572. < _smartctl_tolerance()
  9573. < {
  9574. < COMPREPLY=( $( compgen -W 'warn exit ignore' -- $cur ) )
  9575. < }
  9576. < _smartctl_badsum()
  9577. < {
  9578. < COMPREPLY=( $( compgen -W 'normal conservative permissive verypermissive' -- $cur ) )
  9579. < }
  9580. < _smartctl_report()
  9581. < {
  9582. < COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- $cur ) )
  9583. < }
  9584. < _smartctl_feature()
  9585. < {
  9586. < COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
  9587. < }
  9588. < _smartctl_log()
  9589. < {
  9590. < COMPREPLY=( $( compgen -W 'error selftest selective directory' -- $cur ) )
  9591. < }
  9592. < _smartctl_vendorattribute()
  9593. < {
  9594. < COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \
  9595. < 9,temp 192,emergencyretractcyclect 193,loadunload \
  9596. < 194,10xCelsius 194,unknown 198,offlinescanuncsectorct \
  9597. < 200,writeerrorcount 201,detectedtacount 220,temp' -- $cur ) )
  9598. < }
  9599. < _smartctl_firmwarebug()
  9600. < {
  9601. < COMPREPLY=( $( compgen -W 'none samsung samsung2' -- $cur ) )
  9602. < }
  9603. < _smartctl_presets()
  9604. < {
  9605. < COMPREPLY=( $( compgen -W 'use ignore show showall' -- $cur ) )
  9606. < }
  9607. < _smartctl_test()
  9608. < {
  9609. < COMPREPLY=( $( compgen -W 'offline short long conveyance select afterselect,on afterselect,off pending' -- $cur ) )
  9610. < }
  9611. <
  9612. < _smartctl()
  9613. < {
  9614. < local cur prev
  9615. <
  9616. < COMPREPLY=()
  9617. < cur=`_get_cword`
  9618. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9619. <
  9620. < # --name value style option
  9621. < case "$prev" in
  9622. < -q)
  9623. < _smartctl_quietmode
  9624. < ;;
  9625. < -d)
  9626. < _smartctl_device
  9627. < return 0
  9628. < ;;
  9629. < -t)
  9630. < _smartctl_tolerance
  9631. < return 0
  9632. < ;;
  9633. < -b)
  9634. < _smartctl_badsum
  9635. < return 0
  9636. < ;;
  9637. < -r)
  9638. < _smartctl_report
  9639. < return 0
  9640. < ;;
  9641. < -s)
  9642. < _smartctl_feature
  9643. < return 0
  9644. < ;;
  9645. < -o)
  9646. < _smartctl_feature
  9647. < return 0
  9648. < ;;
  9649. < -S)
  9650. < _smartctl_feature
  9651. < return 0
  9652. < ;;
  9653. < -l)
  9654. < _smartctl_log
  9655. < return 0
  9656. < ;;
  9657. < -v)
  9658. < _smartctl_vendorattribute
  9659. < return 0
  9660. < ;;
  9661. < -F)
  9662. < _smartctl_firmwarebug
  9663. < return 0
  9664. < ;;
  9665. < -P)
  9666. < _smartctl_presets
  9667. < return 0
  9668. < ;;
  9669. < -t)
  9670. < _smartctl_test
  9671. < return 0
  9672. < ;;
  9673. < esac
  9674. <
  9675. < # --name=value style option
  9676. < if [[ "$cur" == *=* ]]; then
  9677. < prev=${cur/=*/}
  9678. < cur=${cur/*=/}
  9679. < case "$prev" in
  9680. < --quietmode)
  9681. < _smartctl_quietmode
  9682. < return 0
  9683. < ;;
  9684. < --device)
  9685. < _smartctl_device
  9686. < return 0
  9687. < ;;
  9688. < --tolerance)
  9689. < _smartctl_tolerance
  9690. < return 0
  9691. < ;;
  9692. < --badsum)
  9693. < _smartctl_badsum
  9694. < return 0
  9695. < ;;
  9696. < --report)
  9697. < _smartctl_report
  9698. < return 0
  9699. < ;;
  9700. < --smart)
  9701. < _smartctl_feature
  9702. < return 0
  9703. < ;;
  9704. < --offlineauto)
  9705. < _smartctl_feature
  9706. < return 0
  9707. < ;;
  9708. < --saveauto)
  9709. < _smartctl_feature
  9710. < return 0
  9711. < ;;
  9712. < --log)
  9713. < _smartctl_log
  9714. < return 0
  9715. < ;;
  9716. < --vendorattribute)
  9717. < _smartctl_vendorattribute
  9718. < return 0
  9719. < ;;
  9720. < --firmwarebug)
  9721. < _smartctl_firmwarebug
  9722. < return 0
  9723. < ;;
  9724. < --presets)
  9725. < _smartctl_presets
  9726. < return 0
  9727. < ;;
  9728. < --test)
  9729. < _smartctl_test
  9730. < return 0
  9731. < ;;
  9732. < esac
  9733. < fi
  9734. <
  9735. <
  9736. < if [[ "$cur" == -* ]]; then
  9737. < COMPREPLY=( $( compgen -W '-h --help --usage -V --version \
  9738. < --copyright --license-i --info -a --all -q \
  9739. < --quietmode= -d --device= -T --tolerance= -b --badsum= \
  9740. < -r --report= -s --smart= -o --offlineauto= -S \
  9741. < --saveauto= -H --health -c --capabilities -A \
  9742. < --attributes -l --log= -v --vendorattribute= -F \
  9743. < --firmwarebug= -P --presets= -t --test= -C \
  9744. < --captive -X --abort' -- $cur ) )
  9745. < else
  9746. < cur=${cur:=/dev/}
  9747. < _filedir
  9748. < fi
  9749. < }
  9750. < complete -F _smartctl smartctl
  9751. < }
  9752. <
  9753. < # vncviewer(1) completion
  9754. < #
  9755. < have vncviewer &&
  9756. < _vncviewer()
  9757. < {
  9758. < local cur prev
  9759. < local -a config
  9760. <
  9761. < COMPREPLY=()
  9762. < cur=`_get_cword`
  9763. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9764. <
  9765. < case "$prev" in
  9766. < -via)
  9767. < _known_hosts -a
  9768. < ;;
  9769. < *)
  9770. < # ssh into the the server, find and ping the broadcast address, then
  9771. < # sort and show the results.
  9772. < COMPREPLY=( $( ssh -o 'Batchmode yes' $prev \
  9773. < "ping -bnc 4 255.255.255.255" 2>/dev/null | \
  9774. < awk -F ' ' '{print $4}' | \
  9775. < sort -n | uniq | egrep '[0-9]+\.[0-9]+\.' 2>/dev/null ) )
  9776. < esac
  9777. <
  9778. < return 0
  9779. < } &&
  9780. < complete -F _vncviewer vncviewer
  9781. <
  9782. < # sysctl(8) completion
  9783. < #
  9784. < have sysctl &&
  9785. < _sysctl()
  9786. < {
  9787. < local cur
  9788. <
  9789. < COMPREPLY=()
  9790. < cur=`_get_cword`
  9791. <
  9792. < COMPREPLY=( $( compgen -W "$(sysctl -N -a 2>/dev/null)" -- $cur ) )
  9793. <
  9794. < return 0
  9795. < } &&
  9796. < complete -F _sysctl sysctl
  9797. <
  9798. < # update-rc.d(8) completion
  9799. < #
  9800. < # Copyright (C) 2004 Servilio Afre Puentes <[email protected]>
  9801. < #
  9802. < have update-rc.d &&
  9803. < _update_rc_d()
  9804. < {
  9805. < local cur prev sysvdir services options valid_options
  9806. <
  9807. < cur=`_get_cword`
  9808. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9809. <
  9810. < [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
  9811. < || sysvdir=/etc/init.d
  9812. <
  9813. < services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)) )
  9814. < services=( ${services[@]#$sysvdir/} )
  9815. < options=( -f -n )
  9816. <
  9817. < if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
  9818. < valid_options=( $( \
  9819. < echo "${COMP_WORDS[@]} ${options[@]}" \
  9820. < | tr " " "\n" \
  9821. < | sed -ne "/$( echo "${options[@]}" | sed "s/ /\\|/g" )/p" \
  9822. < | sort | uniq -u \
  9823. < ) )
  9824. < COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \
  9825. < -X '$( echo ${COMP_WORDS[@]} | tr " " "|" )' -- $cur ) )
  9826. < elif [[ "$prev" == ?($( echo ${services[@]} | tr " " "|" )) ]]; then
  9827. < COMPREPLY=( $( compgen -W 'remove defaults start stop' -- $cur ) )
  9828. < elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then
  9829. < COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
  9830. < elif [[ "$prev" == defaults && "$cur" == [sk]?([0-9]) ]]; then
  9831. < COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
  9832. < elif [[ "$prev" == defaults && -z "$cur" ]]; then
  9833. < COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 s k )
  9834. < elif [[ "$prev" == ?(start|stop) ]]; then
  9835. < if [[ "$cur" == [0-9] || -z "$cur" ]]; then
  9836. < COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
  9837. < elif [[ "$cur" == [0-9][0-9] ]]; then
  9838. < COMPREPLY=( $cur )
  9839. < else
  9840. < COMPREPLY=()
  9841. < fi
  9842. < elif [[ "$prev" == ?([0-9][0-9]|[0-6S]) ]]; then
  9843. < if [[ -z "$cur" ]]; then
  9844. < if [[ $prev == [0-9][0-9] ]]; then
  9845. < COMPREPLY=( 0 1 2 3 4 5 6 S )
  9846. < else
  9847. < COMPREPLY=( 0 1 2 3 4 5 6 S . )
  9848. < fi
  9849. < elif [[ "$cur" == [0-6S.] ]]; then
  9850. < COMPREPLY=( $cur )
  9851. < else
  9852. < COMPREPLY=()
  9853. < fi
  9854. < elif [[ "$prev" == "." ]]; then
  9855. < COMPREPLY=( $(compgen -W "start stop" -- $cur) )
  9856. < else
  9857. < COMPREPLY=()
  9858. < fi
  9859. ---
  9860. > local cur func cline cspec noglob cmd i char_offset word_offset \
  9861. > _COMMAND_FUNC _COMMAND_FUNC_ARGS
  9862. 8779,8781c1422
  9863. < return 0
  9864. < } &&
  9865. < complete -F _update_rc_d update-rc.d
  9866. ---
  9867. > word_offset=$1
  9868. 8783,8815c1424,1452
  9869. < # invoke-rc.d(8) completion
  9870. < #
  9871. < # Copyright (C) 2004 Servilio Afre Puentes <[email protected]>
  9872. < #
  9873. < have invoke-rc.d &&
  9874. < _invoke_rc_d()
  9875. < {
  9876. < local cur prev sysvdir services options valid_options
  9877. <
  9878. < cur=`_get_cword`
  9879. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9880. <
  9881. < [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
  9882. < || sysvdir=/etc/init.d
  9883. <
  9884. < services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)) )
  9885. < services=( ${services[@]#$sysvdir/} )
  9886. < options=( --help --quiet --force --try-anyway --disclose-deny --query --no-fallback )
  9887. <
  9888. < if [[ ($COMP_CWORD -eq 1) || ("$prev" == --* ) ]]; then
  9889. < valid_options=( $( \
  9890. < echo ${COMP_WORDS[@]} ${options[@]} \
  9891. < | tr " " "\n" \
  9892. < | sed -ne "/$( echo ${options[@]} | sed "s/ /\\\\|/g" )/p" \
  9893. < | sort | uniq -u \
  9894. < ) )
  9895. < COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- \
  9896. < $cur ) )
  9897. < elif [ -x $sysvdir/$prev ]; then
  9898. < COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
  9899. < s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \
  9900. < $sysvdir/$prev`' -- \
  9901. < $cur ) )
  9902. ---
  9903. > # rewrite current completion context before invoking
  9904. > # actual command completion
  9905. >
  9906. > # find new first word position, then
  9907. > # rewrite COMP_LINE and adjust COMP_POINT
  9908. > local first_word=${COMP_WORDS[$word_offset]}
  9909. > for (( i=0; i <= ${#COMP_LINE}; i++ )); do
  9910. > if [[ "${COMP_LINE:$i:${#first_word}}" == "$first_word" ]]; then
  9911. > char_offset=$i
  9912. > break
  9913. > fi
  9914. > done
  9915. > COMP_LINE=${COMP_LINE:$char_offset}
  9916. > COMP_POINT=$(( COMP_POINT - $char_offset ))
  9917. >
  9918. > # shift COMP_WORDS elements and adjust COMP_CWORD
  9919. > for (( i=0; i <= COMP_CWORD - $word_offset; i++ )); do
  9920. > COMP_WORDS[i]=${COMP_WORDS[i+$word_offset]}
  9921. > done
  9922. > for (( i; i <= COMP_CWORD; i++ )); do
  9923. > unset COMP_WORDS[i];
  9924. > done
  9925. > COMP_CWORD=$(( $COMP_CWORD - $word_offset ))
  9926. >
  9927. > COMPREPLY=()
  9928. > _get_comp_words_by_ref cur
  9929. >
  9930. > if [[ $COMP_CWORD -eq 0 ]]; then
  9931. > COMPREPLY=( $( compgen -c -- "$cur" ) )
  9932. 8817c1454,1485
  9933. < COMPREPLY=()
  9934. ---
  9935. > cmd=${COMP_WORDS[0]}
  9936. > if complete -p $cmd &>/dev/null; then
  9937. > cspec=$( complete -p $cmd )
  9938. > if [ "${cspec#* -F }" != "$cspec" ]; then
  9939. > # complete -F <function>
  9940. >
  9941. > # get function name
  9942. > func=${cspec#*-F }
  9943. > func=${func%% *}
  9944. >
  9945. > if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
  9946. > $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}"
  9947. > else
  9948. > $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}"
  9949. > fi
  9950. >
  9951. > # remove any \: generated by a command that doesn't
  9952. > # default to filenames or dirnames (e.g. sudo chown)
  9953. > # FIXME: I'm pretty sure this does not work!
  9954. > if [ "${cspec#*-o }" != "$cspec" ]; then
  9955. > cspec=${cspec#*-o }
  9956. > cspec=${cspec%% *}
  9957. > if [[ "$cspec" != @(dir|file)names ]]; then
  9958. > COMPREPLY=("${COMPREPLY[@]//\\\\:/:}")
  9959. > fi
  9960. > fi
  9961. > elif [ -n "$cspec" ]; then
  9962. > cspec=${cspec#complete};
  9963. > cspec=${cspec%%$cmd};
  9964. > COMPREPLY=( $( eval compgen "$cspec" -- "$cur" ) );
  9965. > fi
  9966. > fi
  9967. 8820,8822c1488,1491
  9968. < return 0
  9969. < } &&
  9970. < complete -F _invoke_rc_d invoke-rc.d
  9971. ---
  9972. > [ ${#COMPREPLY[@]} -eq 0 ] && _filedir
  9973. > }
  9974. > complete -F _command -o filenames nohup exec nice eval time ltrace then \
  9975. > else do vsound command xargs tsocks aoss padsp
  9976. 8824,8827c1493
  9977. < # minicom(1) completion
  9978. < #
  9979. < have minicom &&
  9980. < _minicom()
  9981. ---
  9982. > _root_command()
  9983. 8829,9280c1495,1496
  9984. < local cur prev
  9985. <
  9986. < COMPREPLY=()
  9987. < cur=`_get_cword`
  9988. < prev=${COMP_WORDS[COMP_CWORD-1]}
  9989. <
  9990. < case $prev in
  9991. < -@(a|c))
  9992. < COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
  9993. < return 0
  9994. < ;;
  9995. < -@(S|C))
  9996. < _filedir
  9997. < return 0
  9998. < ;;
  9999. < -P)
  10000. < COMPREPLY=( $( command ls /dev/tty* ) )
  10001. < COMPREPLY=( $( compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' -- $cur ) )
  10002. < return 0
  10003. < ;;
  10004. < esac
  10005. <
  10006. <
  10007. < if [[ "$cur" == -* ]]; then
  10008. < COMPREPLY=( $( compgen -W '-s -o -m -M -z -l -L -w -a -t \
  10009. < -c -S -d -p -C -T -8' -- $cur ) )
  10010. < else
  10011. < COMPREPLY=( $( command ls /etc/minicom/minirc.* 2>/dev/null | sed -e 's|/etc/minicom/minirc.||' | grep "^$cur" ) )
  10012. < fi
  10013. < } &&
  10014. < complete -F _minicom minicom
  10015. <
  10016. < # svn completion
  10017. < #
  10018. < have svn &&
  10019. < {
  10020. < _svn()
  10021. < {
  10022. < local cur prev commands options command
  10023. <
  10024. < COMPREPLY=()
  10025. < cur=`_get_cword`
  10026. <
  10027. < commands='add blame praise annotate ann cat checkout co cleanup commit \
  10028. < ci copy cp delete del remove rm diff di export help ? h import \
  10029. < info list ls lock log merge mkdir move mv rename ren \
  10030. < propdel pdel pd propedit pedit pe propget pget pg \
  10031. < proplist plist pl propset pset ps resolved revert \
  10032. < status stat st switch sw unlock update up'
  10033. <
  10034. < if [[ $COMP_CWORD -eq 1 ]] ; then
  10035. < if [[ "$cur" == -* ]]; then
  10036. < COMPREPLY=( $( compgen -W '--version' -- $cur ) )
  10037. < else
  10038. < COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
  10039. < fi
  10040. < else
  10041. <
  10042. < prev=${COMP_WORDS[COMP_CWORD-1]}
  10043. < case $prev in
  10044. < --config-dir)
  10045. < _filedir -d
  10046. < return 0;
  10047. < ;;
  10048. < -@(F|-file|-targets))
  10049. < _filedir
  10050. < return 0;
  10051. < ;;
  10052. < --encoding)
  10053. < COMPREPLY=( $( compgen -W \
  10054. < '$( iconv --list | sed -e "s@//@@;" )' \
  10055. < -- "$cur" ) )
  10056. < return 0;
  10057. < ;;
  10058. < --@(editor|diff|diff3)-cmd)
  10059. < COMP_WORDS=(COMP_WORDS[0] $cur)
  10060. < COMP_CWORD=1
  10061. < _command
  10062. < return 0;
  10063. < ;;
  10064. < esac
  10065. <
  10066. < command=${COMP_WORDS[1]}
  10067. <
  10068. < if [[ "$cur" == -* ]]; then
  10069. < # possible options for the command
  10070. < case $command in
  10071. < add)
  10072. < options='--auto-props --no-auto-props \
  10073. < --force --targets --no-ignore \
  10074. < --non-recursive -N -q --quiet'
  10075. < ;;
  10076. < @(blame|annotate|ann|praise))
  10077. < options='-r --revisions --username \
  10078. < --password --no-auth-cache \
  10079. < --non-interactive -v \
  10080. < --verbose --incremental --xml'
  10081. < ;;
  10082. < cat)
  10083. < options='-r --revision --username \
  10084. < --password --no-auth-cache \
  10085. < --non-interactive'
  10086. < ;;
  10087. < @(checkout|co))
  10088. < options='-r --revision -q --quiet -N \
  10089. < --non-recursive --username \
  10090. < --password --no-auth-cache \
  10091. < --non-interactive \
  10092. < --ignore-externals'
  10093. < ;;
  10094. < cleanup)
  10095. < options='--diff3-cmd'
  10096. < ;;
  10097. < @(commit|ci))
  10098. < options='-m --message -F --file \
  10099. < --encoding --force-log -q \
  10100. < --quiet --non-recursive -N \
  10101. < --targets --editor-cmd \
  10102. < --username --password \
  10103. < --no-auth-cache \
  10104. < --non-interactive --no-unlock'
  10105. < ;;
  10106. < @(copy|cp))
  10107. < options='-m --message -F --file \
  10108. < --encoding --force-log -r \
  10109. < --revision -q --quiet \
  10110. < --editor-cmd -username \
  10111. < --password --no-auth-cache \
  10112. < --non-interactive'
  10113. < ;;
  10114. < @(delete|del|remove|rm))
  10115. < options='--force -m --message -F \
  10116. < --file --encoding --force-log \
  10117. < -q --quiet --targets \
  10118. < --editor-cmd -username \
  10119. < --password --no-auth-cache \
  10120. < --non-interactive'
  10121. < ;;
  10122. < @(diff|di))
  10123. < options='-r --revision -x --extensions \
  10124. < --diff-cmd --no-diff-deleted \
  10125. < -N --non-recursive --username \
  10126. < --password --no-auth-cache \
  10127. < --non-interactive --force \
  10128. < --old --new --notice-ancestry'
  10129. < ;;
  10130. < export)
  10131. < options='-r --revision -q --quiet \
  10132. < --username --password \
  10133. < --no-auth-cache \
  10134. < --non-interactive -N \
  10135. < --non-recursive --force \
  10136. < --native-eol --ignore-externals'
  10137. < ;;
  10138. < import)
  10139. < options='--auto-props --no-auto-props \
  10140. < -m --message -F --file \
  10141. < --encoding --force-log -q \
  10142. < --quiet --non-recursive \
  10143. < --no-ignore --editor-cmd \
  10144. < --username --password \
  10145. < --no-auth-cache \
  10146. < --non-interactive'
  10147. < ;;
  10148. < info)
  10149. < options='--username --password \
  10150. < --no-auth-cache \
  10151. < --non-interactive -r \
  10152. < --revision --xml --targets \
  10153. < -R --recursive --incremental'
  10154. < ;;
  10155. < @(list|ls))
  10156. < options='-r --revision -v --verbose -R \
  10157. < --recursive --username \
  10158. < --password --no-auth-cache \
  10159. < --non-interactive \
  10160. < --incremental --xml'
  10161. < ;;
  10162. < lock)
  10163. < options='-m --message -F --file \
  10164. < --encoding --force-log \
  10165. < --targets --force --username \
  10166. < --password --no-auth-cache \
  10167. < --non-interactive'
  10168. < ;;
  10169. < log)
  10170. < options='-r --revision -v --verbose \
  10171. < --targets --username \
  10172. < --password --no-auth-cache \
  10173. < --non-interactive \
  10174. < --stop-on-copy --incremental \
  10175. < --xml -q --quiet --limit'
  10176. < ;;
  10177. < merge)
  10178. < options='-r --revision -N \
  10179. < --non-recursive -q --quiet \
  10180. < --force --dry-run --diff3-cmd \
  10181. < --username --password \
  10182. < --no-auth-cache \
  10183. < --non-interactive \
  10184. < --ignore-ancestry'
  10185. < ;;
  10186. < mkdir)
  10187. < options='-m --message -F --file \
  10188. < --encoding --force-log -q \
  10189. < --quiet --editor-cmd \
  10190. < --username --password \
  10191. < --no-auth-cache \
  10192. < --non-interactive'
  10193. < ;;
  10194. < @(move|mv|rename|ren))
  10195. < options='-m --message -F --file \
  10196. < --encoding --force-log -r \
  10197. < --revision -q --quiet \
  10198. < --force --editor-cmd \
  10199. < --username --password \
  10200. < --no-auth-cache \
  10201. < --non-interactive'
  10202. < ;;
  10203. < @(propdel|pdel|pd))
  10204. < options='-q --quiet -R --recursive -r \
  10205. < --revision --revprop \
  10206. < --username --password \
  10207. < --no-auth-cache \
  10208. < --non-interactive'
  10209. < ;;
  10210. < @(propedit|pedit|pe))
  10211. < options='-r --revision --revprop \
  10212. < --encoding --editor-cmd \
  10213. < --username --password \
  10214. < --no-auth-cache \
  10215. < --non-interactive --force'
  10216. < ;;
  10217. < @(propget|pget|pg))
  10218. < options='-R --recursive -r --revision \
  10219. < --revprop --strict --username \
  10220. < --password --no-auth-cache \
  10221. < --non-interactive'
  10222. < ;;
  10223. < @(proplist|plist|pl))
  10224. < options='-v --verbose -R --recursive \
  10225. < -r --revision --revprop -q \
  10226. < --quiet --username --password \
  10227. < --no-auth-cache \
  10228. < --non-interactive'
  10229. < ;;
  10230. < @(propset|pset|ps))
  10231. < options='-F --file -q --quiet \
  10232. < --targets -R --recursive \
  10233. < --revprop --encoding \
  10234. < --username --password \
  10235. < --no-auth-cache \
  10236. < --non-interactive -r \
  10237. < --revision --force'
  10238. < ;;
  10239. < resolved)
  10240. < options='--targets -R --recursive -q \
  10241. < --quiet'
  10242. < ;;
  10243. < revert)
  10244. < options='--targets -R --recursive -q \
  10245. < --quiet'
  10246. < ;;
  10247. < @(status|stat|st))
  10248. < options='-u --show-updates -v \
  10249. < --verbose -N --non-recursive \
  10250. < -q --quiet --username \
  10251. < --password --no-auth-cache \
  10252. < --non-interactive --no-ignore \
  10253. < --ignore-externals \
  10254. < --incremental --xml'
  10255. < ;;
  10256. < @(switch|sw))
  10257. < options='--relocate -r --revision -N \
  10258. < --non-recursive -q --quiet \
  10259. < --username --password \
  10260. < --no-auth-cache \
  10261. < --non-interactive --diff3-cmd'
  10262. < ;;
  10263. < unlock)
  10264. < options='--targets --force --username \
  10265. < --password --no-auth-cache \
  10266. < --non-interactive'
  10267. < ;;
  10268. < @(update|up))
  10269. < options='-r --revision -N \
  10270. < --non-recursive -q --quiet \
  10271. < --username --password \
  10272. < --no-auth-cache \
  10273. < --non-interactive \
  10274. < --diff3-cmd --ignore-externals'
  10275. < ;;
  10276. < esac
  10277. < options="$options --help -h --config-dir"
  10278. <
  10279. < COMPREPLY=( $( compgen -W "$options" -- $cur ) )
  10280. < else
  10281. < if [[ "$command" == @(help|h|\?) ]]; then
  10282. < COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
  10283. < else
  10284. < _filedir
  10285. < fi
  10286. < fi
  10287. < fi
  10288. <
  10289. < return 0
  10290. < }
  10291. < complete -F _svn $default svn
  10292. <
  10293. < _svnadmin()
  10294. < {
  10295. < local cur prev commands options mode
  10296. <
  10297. < COMPREPLY=()
  10298. < cur=`_get_cword`
  10299. <
  10300. < commands='create deltify dump help ? hotcopy list-dblogs \
  10301. < list-unused-dblogs load lslocks lstxns recover rmlocks \
  10302. < rmtxns setlog verify'
  10303. <
  10304. < if [[ $COMP_CWORD -eq 1 ]] ; then
  10305. < if [[ "$cur" == -* ]]; then
  10306. < COMPREPLY=( $( compgen -W '--version' -- $cur ) )
  10307. < else
  10308. < COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
  10309. < fi
  10310. < else
  10311. < prev=${COMP_WORDS[COMP_CWORD-1]}
  10312. < case $prev in
  10313. < --config-dir)
  10314. < _filedir -d
  10315. < return 0;
  10316. < ;;
  10317. < --fs-type)
  10318. < COMPREPLY=( $( compgen -W 'fsfs bdb' -- $cur ) )
  10319. < return 0;
  10320. < ;;
  10321. < esac
  10322. <
  10323. < command=${COMP_WORDS[1]}
  10324. <
  10325. < if [[ "$cur" == -* ]]; then
  10326. < # possible options for the command
  10327. < case $command in
  10328. < create)
  10329. < options='--bdb-txn-nosync \
  10330. < --bdb-log-keep --config-dir \
  10331. < --fs-type'
  10332. < ;;
  10333. < deltify)
  10334. < options='-r --revision -q --quiet'
  10335. < ;;
  10336. < dump)
  10337. < options='-r --revision --incremental \
  10338. < -q --quiet --deltas'
  10339. < ;;
  10340. < hotcopy)
  10341. < options='--clean-logs'
  10342. < ;;
  10343. < load)
  10344. < options='--ignore-uuid --force-uuid \
  10345. < --parent-dir -q --quiet \
  10346. < --use-pre-commit-hook \
  10347. < --use-post-commit-hook'
  10348. < ;;
  10349. < rmtxns)
  10350. < options='-q --quiet'
  10351. < ;;
  10352. < setlog)
  10353. < options='-r --revision --bypass-hooks'
  10354. < ;;
  10355. < esac
  10356. <
  10357. < options="$options --help -h"
  10358. < COMPREPLY=( $( compgen -W "$options" -- $cur ) )
  10359. < else
  10360. < if [[ "$command" == @(help|h|\?) ]]; then
  10361. < COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
  10362. < else
  10363. < _filedir
  10364. < fi
  10365. < fi
  10366. < fi
  10367. <
  10368. < return 0
  10369. < }
  10370. < complete -F _svnadmin $default svnadmin
  10371. <
  10372. < _svnlook()
  10373. < {
  10374. < local cur prev commands options mode
  10375. <
  10376. < COMPREPLY=()
  10377. < cur=`_get_cword`
  10378. <
  10379. < commands='author cat changed date diff dirs-changed help ? h history \
  10380. < info lock log propget pget pg proplist plist pl tree uuid \
  10381. < youngest'
  10382. <
  10383. < if [[ $COMP_CWORD -eq 1 ]] ; then
  10384. < if [[ "$cur" == -* ]]; then
  10385. < COMPREPLY=( $( compgen -W '--version' -- $cur ) )
  10386. < else
  10387. < COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
  10388. < fi
  10389. < else
  10390. < command=${COMP_WORDS[1]}
  10391. <
  10392. < if [[ "$cur" == -* ]]; then
  10393. < # possible options for the command
  10394. < case $command in
  10395. < @(author|cat|date|dirs-changed|info|log))
  10396. < options='-r --revision -t \
  10397. < --transaction'
  10398. < ;;
  10399. < changed)
  10400. < options='-r --revision -t \
  10401. < --transaction --copy-info'
  10402. < ;;
  10403. < diff)
  10404. < options='-r --revision -t \
  10405. < --transaction \
  10406. < --no-diff-deleted \
  10407. < --no-diff-added \
  10408. < --diff-copy-from'
  10409. < ;;
  10410. < history)
  10411. < options='-r --revision --show-ids'
  10412. < ;;
  10413. < prop@(get|list))
  10414. < options='-r --revision -t \
  10415. < --transaction --revprop'
  10416. < ;;
  10417. < tree)
  10418. < options='-r --revision -t \
  10419. < --transaction --show-ids \
  10420. < --full-paths'
  10421. < ;;
  10422. < esac
  10423. <
  10424. < options="$options --help -h"
  10425. < COMPREPLY=( $( compgen -W "$options" -- $cur ) )
  10426. < else
  10427. < if [[ "$command" == @(help|h|\?) ]]; then
  10428. < COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
  10429. < else
  10430. < _filedir
  10431. < fi
  10432. < fi
  10433. < fi
  10434. <
  10435. < return 0
  10436. ---
  10437. > local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
  10438. > _command $1 $2 $3
  10439. 9282c1498,1526
  10440. < complete -F _svnlook $default svnlook
  10441. ---
  10442. > complete -F _root_command -o filenames sudo fakeroot really gksudo gksu kdesudo
  10443. >
  10444. > _longopt()
  10445. > {
  10446. > local cur prev
  10447. >
  10448. > _get_comp_words_by_ref cur prev
  10449. >
  10450. > if _split_longopt; then
  10451. > case "$prev" in
  10452. > *[Dd][Ii][Rr]*)
  10453. > _filedir -d
  10454. > ;;
  10455. > *[Ff][Ii][Ll][Ee]*)
  10456. > _filedir
  10457. > ;;
  10458. > esac
  10459. > return 0
  10460. > fi
  10461. >
  10462. > if [[ "$cur" == -* ]]; then
  10463. > COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \
  10464. > sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}\).*/\1/p' | sort -u )" \
  10465. > -- "$cur" ) )
  10466. > elif [[ "$1" == rmdir ]]; then
  10467. > _filedir -d
  10468. > else
  10469. > _filedir
  10470. > fi
  10471. 9283a1528,1542
  10472. > # makeinfo and texi2dvi are defined elsewhere.
  10473. > for i in a2ps autoconf automake bc gprof ld nm objcopy objdump readelf strip \
  10474. > bison colordiff diff patch enscript cp df dir du ln ls mkfifo mknod mv rm \
  10475. > touch vdir awk gperf grep grub indent less m4 sed shar date \
  10476. > tee who texindex cat csplit cut expand fmt fold head \
  10477. > md5sum nl od paste pr ptx sha1sum sort split tac tail tr unexpand \
  10478. > uniq wc ldd bash id irb mkdir rmdir wget curl; do
  10479. > have $i && complete -F _longopt -o filenames $i
  10480. > done
  10481. >
  10482. > # These commands do not use filenames, so '-o filenames' is not needed.
  10483. > for i in env netstat seq uname units; do
  10484. > have $i && complete -F _longopt -o default $i
  10485. > done
  10486. > unset i
  10487. 9287c1546,1550
  10488. < local IFS cur xspec
  10489. ---
  10490. > local IFS cur xspec
  10491. >
  10492. > IFS=$'\t\n'
  10493. > COMPREPLY=()
  10494. > _get_comp_words_by_ref cur
  10495. 9289,9321c1552,1597
  10496. < IFS=$'\t\n'
  10497. < COMPREPLY=()
  10498. < cur=`_get_cword`
  10499. <
  10500. < _expand || return 0
  10501. <
  10502. < # get first exclusion compspec that matches this command
  10503. < xspec=$( sed -ne $'/^complete .*[ \t]'${1##*/}$'\([ \t]\|$\)/{p;q;}' \
  10504. < $BASH_COMPLETION )
  10505. < # prune to leave nothing but the -X spec
  10506. < xspec=${xspec#*-X }
  10507. < xspec=${xspec%% *}
  10508. <
  10509. < COMPREPLY=( $( eval compgen -f -X "$xspec" -- \
  10510. < \"${cur#[\`\"\']}\" 2>/dev/null ) \
  10511. < $( compgen -d -- $cur ) )
  10512. < }
  10513. < list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' \
  10514. < $BASH_COMPLETION | \
  10515. < # read exclusion compspecs
  10516. < (
  10517. < while read line
  10518. < do
  10519. < # ignore compspecs that are commented out
  10520. < if [ "${line#\#}" != "$line" ]; then continue; fi
  10521. < line=${line%# START exclude*}
  10522. < line=${line%# FINISH exclude*}
  10523. < line=${line##*\'}
  10524. < list=( ${list[@]:-} $line )
  10525. < done
  10526. < echo ${list[@]}
  10527. < )
  10528. < ) )
  10529. ---
  10530. > _expand || return 0
  10531. >
  10532. > # get first exclusion compspec that matches this command
  10533. > xspec=$( awk "/^complete[ \t]+.*[ \t]${1##*/}([ \t]|\$)/ { print \$0; exit }" \
  10534. > "$BASH_COMPLETION" )
  10535. > # prune to leave nothing but the -X spec
  10536. > xspec=${xspec#*-X }
  10537. > xspec=${xspec%% *}
  10538. >
  10539. > local -a toks
  10540. > local tmp
  10541. >
  10542. > toks=( ${toks[@]-} $(
  10543. > compgen -d -- "$(quote_readline "$cur")" | {
  10544. > while read -r tmp; do
  10545. > # see long TODO comment in _filedir() --David
  10546. > printf '%s\n' $tmp
  10547. > done
  10548. > }
  10549. > ))
  10550. >
  10551. > toks=( ${toks[@]-} $(
  10552. > eval compgen -f -X "$xspec" -- "\$(quote_readline "\$cur")" | {
  10553. > while read -r tmp; do
  10554. > [ -n $tmp ] && printf '%s\n' $tmp
  10555. > done
  10556. > }
  10557. > ))
  10558. >
  10559. > COMPREPLY=( "${toks[@]}" )
  10560. > }
  10561. > list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' "$BASH_COMPLETION" | \
  10562. > # read exclusion compspecs
  10563. > (
  10564. > while read line
  10565. > do
  10566. > # ignore compspecs that are commented out
  10567. > if [ "${line#\#}" != "$line" ]; then continue; fi
  10568. > line=${line%# START exclude*}
  10569. > line=${line%# FINISH exclude*}
  10570. > line=${line##*\'}
  10571. > list=( "${list[@]}" $line )
  10572. > done
  10573. > printf '%s ' "${list[@]}"
  10574. > )
  10575. > ) )
  10576. 9326c1602
  10577. < eval complete -F _filedir_xspec $filenames ${list[@]}
  10578. ---
  10579. > eval complete -F _filedir_xspec -o filenames "${list[@]}"
  10580. 9331,9336c1607,1622
  10581. < if [ -d $BASH_COMPLETION_DIR -a -r $BASH_COMPLETION_DIR -a \
  10582. < -x $BASH_COMPLETION_DIR ]; then
  10583. < for i in $BASH_COMPLETION_DIR/*; do
  10584. < [[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|.rpm*) ]] &&
  10585. < [ \( -f $i -o -h $i \) -a -r $i ] && . $i
  10586. < done
  10587. ---
  10588. > if [[ -d $BASH_COMPLETION_COMPAT_DIR && -r $BASH_COMPLETION_COMPAT_DIR && \
  10589. > -x $BASH_COMPLETION_COMPAT_DIR ]]; then
  10590. > for i in $(LC_ALL=C command ls "$BASH_COMPLETION_COMPAT_DIR"); do
  10591. > i=$BASH_COMPLETION_COMPAT_DIR/$i
  10592. > [[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)) \
  10593. > && ( -f $i || -h $i ) && -r $i ]] && . "$i"
  10594. > done
  10595. > fi
  10596. > if [[ $BASH_COMPLETION_DIR != $BASH_COMPLETION_COMPAT_DIR && \
  10597. > -d $BASH_COMPLETION_DIR && -r $BASH_COMPLETION_DIR && \
  10598. > -x $BASH_COMPLETION_DIR ]]; then
  10599. > for i in $(LC_ALL=C command ls "$BASH_COMPLETION_DIR"); do
  10600. > i=$BASH_COMPLETION_DIR/$i
  10601. > [[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)) \
  10602. > && ( -f $i || -h $i ) && -r $i ]] && . "$i"
  10603. > done
  10604. 9341,9342c1627,1628
  10605. < [ $BASH_COMPLETION != ~/.bash_completion -a -r ~/.bash_completion ] \
  10606. < && . ~/.bash_completion
  10607. ---
  10608. > [[ $BASH_COMPLETION != ~/.bash_completion && -r ~/.bash_completion ]] \
  10609. > && . ~/.bash_completion
  10610. 9344,9345c1630,1633
  10611. < unset UNAME RELEASE default dirnames filenames have nospace bashdefault \
  10612. < plusdirs
  10613. ---
  10614. > unset UNAME USERLAND have
  10615. >
  10616. > set $BASH_COMPLETION_ORIGINAL_V_VALUE
  10617. > unset BASH_COMPLETION_ORIGINAL_V_VALUE
  10618. 9347,9349c1635,1641
  10619. < ### Local Variables:
  10620. < ### mode: shell-script
  10621. < ### End:
  10622. ---
  10623. > # Local variables:
  10624. > # mode: shell-script
  10625. > # sh-basic-offset: 4
  10626. > # sh-indent-comment: t
  10627. > # indent-tabs-mode: nil
  10628. > # End:
  10629. > # ex: ts=4 sw=4 et filetype=sh
Add Comment
Please, Sign In to add comment