diff --git a/CHANGES b/CHANGES index 791c008d..e1ba72b8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,23 @@ bash-completion (2.x) + [ David Paleino ] + * Fixed "service" completion, thanks to John Hedges (Debian: #586210) + + [ Ville Skyttä ] + * Activate hping2 completion also for hping and hping3. + * Add crontab and lrzip completions. + * Add gif to mplayer filename completions (Alioth: #312512). + * Add "short" tarball extensions to unxz, unlzma etc completions. + * Improve /etc/init.d/* and sqlite3 completions. + + [ Freddy Vulto ] + * Added _tilde(), fix ~username completion (Alioth: #312613, Debian: #587095) + * Speed up `compopt' availability detection + + -- David Paleino Wed, 16 Jun 2010 17:53:22 +0200 + +bash-completion (1.2) + [ David Paleino ] * Don't use pidof in _known_hosts_real() to detect whether Avahi is available, since it's not available on MacOS X. Thanks to Rainer @@ -16,6 +34,12 @@ bash-completion (2.x) * Style policy: don't use fancy globbing in case labels * Added .fdf completion to okular and evince * Added .okular completion to okular (Debian: #545530) + * Added lintian completion + * Refreshed reportbug completion, added --from-buildd (Debian: #579471) + * Special-case "apt-get source" (Debian: #572000) + * Added lintian completion (Debian: #547361) + * contrib/dpkg: update completion to current API + * Styleguide: establish line wrapping and $() instead of `` [ Ville Skyttä ] * Create bz2 dist tarball too. @@ -27,13 +51,13 @@ bash-completion (2.x) * Remove many unnecessary short option completions where long ones exist. * Improve chsh, chgrp, chown, configure, curl, cvs, find, gkrellm, gzip, iconv, lftp, look, lzma, make, man, mdadm, modprobe, mount, mplayer, - mysqladmin, perldoc, rsync, screen, service, scp, ssh, sshfs, + mysqladmin, perldoc, rsync, screen, service, scp, ssh, sshfs, unzip, update-alternatives, vncviewer, wget, yp-tools, xine based players' and general hostname completions. * Add abook and wtf completion, based on work by Raphaël Droz. - * Add cvsps, dragon, fusermount, jarsigner, k3b, lftpget, pm-utils, rtcwake, - pack200, unpack200, pbzip2, pbunzip2, pbzcat, pigz, unpigz, and wol - completions. + * Add cvsps, dragon, fusermount, jarsigner, k3b, lftpget, modplug123, + pm-utils, rtcwake, pack200, unpack200, pbzip2, pbunzip2, pbzcat, pigz, + unpigz, and wol completions. * Don't overwrite other host completions when completing from multiple SSH known hosts files. * Speed up installed rpm package completion on SUSE, based on work by @@ -45,16 +69,22 @@ bash-completion (2.x) to using the complete/compgen features directly, and BASH_VERSINFO for bash version checks. * Protect various completions from unusual user input by not embedding the - input in external command arguments (Debian: 552631). + input in external command arguments (Debian: #552631). * Add /sbin to $PATH when invoking ifconfig and iwconfig. * Combine dcop and qdbus completions into the latter. - * awk and sed usage portability fixes (Alioth: #311393). + * awk and sed usage portability fixes (Alioth: #311393, Debian: #501479). * Fix leaking local variables from various completions. * Turn on -o filenames in _filedir on bash >= 4. * Deprecate modules completion, upstream modules >= 3.2.7 ships one. - * Protect grep invocations from user aliases (Alioth: 312143). + * Protect grep invocations from user aliases (Alioth: #312143). * Split sshfs completion from contrib/ssh into contrib/sshfs. * Split mount and umount completion into contrib/mount. + * Split service completion into contrib/service. + * Split chown, chgrp, and id completions into contrib/coreutils. + * Split kill, look, and renice completions into contrib/util-linux. + * Split killall, pkill, pgrep and related completions into contrib/procps. + * Split ipsec completion into contrib/ipsec. + * Split ifup and ifdown completions into contrib/ifupdown. * Do basic HTML file completion with Firefox and Chrome and friends, and Epiphany. * Do basic diff/patch completion with cdiff and kompare. @@ -63,13 +93,25 @@ bash-completion (2.x) * Do meta-command completion for aoss and padsp. [ Freddy Vulto ] - * Added _get_pword() helper function, thanks to Sung Pae (Alioth: #312030) + * Prevent root PATH expansion prolifering in _root_command (bash >= 4.1.4) + * Only complete xhost if (_)xhost is available. + * Added _get_comp_words_by_ref to replace both _get_cword & _get_pword. + Also additional variables `words' and `cword' can be returned. + * Added _upvar & _upvars helper functions to aid in passing variables + by reference. + * Make _filedir emulate `-o filenames' + * Fixed completion perl modules containing colons. + * Merged __get_cword3 & __get_cword4 to _get_cword. + * Added __expand_tilde_by_ref helper function. + * Added __ltrim_colon_completions to fix completions containing colons + * Improved mutt completion + * Added _get_pword helper function, thanks to Sung Pae (Alioth: #312030) [ Ted Stern ] * Fix modules completion for "(default)" entries. [ Jeremie Lasalle Ratelle ] - * Fix rsync remote path completion (Alioth: #312173). + * Fix rsync remote path completion (Alioth: #312173, Gentoo: #297818). [ Leonard Crestez ] * Improve ssh -o suboption completion (Alioth: #312122). @@ -77,7 +119,8 @@ bash-completion (2.x) * Fix completion of usernames (Alioth: #311396, Debian: #511788). * Fix chown test crashing on systems with no root group (Alioth: #312306). * Fixed tests when BASH_COMPLETION or TESTDIR contain spaces. - * Fix mount handling of escapes (Alioth: #311410, Launchpad: #219971). + * Fix mount handling of escapes (Alioth: #311410, Launchpad: #219971, + Debian: #511149). * Cleanup scripts to run tests. Make runUnit and runCompletion use test/run. Make it possible to run tests from any directory. * Add a --debug-xtrace option to test/run using BASH_XTRACEFD from bash-4.1. @@ -102,12 +145,12 @@ bash-completion (2.x) * Improve xz completion (Alioth: #312466). [ Mario Schwalbe ] - * Update find completion (Alioth: #312491). + * Update find completion (Alioth: #312491, Launchpad: #570113). [ Mark van Rossum ] * Add basic lyx completion. - -- David Paleino Sun, 11 Oct 2009 11:11:57 +0200 + -- David Paleino Wed, 16 Jun 2010 17:44:59 +0200 bash-completion (1.1) diff --git a/Makefile.am b/Makefile.am index bd9284a9..331d234c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,9 +25,11 @@ bashcomp_DATA = contrib/abook \ contrib/cksfv \ contrib/clisp \ contrib/configure \ + contrib/coreutils \ contrib/cowsay \ contrib/cpan2dist \ contrib/cpio \ + contrib/crontab \ contrib/cups \ contrib/cryptsetup \ contrib/cvs \ @@ -54,10 +56,12 @@ bashcomp_DATA = contrib/abook \ contrib/heimdal \ contrib/hping2 \ contrib/iconv \ + contrib/ifupdown \ contrib/imagemagick \ contrib/info \ contrib/iptables \ contrib/ipmitool \ + contrib/ipsec \ contrib/ipv6calc \ contrib/isql \ contrib/jar \ @@ -69,7 +73,9 @@ bashcomp_DATA = contrib/abook \ contrib/lftp \ contrib/lilo \ contrib/links \ + contrib/lintian \ contrib/lisp \ + contrib/lrzip \ contrib/lvm \ contrib/lzma \ contrib/lzop \ @@ -108,6 +114,7 @@ bashcomp_DATA = contrib/abook \ contrib/postfix \ contrib/postgresql \ contrib/povray \ + contrib/procps \ contrib/python \ contrib/qdbus \ contrib/qemu \ @@ -127,10 +134,12 @@ bashcomp_DATA = contrib/abook \ contrib/samba \ contrib/sbcl \ contrib/screen \ + contrib/service \ contrib/shadow \ contrib/sitecopy \ contrib/smartctl \ contrib/snownews \ + contrib/sqlite3 \ contrib/ssh \ contrib/sshfs \ contrib/strace \ @@ -142,10 +151,12 @@ bashcomp_DATA = contrib/abook \ contrib/unace \ contrib/unrar \ contrib/update-alternatives \ + contrib/util-linux \ contrib/vncviewer \ contrib/vpnc \ contrib/wireless-tools \ contrib/wodim \ + contrib/wol \ contrib/wtf \ contrib/wvdial \ contrib/xhost \ diff --git a/bash_completion b/bash_completion index 93e5081e..ef00f05a 100644 --- a/bash_completion +++ b/bash_completion @@ -70,14 +70,15 @@ complete -d pushd # START exclude -- do NOT remove this line # bzcmp, bzdiff, bz*grep, bzless, bzmore intentionally not here, see Debian: #455510 complete -f -X '!*.?(t)bz?(2)' bunzip2 bzcat pbunzip2 pbzcat -complete -f -X '!*.@(zip|ZIP|[ejw]ar|[EJW]AR|exe|EXE|pk3|wsz|zargo|xpi|sxw|ott|od[fgpst]|epub)' unzip zipinfo +complete -f -X '!*.@(zip|ZIP|[ejw]ar|[EJW]AR|exe|EXE|pk3|wsz|zargo|xpi|sxw|o[tx]t|od[fgpst]|epub)' unzip zipinfo complete -f -X '*.Z' compress znew # zcmp, zdiff, z*grep, zless, zmore intentionally not here, see Debian: #455510 complete -f -X '!*.@(Z|[gGd]z|t[ag]z)' gunzip zcat unpigz complete -f -X '!*.Z' uncompress # lzcmp, lzdiff intentionally not here, see Debian: #455510 -complete -f -X '!*.lzma' lzcat lzegrep lzfgrep lzgrep lzless lzmore unlzma -complete -f -X '!*.@(xz|lzma)' unxz xzcat +complete -f -X '!*.@(tlz|lzma)' lzcat lzegrep lzfgrep lzgrep lzless lzmore unlzma +complete -f -X '!*.@(?(t)xz|tlz|lzma)' unxz xzcat +complete -f -X '!*.lrz' lrunzip complete -f -X '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX)' ee complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|X[BP]M|RLE|RGB|PCX|FITS|PM)' xv qiv complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview @@ -92,7 +93,7 @@ complete -f -X '!*.@(?(e)ps|?(E)PS|pdf|PDF)' ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 p complete -f -X '!*.texi*' makeinfo texi2html complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS|ltx|LTX)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi complete -f -X '!*.@(mp3|MP3)' mpg123 mpg321 madplay -complete -f -X '!*@(.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|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]|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 +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 complete -f -X '!*.@(avi|asf|wmv)' aviplay complete -f -X '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay complete -f -X '!*.@(mpg|mpeg|avi|mov|qt)' xanim @@ -101,7 +102,7 @@ complete -f -X '!*.@(mp3|MP3|ogg|OGG|pls|m3u)' gqmpeg freeamp complete -f -X '!*.fig' xfig complete -f -X '!*.@(mid?(i)|MID?(I)|cmf|CMF)' playmidi 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 -complete -f -X '!*.@(m[eo]d|M[EO]D|s[3t]m|S[3T]M|xm|XM|it|IT)' modplugplay +complete -f -X '!*.@(m[eo]d|M[EO]D|s[3t]m|S[3T]M|xm|XM|it|IT)' modplugplay modplug123 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 complete -f -X '!*.@([eE][xX][eE]?(.[sS][oO])|[cC][oO][mM]|[sS][cC][rR])' wine complete -f -X '!*.@(zip|ZIP|z|Z|gz|GZ|tgz|TGZ)' bzme @@ -114,7 +115,6 @@ complete -f -X '!*.@(sxd|std|sda|sdd|odg|otg)' oodraw complete -f -X '!*.@(sxm|smf|mml|odf)' oomath complete -f -X '!*.odb' oobase complete -f -X '!*.rpm' rpm2cpio -complete -f -X '!*.sqlite' sqlite3 complete -f -X '!*.aux' bibtex complete -f -X '!*.po' poedit gtranslator kbabel lokalize complete -f -X '!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])' harbour gharbour hbpp @@ -204,6 +204,68 @@ dequote() } +# Assign variable one scope above the caller +# Usage: local "$1" && _upvar $1 "value(s)" +# Param: $1 Variable name to assign value to +# Param: $* Value(s) to assign. If multiple values, an array is +# assigned, otherwise a single value is assigned. +# NOTE: For assigning multiple variables, use '_upvars'. Do NOT +# use multiple '_upvar' calls, since one '_upvar' call might +# reassign a variable to be used by another '_upvar' call. +# See: http://fvue.nl/wiki/Bash:_Passing_variables_by_reference +_upvar() { + if unset -v "$1"; then # Unset & validate varname + if (( $# == 2 )); then + eval $1=\"\$2\" # Return single value + else + eval $1=\(\"\${@:2}\"\) # Return array + fi + fi +} + + +# Assign variables one scope above the caller +# Usage: local varname [varname ...] && +# _upvars [-v varname value] | [-aN varname [value ...]] ... +# Available OPTIONS: +# -aN Assign next N values to varname as array +# -v Assign single value to varname +# Return: 1 if error occurs +# See: http://fvue.nl/wiki/Bash:_Passing_variables_by_reference +_upvars() { + if ! (( $# )); then + echo "${FUNCNAME[0]}: usage: ${FUNCNAME[0]} [-v varname"\ + "value] | [-aN varname [value ...]] ..." 1>&2 + return 2 + fi + while (( $# )); do + case $1 in + -a*) + # Error checking + [[ ${1#-a} ]] || { echo "bash: ${FUNCNAME[0]}: \`$1': missing"\ + "number specifier" 1>&2; return 1; } + printf %d "${1#-a}" &> /dev/null || { echo "bash:"\ + "${FUNCNAME[0]}: \`$1': invalid number specifier" 1>&2 + return 1; } + # Assign array of -aN elements + [[ "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) && + shift $((${1#-a} + 2)) || { echo "bash: ${FUNCNAME[0]}:"\ + "\`$1${2+ }$2': missing argument(s)" 1>&2; return 1; } + ;; + -v) + # Assign single value + [[ "$2" ]] && unset -v "$2" && eval $2=\"\$3\" && + shift 3 || { echo "bash: ${FUNCNAME[0]}: $1: missing"\ + "argument(s)" 1>&2; return 1; } + ;; + *) + echo "bash: ${FUNCNAME[0]}: $1: invalid option" 1>&2 + return 1 ;; + esac + done +} + + # Reassemble command line words, excluding specified characters from the # list of word completion separators (COMP_WORDBREAKS). # @param $1 chars Characters out of $COMP_WORDBREAKS which should @@ -248,7 +310,7 @@ __reassemble_comp_words_by_ref() { ref="$2[$j]" eval $2[$j]=\${!ref}\${COMP_WORDS[i]} # Indicate new cword - [ $i = $COMP_CWORD ] && [[ ${COMP_WORDS[i]} ]] && eval $3=$j + [[ $i == $COMP_CWORD && ${COMP_WORDS[i]} ]] && eval $3=$j done else # No, list of word completions separators hasn't changed; @@ -267,30 +329,10 @@ __reassemble_comp_words_by_ref() { # @param $4 cur Name of variable to return current word to complete to # @see ___get_cword_at_cursor_by_ref() __get_cword_at_cursor_by_ref() { - # NOTE: The call to the main function ___get_cword_at_cursor_by_ref() is - # wrapped to make collisions with local variable names less likely. - local __words __cword __cur - ___get_cword_at_cursor_by_ref "$1" __words __cword __cur - - eval $2=\( \"\${__words[@]}\" \) - eval $3=\$__cword - eval $4=\$__cur -} - - -# @param $1 exclude -# @param $2 words Name of variable to return words to -# @param $3 cword Name of variable to return cword to -# @param $4 cur Name of variable to return current word to complete to -# @note Do not call this function directly but call -# `__get_cword_at_cursor_by_ref()' instead to make variable name collisions -# less likely -# @see __get_cword_at_cursor_by_ref() -___get_cword_at_cursor_by_ref() { - local cword words + local cword words=() __reassemble_comp_words_by_ref "$1" words cword - local i + local i cur2 local cur="$COMP_LINE" local index="$COMP_POINT" for (( i = 0; i <= cword; ++i )); do @@ -318,13 +360,13 @@ ___get_cword_at_cursor_by_ref() { if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then # We messed up. At least return the whole word so things keep working - eval $4=\"\${words[cword]}\" + cur2=${words[cword]} else - eval $4=\"\${cur:0:\$index}\" + cur2=${cur:0:$index} fi - eval $2=\( \"\${words[@]}\" \) - eval $3=\$cword + local "$2" "$3" "$4" && + _upvars -a${#words[@]} $2 "${words[@]}" -v $3 "$cword" -v $4 "$cur2" } @@ -334,62 +376,66 @@ ___get_cword_at_cursor_by_ref() { # (For example, if the line is "ls foobar", # and the cursor is here --------> ^ # Also one is able to cross over possible wordbreak characters. -# Usage: _get_comp_words_by_ref [OPTIONS] VAR1 [VAR2 [VAR3]] +# Usage: _get_comp_words_by_ref [OPTIONS] [VARNAMES] +# Available VARNAMES: +# cur Return cur via $cur +# prev Return prev via $prev +# words Return words via $words +# cword Return cword via $cword +# +# Available OPTIONS: +# -n EXCLUDE Characters out of $COMP_WORDBREAKS which should NOT be +# considered word breaks. This is useful for things like scp +# where we want to return host:path and not only path, so we +# would pass the colon (:) as -n option in this case. Bash-3 +# doesn't do word splitting, so this ensures we get the same +# word on both bash-3 and bash-4. +# -c VARNAME Return cur via $VARNAME +# -p VARNAME Return prev via $VARNAME +# -w VARNAME Return words via $VARNAME +# -i VARNAME Return cword via $VARNAME +# # Example usage: # # $ _get_comp_words_by_ref -n : cur prev # -# Options: -n EXCLUDE Characters out of $COMP_WORDBREAKS which should NOT -# be considered word breaks. This is useful for things like scp where -# we want to return host:path and not only path, so we would pass the -# colon (:) as -n option in this case. Bash-3 doesn't do word splitting, -# so this ensures we get the same word on both bash-3 and bash-4. -# @see __get_comp_words_by_ref -_get_comp_words_by_ref() { - # NOTE: The call to the main function __get_comp_words_by_ref() is wrapped - # to make collisions with local variable name less likely. - local __words __cword __cur __var __vars - __get_comp_words_by_ref __words __cword __cur __vars "$@" - set -- "${__vars[@]}" - eval $1=\$__cur - shift - for __var; do - ((__cword--)) - [[ ${__words[__cword]} ]] && eval $__var=\${__words[__cword]} - done -} - - -# @param $1 words Name of variable to return words to -# @param $2 cword Name of variable to return cword to -# @param $3 cur Name of variable to return current word to complete to -# @param $4 varnames Name of variable to return array of variable names to -# @param $@ Arguments to _get_comp_words_by_ref() -# @note Do not call this function directly but call `_get_comp_words_by_ref()' -# instead to make variable name collisions less likely -# @see _get_comp_words_by_ref() -__get_comp_words_by_ref() +_get_comp_words_by_ref() { - local exclude flag i OPTIND=5 # Skip first four arguments - local cword words cur varnames=() - while getopts "n:" flag "$@"; do + local exclude flag i OPTIND=1 + local cur cword words=() + local upargs=() upvars=() vcur vcword vprev vwords + + while getopts "c:i:n:p:w:" flag "$@"; do case $flag in + c) vcur=$OPTARG ;; + i) vcword=$OPTARG ;; n) exclude=$OPTARG ;; + p) vprev=$OPTARG ;; + w) vwords=$OPTARG ;; esac done - varnames=( ${!OPTIND} ) - let "OPTIND += 1" while [[ $# -ge $OPTIND ]]; do - varnames+=( ${!OPTIND} ) + case ${!OPTIND} in + cur) vcur=cur ;; + prev) vprev=prev ;; + cword) vcword=cword ;; + words) vwords=words ;; + *) echo "bash: $FUNCNAME(): \`${!OPTIND}': unknown argument" \ + 1>&2; return 1 + esac let "OPTIND += 1" done __get_cword_at_cursor_by_ref "$exclude" words cword cur - eval $1=\( \"\${words[@]}\" \) - eval $2=\$cword - eval $3=\$cur - eval $4=\( \"\${varnames[@]}\" \) + [[ $vcur ]] && { upvars+=("$vcur" ); upargs+=(-v $vcur "$cur" ); } + [[ $vcword ]] && { upvars+=("$vcword"); upargs+=(-v $vcword "$cword"); } + [[ $vprev ]] && { upvars+=("$vprev" ); upargs+=(-v $vprev + "${words[cword - 1]}"); } + [[ $vwords ]] && { upvars+=("$vwords"); upargs+=(-a${#words[@]} $vwords + "${words[@]}"); } + + (( ${#upvars[@]} )) && local "${upvars[@]}" && _upvars "${upargs[@]}" } @@ -407,7 +453,8 @@ __get_comp_words_by_ref() # current word (default is 0, previous is 1), respecting the exclusions # given at $1. For example, `_get_cword "=:" 1' returns the word left of # the current word, respecting the exclusions "=:". -# +# @deprecated Use `_get_comp_words_by_ref cur' instead +# @see _get_comp_words_by_ref() _get_cword() { local LC_CTYPE=C @@ -417,7 +464,7 @@ _get_cword() # return previous word offset by $2 if [[ ${2//[^0-9]/} ]]; then printf "%s" "${words[cword-$2]}" - elif [[ "${#words[cword]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then + elif [[ "${#words[cword]}" -eq 0 || "$COMP_POINT" == "${#COMP_LINE}" ]]; then printf "%s" "${words[cword]}" else local i @@ -461,7 +508,8 @@ _get_cword() # This is a good alternative to `prev=${COMP_WORDS[COMP_CWORD-1]}' because bash4 # will properly return the previous word with respect to any given exclusions to # COMP_WORDBREAKS. -# @see _get_cword() +# @deprecated Use `_get_comp_words_by_ref cur prev' instead +# @see _get_comp_words_by_ref() # _get_pword() { @@ -520,16 +568,32 @@ __ltrim_colon_completions() { # $ compgen -f "a\\\\\'b/" # Good (bash-3) # a\'b/c # -# See also: http://lists.gnu.org/archive/html/bug-bash/2009-03/msg00155.html +# On bash-3, special characters need to be escaped extra. This is +# unless the first character is a single quote ('). If the single +# quote appears further down the string, bash default completion also +# fails, e.g.: +# +# $ ls 'a&b/' +# f +# $ foo 'a&b/ # Becomes: foo 'a&b/f' +# $ foo a'&b/ # Nothing happens +# +# See also: +# - http://lists.gnu.org/archive/html/bug-bash/2009-03/msg00155.html +# - http://www.mail-archive.com/bash-completion-devel@lists.alioth.\ +# debian.org/msg01944.html # @param $1 Argument to quote # @param $2 Name of variable to return result to _quote_readline_by_ref() { if [[ ${1:0:1} == "'" ]]; then - # Quote word, leaving out first character - printf -v $2 %q "${1:1}" - if [[ ${BASH_VERSINFO[0]} -le 3 ]]; then - # Double-quote word on bash-3 + if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then + # Leave out first character + printf -v $2 %s "${1:1}" + else + # Quote word, leaving out first character + printf -v $2 %q "${1:1}" + # Double-quote word (bash-3) printf -v $2 %q ${!2} fi elif [[ ${BASH_VERSINFO[0]} -le 3 && ${1:0:1} == '"' ]]; then @@ -554,7 +618,7 @@ _filedir() { local i IFS=$'\t\n' xspec - __expand_tilde_by_ref cur + _tilde "$cur" || return 0 local -a toks local quoted tmp @@ -573,30 +637,12 @@ _filedir() } )) - # On bash-3, special characters need to be escaped extra. This is - # unless the first character is a single quote ('). If the single - # quote appears further down the string, bash default completion also - # fails, e.g.: - # - # $ ls 'a&b/' - # f - # $ foo 'a&b/ # Becomes: foo 'a&b/f' - # $ foo a'&b/ # Nothing happens - # if [[ "$1" != -d ]]; then xspec=${1:+"!*.$1"} - if [[ ${cur:0:1} == "'" && ${BASH_VERSINFO[0]} -ge 4 ]]; then - toks=( ${toks[@]-} $( - eval compgen -f -X \"\$xspec\" -- $quoted - ) ) - else - toks=( ${toks[@]-} $( - compgen -f -X "$xspec" -- $quoted - ) ) - fi + toks=( ${toks[@]-} $( compgen -f -X "$xspec" -- $quoted) ) if [ ${#toks[@]} -ne 0 ]; then # If `compopt' is available, set `-o filenames' - compopt &>/dev/null && compopt -o filenames || + type compopt &>/dev/null && compopt -o filenames || # No, `compopt' isn't available; # Is `-o filenames' set? [[ ( @@ -757,7 +803,26 @@ _available_interfaces() } +# Perform tilde (~) completion +# @return True (0) if completion needs further processing, +# False (> 0) if tilde is followed by a valid username, completions +# are put in COMPREPLY and no further processing is necessary. +_tilde() { + local result=0 + # Does $1 start with tilde (~) and doesn't contain slash (/)? + if [[ ${1:0:1} == "~" && $1 == ${1//\/} ]]; then + # Try generate username completions + COMPREPLY=( $( compgen -P '~' -u "${1#\~}" ) ) + result=${#COMPREPLY[@]} + fi + return $result +} + + # Expand variable starting with tilde (~) +# We want to expand ~foo/... to /home/foo/... to avoid problems when +# word-to-complete starting with a tilde is fed to commands and ending up +# quoted instead of expanded. # Only the first portion of the variable from the tilde up to the first slash # (~../) is expanded. The remainder of the variable, containing for example # a dollar sign variable ($) or asterisk (*) is not expanded. @@ -1082,299 +1147,13 @@ _dvd_devices() patch configure build install reinstall deinstall clean clean-depends \ kernel buildworld' make -# This completes on a list of all available service scripts for the -# 'service' command and/or the SysV init.d directory, followed by -# that script's available commands -# -{ have service || [ -d /etc/init.d/ ]; } && -_service() -{ - local cur prev sysvdir - - COMPREPLY=() - prev=${COMP_WORDS[COMP_CWORD-1]} - cur=`_get_cword` - - # don't complete for things like killall, ssh and mysql if it's - # the standalone command, rather than the init script - [[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|service) ]] && return 0 - - # don't complete past 2nd token - [ $COMP_CWORD -gt 2 ] && return 0 - - [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d - - if [[ $COMP_CWORD -eq 1 ]] && [[ $prev == "service" ]]; then - _services - else - COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \ - -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \ - $sysvdir/${prev##*/} 2>/dev/null`' -- "$cur" ) ) - fi - - return 0 -} && -complete -F _service service -[ -d /etc/init.d/ ] && complete -F _service -o default \ - $(for i in /etc/init.d/*; do printf '%s\n' ${i##*/}; done) - - -# chown(1) completion -# -_chown() -{ - local cur prev split=false - - # Get cur and prev words; but don't treat user:group as separate words. - cur=`_get_cword :` - prev=`_get_pword :` - - _split_longopt && split=true - - case "$prev" in - --from) - _usergroup - return 0 - ;; - --reference) - _filedir - return 0 - ;; - esac - - $split && return 0 - - if [[ "$cur" == -* ]]; then - # Complete -options - local w opts - for w in "${COMP_WORDS[@]}" ; do - [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break - done - COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes --dereference \ - --no-dereference --from --silent --quiet --reference --recursive \ - --verbose --help --version $opts' -- "$cur" ) ) - else - local args - - # The first argument is an usergroup; the rest are filedir. - _count_args : - - if [[ $args == 1 ]]; then - _usergroup - else - _filedir - fi - fi -} # _chown() -complete -F _chown -o filenames chown - - -# chgrp(1) completion -# -_chgrp() -{ - local cur prev split=false - - COMPREPLY=() - cur=`_get_cword` - cur=${cur//\\\\/} - prev=${COMP_WORDS[COMP_CWORD-1]} - - _split_longopt && split=true - - if [[ "$prev" == --reference ]]; then - _filedir - return 0 - fi - - $split && return 0 - - # options completion - if [[ "$cur" == -* ]]; then - local w opts - for w in "${COMP_WORDS[@]}" ; do - [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break - done - COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes --dereference \ - --no-dereference --silent --quiet --reference --recursive \ - --verbose --help --version $opts' -- "$cur" ) ) - return 0 - fi - - # first parameter on line or first since an option? - if [[ $COMP_CWORD -eq 1 && "$cur" != -* || "$prev" == -* ]]; then - local IFS=$'\n' - COMPREPLY=( $( compgen -g "$cur" 2>/dev/null ) ) - else - _filedir || return 0 - fi - - return 0 -} # _chgrp() -complete -F _chgrp -o filenames chgrp - - -# renice(8) completion -# -_renice() -{ - local command cur curopt i - - COMPREPLY=() - cur=`_get_cword` - command=$1 - - i=0 - # walk back through command line and find last option - while [[ $i -le $COMP_CWORD && ${#COMPREPLY[@]} -eq 0 ]]; do - curopt=${COMP_WORDS[COMP_CWORD-$i]} - case "$curopt" in - -u) - COMPREPLY=( $( compgen -u -- "$cur" ) ) - ;; - -g) - _pgids - ;; - -p|$command) - _pids - ;; - esac - i=$(( ++i )) - done -} -complete -F _renice renice - - -# kill(1) completion -# -_kill() -{ - local cur - - COMPREPLY=() - cur=`_get_cword` - - if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then - # return list of available signals - _signals - else - # return list of available PIDs - _pids - fi -} -complete -F _kill kill - -# killall(1) (Linux and FreeBSD) and pkill(1) completion. -# -[[ $UNAME == Linux || $UNAME == FreeBSD ]] || have pkill && -_killall() -{ - local cur - - COMPREPLY=() - cur=`_get_cword` - - if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then - _signals - else - _pnames - fi - - return 0 -} -[[ $UNAME == Linux || $UNAME == FreeBSD ]] && complete -F _killall killall -have pkill && complete -F _killall pkill - -# pgrep(1) completion. -# -[ $UNAME = Linux ] || have pgrep && -_pgrep() -{ - local cur - - COMPREPLY=() - cur=`_get_cword` - - _pnames - - return 0 -} -have pgrep && complete -F _pgrep pgrep - -# Linux pidof(8) completion. -[ $UNAME = Linux ] && complete -F _pgrep pidof - -# Red Hat & Debian GNU/Linux if{up,down} completion -# -[ $USERLAND = GNU ] && { have ifup || have ifdown; } && -_ifupdown() -{ - local cur - - COMPREPLY=() - cur=`_get_cword` - - if [ $COMP_CWORD -eq 1 ]; then - _configured_interfaces - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) - fi - - return 0 -} && -complete -F _ifupdown ifup ifdown -[ $USERLAND = GNU ] && have ifstatus && complete -F _ifupdown ifstatus - -# Linux ipsec(8) completion (for FreeS/WAN) -# -[ $UNAME = Linux ] && have ipsec && -_ipsec() -{ - local cur - - COMPREPLY=() - cur=`_get_cword` - - - if [ $COMP_CWORD -eq 1 ]; then - COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look manual \ - pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp \ - tncfg whack' -- "$cur" ) ) - return 0 - fi - - case ${COMP_WORDS[1]} in - auto) - COMPREPLY=( $( compgen -W '--asynchronous --up --add --delete \ - --replace --down --route --unroute \ - --ready --status --rereadsecrets' \ - -- "$cur" ) ) - ;; - manual) - COMPREPLY=( $( compgen -W '--up --down --route --unroute \ - --union' -- "$cur" ) ) - ;; - ranbits) - COMPREPLY=( $( compgen -W '--quick --continuous --bytes' \ - -- "$cur" ) ) - ;; - setup) - COMPREPLY=( $( compgen -W '--start --stop --restart' -- "$cur" ) ) - ;; - *) - ;; - esac - - return 0 -} && -complete -F _ipsec ipsec - # This function provides simple user@host completion # _user_at_host() { local cur COMPREPLY=() - cur=`_get_cword :` + _get_comp_words_by_ref -n : cur if [[ $cur == *@* ]]; then _known_hosts_real "$cur" @@ -1580,7 +1359,8 @@ complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 ping \ # _cd() { - local IFS=$'\t\n' cur=`_get_cword` i j k + local cur IFS=$'\t\n' i j k + _get_comp_words_by_ref cur # try to allow variable completion if [[ "$cur" == ?(\\)\$* ]]; then @@ -1683,7 +1463,7 @@ _command_offset() COMP_CWORD=$(( $COMP_CWORD - $word_offset )) COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ $COMP_CWORD -eq 0 ]]; then COMPREPLY=( $( compgen -c -- "$cur" ) ) @@ -1729,7 +1509,8 @@ complete -F _command -o filenames nohup exec nice eval time ltrace then \ _root_command() { - PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin _command $1 $2 $3 + local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin + _command $1 $2 $3 } complete -F _root_command -o filenames sudo fakeroot really gksudo gksu kdesudo @@ -1737,8 +1518,7 @@ _longopt() { local cur prev - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev if _split_longopt; then case "$prev" in @@ -1778,48 +1558,13 @@ for i in env netstat seq uname units; do done unset i -# look(1) completion -# -have look && -_look() -{ - local cur - - COMPREPLY=() - cur=`_get_cword` - - if [ $COMP_CWORD = 1 ]; then - COMPREPLY=( $( compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur" ) ) - fi -} && -complete -F _look -o default look - -# id(1) completion -# -have id && -_id() -{ - local cur - - COMPREPLY=() - cur=`_get_cword` - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-a -g --group -G --groups -n --name\ - -r --real -u --user --help --version' -- "$cur" ) ) - else - COMPREPLY=( $( compgen -u "$cur" ) ) - fi -} && -complete -F _id id - _filedir_xspec() { local IFS cur xspec IFS=$'\t\n' COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _expand || return 0 diff --git a/contrib/_mock b/contrib/_mock index 76ecb8a1..f16f116d 100644 --- a/contrib/_mock +++ b/contrib/_mock @@ -9,8 +9,7 @@ _mock() local cur prev plugins cfgdir split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev plugins='tmpfs root_cache yum_cache bind_mount ccache' cfgdir=/etc/mock diff --git a/contrib/_modules b/contrib/_modules index 73a7190f..f1ad88d8 100644 --- a/contrib/_modules +++ b/contrib/_modules @@ -49,8 +49,7 @@ _module () local cur prev options COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev if [ $COMP_CWORD -eq 1 ] ; then # First parameter on line -- we expect it to be a mode selection diff --git a/contrib/_subversion b/contrib/_subversion index 643ba0d6..06adf830 100644 --- a/contrib/_subversion +++ b/contrib/_subversion @@ -10,7 +10,7 @@ _svn() local cur prev commands options command COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur prev commands='add blame praise annotate ann cat checkout co cleanup commit \ ci copy cp delete del remove rm diff di export help ? h import \ @@ -27,7 +27,6 @@ _svn() fi else - prev=${COMP_WORDS[COMP_CWORD-1]} case $prev in --config-dir) _filedir -d @@ -280,7 +279,7 @@ _svnadmin() local cur prev commands options mode COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur prev commands='create deltify dump help ? hotcopy list-dblogs \ list-unused-dblogs load lslocks lstxns recover rmlocks \ @@ -293,7 +292,6 @@ _svnadmin() COMPREPLY=( $( compgen -W "$commands" -- $cur ) ) fi else - prev=${COMP_WORDS[COMP_CWORD-1]} case $prev in --config-dir) _filedir -d @@ -359,7 +357,7 @@ _svnlook() local cur prev commands options mode COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur commands='author cat changed date diff dirs-changed help ? h history \ info lock log propget pget pg proplist plist pl tree uuid \ diff --git a/contrib/_yum b/contrib/_yum index 7ec3b1aa..19b79cee 100644 --- a/contrib/_yum +++ b/contrib/_yum @@ -39,8 +39,7 @@ _yum() local cur prev special i split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do if [[ ${COMP_WORDS[i]} == @(install|update|upgrade|remove|erase|deplist|info) ]]; then diff --git a/contrib/_yum-utils b/contrib/_yum-utils index 1914ba0a..49a57f76 100644 --- a/contrib/_yum-utils +++ b/contrib/_yum-utils @@ -9,8 +9,7 @@ _repomanage() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev [[ "$prev" == -@(h|-help|k|-keep) ]] && return 0 diff --git a/contrib/abook b/contrib/abook index b01c932b..2a3bc4f6 100644 --- a/contrib/abook +++ b/contrib/abook @@ -6,8 +6,7 @@ _abook() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev # abook only takes options, tabbing after command name adds a single # dash (bash4) diff --git a/contrib/ant b/contrib/ant index 9ba08525..e0d835d6 100644 --- a/contrib/ant +++ b/contrib/ant @@ -7,8 +7,7 @@ _ant() local cur prev buildfile i COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -buildfile|-file|-f) diff --git a/contrib/apache2ctl b/contrib/apache2ctl index 1d6ff835..287443a2 100644 --- a/contrib/apache2ctl +++ b/contrib/apache2ctl @@ -5,7 +5,7 @@ _apache2ctl() { local APWORDS cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur APWORDS=$(apache2ctl 2>&1 >/dev/null | awk 'NR<2 { print $3; exit }' | \ tr "|" " ") diff --git a/contrib/apt b/contrib/apt index 53a7dcc9..4010a0d5 100644 --- a/contrib/apt +++ b/contrib/apt @@ -6,8 +6,7 @@ _apt_get() local cur prev special i COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do if [[ ${COMP_WORDS[i]} == @(install|remove|autoremove|purge|source|build-dep) ]]; then @@ -27,6 +26,12 @@ _apt_get() fi return 0 ;; + source) + COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ + 2> /dev/null ) $( apt-cache dumpavail | \ + command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) ) + return 0 + ;; *) COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ 2> /dev/null ) ) @@ -76,9 +81,7 @@ _apt_cache() local cur prev special i COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} - + _get_comp_words_by_ref cur prev if [ "$cur" != show ]; then for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do diff --git a/contrib/apt-build b/contrib/apt-build index 9d9508f3..9597ae8d 100644 --- a/contrib/apt-build +++ b/contrib/apt-build @@ -6,8 +6,7 @@ _apt_build() local cur prev special i COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do if [[ ${COMP_WORDS[i]} == @(install|remove|source|info|clean) ]]; then diff --git a/contrib/aptitude b/contrib/aptitude index e4c8b688..c00ad40e 100644 --- a/contrib/aptitude +++ b/contrib/aptitude @@ -19,9 +19,7 @@ _aptitude() local cur dashoptions prev special i COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} - + _get_comp_words_by_ref cur prev dashoptions='-S -u -i -h --help --version -s --simulate -d \ --download-only -P --prompt -y --assume-yes -F \ diff --git a/contrib/aspell b/contrib/aspell index 9c56c992..e063f497 100644 --- a/contrib/aspell +++ b/contrib/aspell @@ -19,8 +19,7 @@ _aspell() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/autorpm b/contrib/autorpm index e111af02..6a5f7620 100644 --- a/contrib/autorpm +++ b/contrib/autorpm @@ -6,7 +6,7 @@ _autorpm() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur COMPREPLY=( $( compgen -W '--notty --debug --help --version auto add \ fullinfo info help install list remove set' -- "$cur" ) ) diff --git a/contrib/bash-builtins b/contrib/bash-builtins index 61c9d8d4..aac75ae0 100644 --- a/contrib/bash-builtins +++ b/contrib/bash-builtins @@ -5,7 +5,7 @@ _alias() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur case $COMP_LINE in *[^=]) @@ -26,7 +26,7 @@ _export() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur case $COMP_LINE in *=\$*) @@ -52,8 +52,7 @@ _function() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev if [[ $1 == @(declare|typeset) ]]; then if [ "$prev" = -f ]; then @@ -76,8 +75,7 @@ _complete() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -o) diff --git a/contrib/bind-utils b/contrib/bind-utils index 6c005392..040d1975 100644 --- a/contrib/bind-utils +++ b/contrib/bind-utils @@ -6,7 +6,7 @@ _nslookup() local cur COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]#-} + _get_comp_words_by_ref cur COMPREPLY=( $( compgen -P '-' -W 'all class= debug d2 domain= srchlist= \ defname search port= querytype= type= recurse retry root timeout vc \ diff --git a/contrib/bitkeeper b/contrib/bitkeeper index 7d48869c..4c312a14 100644 --- a/contrib/bitkeeper +++ b/contrib/bitkeeper @@ -5,7 +5,7 @@ _bk() { local BKCMDS COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur BKCMDS="$( bk help topics | awk '/^ bk/ { print $4 }' | \ xargs printf '%s ' )" diff --git a/contrib/bittorrent b/contrib/bittorrent index 4c0fe7fb..761d0836 100644 --- a/contrib/bittorrent +++ b/contrib/bittorrent @@ -7,8 +7,7 @@ _btdownload() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --responsefile|--saveas) diff --git a/contrib/bluez b/contrib/bluez index a420398e..7a2b1e57 100644 --- a/contrib/bluez +++ b/contrib/bluez @@ -33,8 +33,7 @@ _hcitool() local cur prev split=false arg COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -116,8 +115,7 @@ _sdptool() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -178,8 +176,7 @@ _l2ping() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -i) @@ -202,8 +199,7 @@ _rfcomm() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -f|--config) @@ -248,8 +244,7 @@ _ciptool() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -i) @@ -285,8 +280,7 @@ _dfutool() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -d|--device) @@ -317,7 +311,7 @@ _hciconfig() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _get_first_arg if [ -z $arg ]; then @@ -363,7 +357,7 @@ _hciattach() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-n -p -t -b -s -l' -- "$cur" ) ) @@ -401,7 +395,7 @@ _hid2hci() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --quiet -0 --tohci -1 \ @@ -415,7 +409,7 @@ _avctrl() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --quiet' -- "$cur" ) ) diff --git a/contrib/brctl b/contrib/brctl index 14401eee..1be86af1 100644 --- a/contrib/brctl +++ b/contrib/brctl @@ -6,7 +6,7 @@ _brctl() local cur command COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur command=${COMP_WORDS[1]} case $COMP_CWORD in diff --git a/contrib/bzip2 b/contrib/bzip2 index 9001dd58..f4902e29 100644 --- a/contrib/bzip2 +++ b/contrib/bzip2 @@ -6,8 +6,7 @@ _bzip2() local cur prev xspec helpopts COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev helpopts=`_parse_help ${COMP_WORDS[0]}` case $prev in diff --git a/contrib/cardctl b/contrib/cardctl index dfd7403b..1af7491b 100644 --- a/contrib/cardctl +++ b/contrib/cardctl @@ -6,7 +6,7 @@ _cardctl() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -W 'status config ident suspend \ diff --git a/contrib/cfengine b/contrib/cfengine index 63df3409..50a13840 100644 --- a/contrib/cfengine +++ b/contrib/cfengine @@ -17,8 +17,7 @@ _cfagent() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -f|--file) @@ -35,10 +34,10 @@ complete -F _cfagent cfagent _cfrun() { - local i section cfinputs + local i section cfinputs cur prev COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur prev section=1 for (( i=1; i < COMP_CWORD; i++ )); do @@ -49,7 +48,6 @@ _cfrun() case $section in 1) - prev=${COMP_WORDS[COMP_CWORD-1]} case $prev in -f) _filedir diff --git a/contrib/chkconfig b/contrib/chkconfig index 7f65d069..2d02e56e 100644 --- a/contrib/chkconfig +++ b/contrib/chkconfig @@ -6,8 +6,7 @@ _chkconfig() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/chsh b/contrib/chsh index fd947b8f..1af3630f 100644 --- a/contrib/chsh +++ b/contrib/chsh @@ -5,8 +5,7 @@ _chsh() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --list-shells|--help|-v|--version) diff --git a/contrib/cksfv b/contrib/cksfv index 34bf0f5d..1f83824b 100644 --- a/contrib/cksfv +++ b/contrib/cksfv @@ -3,15 +3,17 @@ have cksfv && _cksfv() { + local cur prev + COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur prev if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -W '-C -f -i -q -v' -- "$cur" ) ) return 0 fi - case ${COMP_WORDS[$COMP_CWORD-1]} in + case "$prev" in -C) _filedir -d return 0 diff --git a/contrib/clisp b/contrib/clisp index 18b783e4..074f692c 100644 --- a/contrib/clisp +++ b/contrib/clisp @@ -7,7 +7,7 @@ _clisp() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur # completing an option (may or may not be separated by a space) if [[ "$cur" == -* ]]; then diff --git a/contrib/configure b/contrib/configure index 419b744e..d69f85b1 100644 --- a/contrib/configure +++ b/contrib/configure @@ -5,8 +5,7 @@ _configure() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/coreutils b/contrib/coreutils new file mode 100644 index 00000000..65809fbb --- /dev/null +++ b/contrib/coreutils @@ -0,0 +1,122 @@ +# Completions for various core utilities + +# chown(1) completion +# +have chown && +_chown() +{ + local cur prev split=false + + # Get cur and prev words; but don't treat user:group as separate words. + _get_comp_words_by_ref -n : cur prev + + _split_longopt && split=true + + case "$prev" in + --from) + _usergroup + return 0 + ;; + --reference) + _filedir + return 0 + ;; + esac + + $split && return 0 + + if [[ "$cur" == -* ]]; then + # Complete -options + local w opts + for w in "${COMP_WORDS[@]}" ; do + [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break + done + COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes --dereference \ + --no-dereference --from --silent --quiet --reference --recursive \ + --verbose --help --version $opts' -- "$cur" ) ) + else + local args + + # The first argument is an usergroup; the rest are filedir. + _count_args : + + if [[ $args == 1 ]]; then + _usergroup + else + _filedir + fi + fi +} && +complete -F _chown -o filenames chown + + +# chgrp(1) completion +# +have chgrp && +_chgrp() +{ + local cur prev split=false + + COMPREPLY=() + _get_comp_words_by_ref cur prev + cur=${cur//\\\\/} + + _split_longopt && split=true + + if [[ "$prev" == --reference ]]; then + _filedir + return 0 + fi + + $split && return 0 + + # options completion + if [[ "$cur" == -* ]]; then + local w opts + for w in "${COMP_WORDS[@]}" ; do + [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break + done + COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes --dereference \ + --no-dereference --silent --quiet --reference --recursive \ + --verbose --help --version $opts' -- "$cur" ) ) + return 0 + fi + + # first parameter on line or first since an option? + if [[ $COMP_CWORD -eq 1 && "$cur" != -* || "$prev" == -* ]]; then + local IFS=$'\n' + COMPREPLY=( $( compgen -g "$cur" 2>/dev/null ) ) + else + _filedir || return 0 + fi + + return 0 +} && +complete -F _chgrp -o filenames chgrp + +# id(1) completion +# +have id && +_id() +{ + local cur + + COMPREPLY=() + _get_comp_words_by_ref cur + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-a -g --group -G --groups -n --name\ + -r --real -u --user --help --version' -- "$cur" ) ) + else + COMPREPLY=( $( compgen -u "$cur" ) ) + fi +} && +complete -F _id id + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/contrib/cowsay b/contrib/cowsay index f3ed3bd9..c6d797aa 100644 --- a/contrib/cowsay +++ b/contrib/cowsay @@ -6,8 +6,7 @@ _cowsay() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -f) diff --git a/contrib/cpan2dist b/contrib/cpan2dist index f6974d40..13f568af 100644 --- a/contrib/cpan2dist +++ b/contrib/cpan2dist @@ -6,8 +6,7 @@ _cpan2dist() local cur prev packagelist cpandirs COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --format) diff --git a/contrib/cpio b/contrib/cpio index dddfc190..e77b4153 100644 --- a/contrib/cpio +++ b/contrib/cpio @@ -11,8 +11,7 @@ _cpio() local cur prev split=false COMPREPLY=() - cur=`_get_cword :` - prev=`_get_pword :` + _get_comp_words_by_ref -n : cur prev _split_longopt && split=true diff --git a/contrib/crontab b/contrib/crontab new file mode 100644 index 00000000..cb440a6f --- /dev/null +++ b/contrib/crontab @@ -0,0 +1,60 @@ +# crontab(1) completion + +have crontab && +_crontab() +{ + local cur prev + COMPREPLY=() + _get_comp_words_by_ref cur prev + + case $prev in + -u) + COMPREPLY=( $( compgen -u -- "$cur" ) ) + return 0 + ;; + esac + + local i opts=" -u -l -r -e" # leading space at start is significant... + [ "$(uname -s)" = Linux ] && opts="$opts -i" + [ -e /etc/selinux ] && opts="$opts -s" + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + case "${COMP_WORDS[i]}" in + -l) + opts=${opts// -l -r -e/} + opts=${opts// -i/} + opts=${opts// -s/} + ;; + -e) + opts=${opts// -l -r -e/} + opts=${opts// -i/} + ;; + -r) + opts=${opts// -l -r -e/} + ;; + -u) + opts=${opts// -u/} + opts=${opts// -i/} + ;; + -i|-s) + opts=${opts// ${COMP_WORDS[i]}/} + ;; + esac + done + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) ) + return 0 + fi + + # do filenames only if we did not have -l, -r, or -e + [[ "${COMP_LINE}" == *\ -@(l|r|e)* ]] || _filedir +} && +complete -F _crontab -o filenames crontab + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/contrib/cups b/contrib/cups index 9550808e..80c9af54 100644 --- a/contrib/cups +++ b/contrib/cups @@ -6,7 +6,7 @@ _cancel() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur COMPREPLY=( $( compgen -W "$( lpstat | cut -d' ' -f1 )" -- "$cur" ) ) } && diff --git a/contrib/cvs b/contrib/cvs index 5c915d51..be3b1be7 100644 --- a/contrib/cvs +++ b/contrib/cvs @@ -60,8 +60,7 @@ _cvs() local -a flags miss files entries changed newremoved COMPREPLY=() - cur=`_get_cword :` - prev=`_get_pword :` + _get_comp_words_by_ref -n : cur prev count=0 for i in "${COMP_WORDS[@]}"; do @@ -239,7 +238,7 @@ _cvs() set_prefix - if [[ "$cur" != -* ]] && [ -r ${prefix:-}CVS/Entries ]; then + if [[ "$cur" != -* && -r ${prefix:-}CVS/Entries ]]; then # if $COMP_CVS_REMOTE is not null, 'cvs commit' will # complete on remotely checked-out files (requires # passwordless access to the remote repository diff --git a/contrib/cvsps b/contrib/cvsps index a9566f64..257437bc 100644 --- a/contrib/cvsps +++ b/contrib/cvsps @@ -4,7 +4,8 @@ have cvsps && _cvsps() { COMPREPLY=() - local cur=`_get_cword :` prev=`_get_pword :` + local cur prev + _get_comp_words_by_ref -n : cur prev case $prev in -h|-z|-f|-d|-l|--diff-opts|--debuglvl) diff --git a/contrib/dd b/contrib/dd index bbca4783..e236f85a 100644 --- a/contrib/dd +++ b/contrib/dd @@ -6,7 +6,7 @@ _dd() local cur COMPREPLY=() - cur=`_get_cword =` + _get_comp_words_by_ref -n = cur case $cur in if=*|of=*) diff --git a/contrib/dhclient b/contrib/dhclient index 5ce15883..3d7e1e1a 100644 --- a/contrib/dhclient +++ b/contrib/dhclient @@ -5,8 +5,7 @@ have dhclient && _dhclient() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -cf|-lf|-pf|-sf) diff --git a/contrib/dict b/contrib/dict index 0b6a1ba5..4cfdf98f 100644 --- a/contrib/dict +++ b/contrib/dict @@ -12,8 +12,7 @@ _dict() local cur prev host port db dictfile COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev dictfile=/usr/share/dict/words for (( i=1; i < COMP_CWORD; i++ )); do diff --git a/contrib/dselect b/contrib/dselect index ddd22927..8bea891a 100644 --- a/contrib/dselect +++ b/contrib/dselect @@ -6,8 +6,7 @@ _dselect() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --admindir) diff --git a/contrib/dsniff b/contrib/dsniff index 95875be3..1d3b303b 100644 --- a/contrib/dsniff +++ b/contrib/dsniff @@ -6,8 +6,7 @@ _arpspoof() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=`_get_pword` + _get_comp_words_by_ref cur prev case $prev in -i) @@ -35,8 +34,7 @@ _dnsspoof() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -i) @@ -62,8 +60,7 @@ _dsniff() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -r|-w|-f) @@ -89,8 +86,7 @@ _snarf() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -i) @@ -112,8 +108,7 @@ _macof() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -i) @@ -136,7 +131,7 @@ _sshmitm() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-d -I -p' -- "$cur" ) ) @@ -153,8 +148,7 @@ _sshow() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -i) @@ -176,8 +170,7 @@ _tcpkill() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -i) @@ -199,8 +192,7 @@ _tcpnice() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -i) @@ -222,8 +214,7 @@ _urlsnarf() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -i) @@ -245,7 +236,7 @@ _webmitm() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-d' -- "$cur" ) ) diff --git a/contrib/findutils b/contrib/findutils index 73179a40..6af5d50b 100644 --- a/contrib/findutils +++ b/contrib/findutils @@ -8,8 +8,7 @@ _find() local cur prev i exprfound onlyonce COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -maxdepth|-mindepth) diff --git a/contrib/freeciv b/contrib/freeciv index 6f5e167c..602ad76a 100644 --- a/contrib/freeciv +++ b/contrib/freeciv @@ -6,8 +6,7 @@ _civserver() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -f|-g|-l|-r|--file|--log|--gamelog|--read) @@ -31,8 +30,7 @@ _civclient() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -l|-S|-t|--log|--Sound|--tiles) diff --git a/contrib/fuse b/contrib/fuse index e09b8757..b4d80a28 100644 --- a/contrib/fuse +++ b/contrib/fuse @@ -4,7 +4,8 @@ have fusermount && _fusermount() { COMPREPLY=() - local cur=`_get_cword` prev=`_get_pword` + local cur prev + _get_comp_words_by_ref cur prev case $prev in -h|-V|-o) diff --git a/contrib/gcc b/contrib/gcc index b3cdeb7e..3f5a5619 100644 --- a/contrib/gcc +++ b/contrib/gcc @@ -14,7 +14,7 @@ _gcc() local cur cc backend COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _expand || return 0 diff --git a/contrib/gcl b/contrib/gcl index e3df88cf..e0931536 100644 --- a/contrib/gcl +++ b/contrib/gcl @@ -7,7 +7,7 @@ _gcl() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur # completing an option (may or may not be separated by a space) if [[ "$cur" == -* ]]; then diff --git a/contrib/gdb b/contrib/gdb index e33ec029..dc769613 100644 --- a/contrib/gdb +++ b/contrib/gdb @@ -6,8 +6,7 @@ _gdb() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev if [ $COMP_CWORD -eq 1 ]; then local IFS diff --git a/contrib/genisoimage b/contrib/genisoimage index 4aafe250..7f379041 100644 --- a/contrib/genisoimage +++ b/contrib/genisoimage @@ -6,8 +6,7 @@ _mkisofs() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -o|-abstract|-biblio|-check-session|-copyright|-log-file| \ diff --git a/contrib/getent b/contrib/getent index 008f3abc..54e62ab8 100644 --- a/contrib/getent +++ b/contrib/getent @@ -6,8 +6,7 @@ _getent() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in passwd) diff --git a/contrib/gkrellm b/contrib/gkrellm index 08b5b6d8..1e3925f1 100644 --- a/contrib/gkrellm +++ b/contrib/gkrellm @@ -6,8 +6,7 @@ _gkrellm() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -t|--theme) diff --git a/contrib/gnatmake b/contrib/gnatmake index 42e9bcef..11b04908 100644 --- a/contrib/gnatmake +++ b/contrib/gnatmake @@ -6,7 +6,7 @@ _gnatmake() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then # relevant (and less relevant ;-) )options completion diff --git a/contrib/gpg b/contrib/gpg index 3d9ad4d5..878a800b 100644 --- a/contrib/gpg +++ b/contrib/gpg @@ -6,8 +6,7 @@ _gpg() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -s|--sign|--clearsign|--decrypt-files|--load-extension) diff --git a/contrib/gpg2 b/contrib/gpg2 index 2017bdd0..b99783f9 100644 --- a/contrib/gpg2 +++ b/contrib/gpg2 @@ -6,8 +6,7 @@ _gpg2 () local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --homedir) diff --git a/contrib/gzip b/contrib/gzip index 931423d5..0951f72f 100644 --- a/contrib/gzip +++ b/contrib/gzip @@ -6,8 +6,7 @@ _gzip() local cur prev xspec helpopts COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev helpopts=`_parse_help ${COMP_WORDS[0]}` case $prev in diff --git a/contrib/heimdal b/contrib/heimdal index 9e3d181e..c1efb110 100644 --- a/contrib/heimdal +++ b/contrib/heimdal @@ -28,8 +28,7 @@ _ktutil() local cur prev command options split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/hping2 b/contrib/hping2 index b1607f83..e2e6bf1a 100644 --- a/contrib/hping2 +++ b/contrib/hping2 @@ -1,6 +1,6 @@ # bash completion for hping2 -have hping2 && +have hping || have hping2 || have hping3 && _hping2() { local cur prev @@ -44,7 +44,7 @@ _hping2() _known_hosts_real "$cur" fi } && -complete -F _hping2 hping2 hping +complete -F _hping2 hping hping2 hping3 # Local variables: # mode: shell-script diff --git a/contrib/iconv b/contrib/iconv index 959ce40f..14b618dc 100644 --- a/contrib/iconv +++ b/contrib/iconv @@ -6,8 +6,7 @@ _iconv() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/ifupdown b/contrib/ifupdown new file mode 100644 index 00000000..f81e08d5 --- /dev/null +++ b/contrib/ifupdown @@ -0,0 +1,27 @@ +# Red Hat & Debian GNU/Linux if{up,down} completion +# +[ $USERLAND = GNU ] && { have ifup || have ifdown; } && +_ifupdown() +{ + local cur + + COMPREPLY=() + _get_comp_words_by_ref cur + + if [ $COMP_CWORD -eq 1 ]; then + _configured_interfaces + COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + fi + + return 0 +} && +complete -F _ifupdown ifup ifdown +[ $USERLAND = GNU ] && have ifstatus && complete -F _ifupdown ifstatus + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/contrib/imagemagick b/contrib/imagemagick index caa758e0..5366e619 100644 --- a/contrib/imagemagick +++ b/contrib/imagemagick @@ -3,8 +3,8 @@ have convert && { _ImageMagick() { - local prev - prev=${COMP_WORDS[COMP_CWORD-1]} + local cur prev + _get_comp_words_by_ref cur prev case $prev in -channel) @@ -135,7 +135,7 @@ _convert() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _ImageMagick @@ -196,7 +196,7 @@ _mogrify() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _ImageMagick @@ -252,7 +252,7 @@ _display() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _ImageMagick @@ -292,7 +292,7 @@ _animate() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _ImageMagick @@ -326,7 +326,7 @@ _identify() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _ImageMagick @@ -351,7 +351,7 @@ _montage() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _ImageMagick @@ -389,7 +389,7 @@ _composite() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _ImageMagick @@ -424,7 +424,7 @@ _compare() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _ImageMagick @@ -451,7 +451,7 @@ _conjure() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _ImageMagick @@ -471,7 +471,7 @@ _import() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _ImageMagick @@ -502,7 +502,7 @@ _stream() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _ImageMagick diff --git a/contrib/info b/contrib/info index 691edf64..55791d31 100644 --- a/contrib/info +++ b/contrib/info @@ -6,7 +6,7 @@ _info() local cur i infopath COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _expand || return 0 diff --git a/contrib/ipmitool b/contrib/ipmitool index 112b0965..fc4ec71c 100644 --- a/contrib/ipmitool +++ b/contrib/ipmitool @@ -6,8 +6,7 @@ _ipmitool() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -I) diff --git a/contrib/ipsec b/contrib/ipsec new file mode 100644 index 00000000..acb8c995 --- /dev/null +++ b/contrib/ipsec @@ -0,0 +1,51 @@ +# Linux ipsec(8) completion (for FreeS/WAN) +# +[ $UNAME = Linux ] && have ipsec && +_ipsec() +{ + local cur + + COMPREPLY=() + _get_comp_words_by_ref cur + + + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look manual \ + pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp \ + tncfg whack' -- "$cur" ) ) + return 0 + fi + + case ${COMP_WORDS[1]} in + auto) + COMPREPLY=( $( compgen -W '--asynchronous --up --add --delete \ + --replace --down --route --unroute \ + --ready --status --rereadsecrets' \ + -- "$cur" ) ) + ;; + manual) + COMPREPLY=( $( compgen -W '--up --down --route --unroute \ + --union' -- "$cur" ) ) + ;; + ranbits) + COMPREPLY=( $( compgen -W '--quick --continuous --bytes' \ + -- "$cur" ) ) + ;; + setup) + COMPREPLY=( $( compgen -W '--start --stop --restart' -- "$cur" ) ) + ;; + *) + ;; + esac + + return 0 +} && +complete -F _ipsec ipsec + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/contrib/iptables b/contrib/iptables index 405b7eec..bd0e4622 100644 --- a/contrib/iptables +++ b/contrib/iptables @@ -6,8 +6,7 @@ _iptables() local cur prev table chain COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p' if [[ $COMP_LINE == *-t\ *filter* ]]; then diff --git a/contrib/ipv6calc b/contrib/ipv6calc index dca4c144..75f55e74 100644 --- a/contrib/ipv6calc +++ b/contrib/ipv6calc @@ -4,8 +4,9 @@ _ipv6calc() local cur prev split=false COMPREPLY=() - cur=`_get_cword =` - prev=`_get_pword` + _get_comp_words_by_ref -n = cur prev + #cur=`_get_cword =` + #prev=`_get_pword` _split_longopt && split=true diff --git a/contrib/isql b/contrib/isql index fef0c0aa..f0ddbd75 100644 --- a/contrib/isql +++ b/contrib/isql @@ -4,7 +4,7 @@ have isql && _isql() { local cur - cur=`_get_cword` + _get_comp_words_by_ref cur [ -f "$ODBCINI" ] \ && COMPREPLY=( $( command grep \\["$cur" "$ODBCINI" | tr -d \\[\\] ) ) diff --git a/contrib/jar b/contrib/jar index 11d3ffe9..75dcaf3e 100644 --- a/contrib/jar +++ b/contrib/jar @@ -6,7 +6,7 @@ _jar() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [ $COMP_CWORD = 1 ]; then COMPREPLY=( $( compgen -W 'c t x u' -- "$cur" ) ) diff --git a/contrib/java b/contrib/java index b9418ed8..76d2cd4e 100644 --- a/contrib/java +++ b/contrib/java @@ -121,8 +121,7 @@ _java() local cur prev i COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev for ((i=1; i < $COMP_CWORD; i++)); do case ${COMP_WORDS[$i]} in @@ -174,8 +173,7 @@ _javadoc() COMPREPLY=() local cur prev classpath - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -overview|-helpfile|-stylesheetfile) @@ -222,8 +220,7 @@ _javac() COMPREPLY=() local cur prev - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -d) @@ -253,7 +250,8 @@ have pack200 && _pack200() { COMPREPLY=() - local cur=`_get_cword` prev=`_get_pword` + local cur prev + _get_comp_words_by_ref cur prev case $prev in -S|--segment-limit|-P|--pass-file|-C|--class-attribute|\ @@ -320,7 +318,8 @@ have unpack200 && _unpack200() { COMPREPLY=() - local cur=`_get_cword` prev=`_get_pword` + local cur prev + _get_comp_words_by_ref cur prev case $prev in '-?'|-h|--help|-V|--version|-J) @@ -365,7 +364,8 @@ have jarsigner && _jarsigner() { COMPREPLY=() - local cur=`_get_cword` prev=`_get_pword` + local cur prev + _get_comp_words_by_ref cur prev case $prev in -keystore) diff --git a/contrib/k3b b/contrib/k3b index 44a4ed09..a2b0af6b 100644 --- a/contrib/k3b +++ b/contrib/k3b @@ -3,7 +3,8 @@ have k3b && _k3b() { - local cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} + local cur prev + _get_comp_words_by_ref cur prev COMPREPLY=() case $prev in diff --git a/contrib/kldload b/contrib/kldload index ff5ced1d..a230dbb5 100644 --- a/contrib/kldload +++ b/contrib/kldload @@ -9,7 +9,7 @@ _kldload() moddir=/modules/ [ -d $moddir ] || moddir=/boot/kernel/ - cur=`_get_cword` + _get_comp_words_by_ref cur COMPREPLY=( $( compgen -f "$moddir$cur" ) ) COMPREPLY=( ${COMPREPLY[@]#$moddir} ) @@ -22,7 +22,7 @@ complete -F _kldload -o filenames kldload _kldunload() { local cur - cur=`_get_cword` + _get_comp_words_by_ref cur COMPREPLY=( $( kldstat | \ sed -ne "s/^.*[ \t]\{1,\}\($cur[a-z_]\{1,\}\).ko$/\1/p" ) ) } diff --git a/contrib/larch b/contrib/larch index 6dcaf545..e58374f7 100644 --- a/contrib/larch +++ b/contrib/larch @@ -6,8 +6,7 @@ _larch() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then COMPREPLY=( $( compgen -W ' \ diff --git a/contrib/ldapvi b/contrib/ldapvi index 7a64b0fe..31e26d1c 100644 --- a/contrib/ldapvi +++ b/contrib/ldapvi @@ -6,8 +6,7 @@ _ldapvi() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -h|--host) diff --git a/contrib/lftp b/contrib/lftp index ba1f4938..15d0a977 100644 --- a/contrib/lftp +++ b/contrib/lftp @@ -6,8 +6,7 @@ _lftp() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -f) @@ -34,7 +33,8 @@ have lftpget && _lftpget() { COMPREPLY=() - local cur=`_get_cword` + local cur + _get_comp_words_by_ref cur if [[ "$cur" == -* ]] ; then COMPREPLY=( $( compgen -W '-c -d -v' -- "$cur" ) ) diff --git a/contrib/lilo b/contrib/lilo index c5ff155a..ab0d9dc3 100644 --- a/contrib/lilo +++ b/contrib/lilo @@ -12,8 +12,7 @@ _lilo() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -C|-i|-m|-s|-S) diff --git a/contrib/links b/contrib/links index 62b8ead1..4b5c683a 100644 --- a/contrib/links +++ b/contrib/links @@ -6,7 +6,7 @@ _links() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur case $cur in --*) diff --git a/contrib/lintian b/contrib/lintian new file mode 100644 index 00000000..a1f51546 --- /dev/null +++ b/contrib/lintian @@ -0,0 +1,186 @@ +# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*- +# ex: ts=8 sw=8 noet filetype=sh +# +# bash completion for lintian(1) and lintian-info(1) + +have lintian && { +_lintian_tags() { + local match search tags + + tags=$( grep -e ^Tag /usr/share/lintian/checks/*.desc | cut -d\ -f2 ) + if [[ "$cur" == *, ]]; then + search=${cur//,/ } + for item in $search; do + match=$(grep -nE "^Tag: $item$" /usr/share/lintian/checks/*.desc \ + | cut -d: -f1 ) + tags=$( echo $tags | sed -e "s/\<$item\>//g" ) + done + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$tags") ) + elif [[ "$cur" == *,* ]]; then + COMPREPLY=( ${COMPREPLY[@]} $(compgen -P "${cur%,*}," -W "$tags" -- \ + "${cur##*,}") ) + else + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$tags" -- "$cur") ) + fi + return 0 +} + +_lintian_checks() { + local match search todisable checks + + checks=$(grep -e ^Check-Script -e ^Abbrev \ + /usr/share/lintian/checks/*.desc | cut -d\ -f2 ) + if [[ "$cur" == *, ]]; then + search=${cur//,/ } + for item in $search; do + match=$(grep -nE "^(Check-Script|Abbrev): $item$" \ + /usr/share/lintian/checks/*.desc | cut -d: -f1 ) + todisable=$(grep -e ^Check-Script -e ^Abbrev $match | \ + cut -d\ -f2 ) + for name in $todisable; do + checks=$( echo $checks | sed -e "s/\<$name\>//g" ) + done + done + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$checks") ) + elif [[ "$cur" == *,* ]]; then + COMPREPLY=( ${COMPREPLY[@]} $(compgen -P "${cur%,*}," -W "$checks" \ + -- "${cur##*,}") ) + else + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$checks" -- "$cur") ) + fi + return 0 +} + +_lintian_infos() { + local match search infos + + infos=$(grep -e ^Collector /usr/share/lintian/collection/*.desc \ + | cut -d\ -f2 ) + if [[ "$cur" == *, ]]; then + search=${cur//,/ } + for item in $search; do + match=$( grep -nE "^Collector: $item$" \ + /usr/share/lintian/collection/*.desc | cut -d: -f1 ) + infos=$( echo $infos | sed -e "s/\<$item\>//g" ) + done + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$infos") ) + elif [[ "$cur" == *,* ]]; then + COMPREPLY=( ${COMPREPLY[@]} $(compgen -P "${cur%,*}," -W "$infos" \ + -- "${cur##*,}") ) + else + COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$infos" -- "$cur") ) + fi + return 0 +} + +_lintian_arches() { + return 0 +} + +_lintian() { + local cur prev action lint_actions general_opts behaviour_opts \ + configuration_opts selection_opts + + _get_comp_words_by_ref cur prev + + lint_actions="--setup-lab --remove-lab --check --check-part --tags \ + --tags-from-file --ftp-master-rejects --dont-check-part \ + --unpack --remove" + general_opts="--help --version --print-version --verbose --debug --quiet" + behaviour_opts="--info --display-info --display-experimental --pedantic \ + --display-level --suppress-tags --unpack-level \ + --suppress-tags-from-file --no-override --show-overrides \ + --color --unpack-info --md5sums --checksums --allow-root \ + --fail-on-warnings --keep-lab" + configuration_opts="--cfg --lab --archivedir --dist --area --section \ + --arch --root" + selection_opts="--all --binary --source --udeb --packages-file" + + if [[ "$prev" = -* ]]; then + case $prev in + -C|--check-part|-X|--dont-check-part) + _lintian_checks + ;; + -T|--tags|--suppress-tags) + _lintian_tags + ;; + --tags-from-file|--suppress-tags-from-file|--cfg|-p|\ + --packages-file) + _filedir + ;; + --lab|--archivedir|--dist|--root) + _filedir -d + ;; + -l|--unpack-level) + COMPREPLY=($(compgen -W "0 none 1 basic 2 contents" -- \ + "$cur")) + ;; + --color) + COMPREPLY=($(compgen -W "never always auto html" -- "$cur")) + ;; + -U|--unpack-info) + _lintian_infos + ;; + --area|--section) + COMPREPLY=($(compgen -W "main contrib non-free" -- "$cur")) + ;; + --arch) + ;; + esac + fi + + case "$cur" in + --*) + COMPREPLY=($(compgen -W "$lint_actions $general_opts \ + $behaviour_opts $configuration_opts" -- "$cur")) + ;; + *,) + # If we're here, the user is trying to complete on + # --action tag,tag, + # Only few actions permit that, re-complete them now. + echo $prev + case "$prev" in + -C|--check-part|-X|--dont-check-part) + _lintian_checks + ;; + -T|--tags|--suppress-tags) + _lintian_tags + ;; + -U|--unpack-info) + _lintian_infos + ;; + esac + ;; + *) + _filedir '@(?(u)deb|changes|dsc)' + ;; + esac + return 0 +} + +_lintian_info() { + local cur prev + + _get_comp_words_by_ref cur prev + + case "$prev" in + -t|--tags) + _lintian_tags + return 0 + ;; + esac + + case "$cur" in + --*) + COMPREPLY=($(compgen -W "--annotate --help --tags" -- "$cur")) + ;; + *) + _filedir + ;; + esac + return 0 +} + +complete -F _lintian -o filenames lintian +complete -F _lintian_info -o filenames lintian-info +} diff --git a/contrib/lisp b/contrib/lisp index a88db35a..ee43a019 100644 --- a/contrib/lisp +++ b/contrib/lisp @@ -7,7 +7,7 @@ _lisp() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur # completing an option (may or may not be separated by a space) if [[ "$cur" == -* ]]; then diff --git a/contrib/lrzip b/contrib/lrzip new file mode 100644 index 00000000..e5848035 --- /dev/null +++ b/contrib/lrzip @@ -0,0 +1,63 @@ +# lrzip(1) completion + +have lrzip && +_lrzip() +{ + COMPREPLY=() + local cur prev + _get_comp_words_by_ref cur prev + + if [[ "$cur" == -* && $prev != -N ]]; then + COMPREPLY=( $( compgen -W '-w -d -o -O -S -f -D -q -L -n -l -b -g -M \ + -T -N -v -vv -V -h' -- "$cur" ) ) + return 0 + fi + + local xspec="*.lrz" + + case $prev in + -w|-S|-V|-h) + return 0 + ;; + -d) + xspec="!"$xspec + ;; + -o) + _filedir + return 0 + ;; + -O) + _filedir -d + return 0 + ;; + -L) + COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9' -- "$cur" ) ) + return 0 + ;; + -T) + COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9 10' -- "$cur" ) ) + return 0 + ;; + -N) + COMPREPLY=( $( compgen -W '-20 -19 -18 -17 -16 -15 -14 -13 -12 \ + -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 \ + 12 13 14 15 16 17 18 19' -- "$cur" ) ) + return 0 + ;; + esac + + _expand || return 0 + + local IFS=$'\t\n' + COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ + $( compgen -d -- "$cur" ) ) +} && +complete -F _lrzip -o filenames lrzip + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/contrib/lvm b/contrib/lvm index 63284cf3..f4d3b77d 100644 --- a/contrib/lvm +++ b/contrib/lvm @@ -49,7 +49,7 @@ _lvmdiskscan() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--debug --help \ @@ -63,7 +63,7 @@ _pvscan() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--debug --exported --novolumegroup \ @@ -78,8 +78,7 @@ _pvs() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -o|-O|--options|--sort) @@ -111,8 +110,7 @@ _pvdisplay() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --units) @@ -135,8 +133,7 @@ _pvchange() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|-x|--autobackup|--allocatable) @@ -161,8 +158,7 @@ _pvcreate() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --restorefile) @@ -200,8 +196,7 @@ _pvmove() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -228,7 +223,7 @@ _pvremove() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--debug --force \ @@ -244,7 +239,7 @@ _vgscan() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--debug --help \ @@ -259,8 +254,7 @@ _vgs() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -o|-O|--options|--sort) @@ -294,8 +288,7 @@ _vgdisplay() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --units) @@ -319,8 +312,7 @@ _vgchange() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -a|-A|-x|--available|--autobackup|--resizeable) @@ -346,8 +338,7 @@ _vgcreate() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -385,7 +376,7 @@ _vgremove() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--debug --help --test \ @@ -401,8 +392,7 @@ _vgrename() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -425,8 +415,7 @@ _vgreduce() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -456,8 +445,7 @@ _vgextend() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -489,7 +477,7 @@ _vgport() local cur prev COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--all --debug \ @@ -502,10 +490,10 @@ complete -F _vgport vgimport vgexport _vgck() { - local cur prev + local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--debug \ @@ -521,8 +509,7 @@ _vgconvert() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -M|--metadatatype) @@ -554,8 +541,7 @@ _vgcfgbackup() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -f|--file) @@ -579,8 +565,7 @@ _vgcfgrestore() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -f|--file) @@ -612,8 +597,7 @@ _vgmerge() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -636,8 +620,7 @@ _vgsplit() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -670,7 +653,7 @@ _vgmknodes() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--debug --help --verbose \ @@ -686,7 +669,7 @@ _lvscan() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--blockdevice --debug \ @@ -701,8 +684,7 @@ _lvs() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -o|-O|--options|--sort) @@ -733,8 +715,7 @@ _lvdisplay() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --units) @@ -757,8 +738,7 @@ _lvchange() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -a|-A|-C|-M|--available|--autobackup|--continguous|--persistent) @@ -789,8 +769,7 @@ _lvcreate() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|-C|-M|-Z|--autobackup|--continguous|--persistent|--zero) @@ -834,8 +813,7 @@ _lvremove() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -858,8 +836,7 @@ _lvrename() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -882,8 +859,7 @@ _lvreduce() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -911,8 +887,7 @@ _lvresize() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -946,8 +921,7 @@ _lvextend() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -A|--autobackup) @@ -981,7 +955,7 @@ _lvm() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -W 'dumpconfig help lvchange \ diff --git a/contrib/lzma b/contrib/lzma index e015ef8e..a176f191 100644 --- a/contrib/lzma +++ b/contrib/lzma @@ -6,8 +6,7 @@ _lzma() local cur prev xspec COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -9 \ diff --git a/contrib/lzop b/contrib/lzop index 21b085f7..19852b24 100644 --- a/contrib/lzop +++ b/contrib/lzop @@ -6,8 +6,7 @@ _lzop() local cur prev xspec COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -9 -P \ diff --git a/contrib/mailman b/contrib/mailman index 7af891d9..33227897 100644 --- a/contrib/mailman +++ b/contrib/mailman @@ -11,7 +11,7 @@ _list_lists() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--advertised --virtual-host-overview \ @@ -28,8 +28,7 @@ _add_members() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -63,8 +62,7 @@ _remove_members() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -93,8 +91,7 @@ _find_member() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -121,8 +118,7 @@ _clone_member() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -149,8 +145,7 @@ _sync_members() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -183,7 +178,7 @@ _unshunt() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help' -- "$cur" ) ) @@ -200,7 +195,7 @@ _list_admins() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--all-vhost --all --help' -- "$cur" ) ) @@ -217,7 +212,7 @@ _list_owners() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--with-listnames --moderators \ @@ -235,8 +230,7 @@ _list_members() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -274,8 +268,7 @@ _change_pw() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -302,7 +295,7 @@ _withlist() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--lock --interactive \ @@ -320,7 +313,7 @@ _newlist() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--language --quiet --help' -- "$cur" ) ) @@ -337,7 +330,7 @@ _rmlist() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--archives --help' -- "$cur" ) ) @@ -354,8 +347,7 @@ _config_list() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -386,8 +378,7 @@ _arch() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -433,7 +424,7 @@ _cleanarch() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--status --dry-run --quiet \ @@ -449,8 +440,7 @@ _inject() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -478,7 +468,7 @@ _dumpdb() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--marshal --pickle --noprint \ @@ -496,7 +486,7 @@ _check_db() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--all --verbose --help' -- "$cur" ) ) @@ -513,7 +503,7 @@ _check_perms() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-f -v -h' -- "$cur" ) ) @@ -528,7 +518,7 @@ _genaliases() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--quiet --help' -- "$cur" ) ) @@ -543,7 +533,7 @@ _mmsitepass() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--listcreator --help' -- "$cur" ) ) @@ -558,8 +548,7 @@ _qrunner() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && return 0 @@ -577,7 +566,7 @@ _mailmanctl() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--no-restart --run-as-user \ diff --git a/contrib/make b/contrib/make index 79f373fe..e792b348 100644 --- a/contrib/make +++ b/contrib/make @@ -6,8 +6,7 @@ _make() local file makef makef_dir="." makef_inc cur prev i split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/man b/contrib/man index c1da66aa..a3360b2e 100644 --- a/contrib/man +++ b/contrib/man @@ -11,8 +11,7 @@ _man() mansect="@([0-9lnp]|[0-9][px]|3pm)" COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev if [[ "$prev" == -l ]]; then _filedir $manext diff --git a/contrib/mc b/contrib/mc index c41c42a1..910fef13 100644 --- a/contrib/mc +++ b/contrib/mc @@ -6,8 +6,7 @@ _mc() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/mcrypt b/contrib/mcrypt index 5f9474c7..e777150f 100644 --- a/contrib/mcrypt +++ b/contrib/mcrypt @@ -6,8 +6,7 @@ _mcrypt() local cur prev i decrypt COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -g|--openpgp-z) diff --git a/contrib/mdadm b/contrib/mdadm index 425a6c01..9cbaad7b 100644 --- a/contrib/mdadm +++ b/contrib/mdadm @@ -75,8 +75,7 @@ _mdadm() local cur prev mode options split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/minicom b/contrib/minicom index b2ffcb07..76553317 100644 --- a/contrib/minicom +++ b/contrib/minicom @@ -6,8 +6,7 @@ _minicom() local cur prev confdir COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -a|-c) diff --git a/contrib/mkinitrd b/contrib/mkinitrd index 0ac6f434..48893471 100644 --- a/contrib/mkinitrd +++ b/contrib/mkinitrd @@ -6,8 +6,7 @@ _mkinitrd() local cur prev args split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/module-init-tools b/contrib/module-init-tools index 5a8994e8..8c0f13ea 100644 --- a/contrib/module-init-tools +++ b/contrib/module-init-tools @@ -9,7 +9,7 @@ _rmmod() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur _installed_modules "$cur" return 0 @@ -26,8 +26,7 @@ _insmod() local cur prev modpath COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev # behave like lsmod for modprobe -r if [[ ${1##*/} == modprobe && "${COMP_WORDS[1]}" == -r ]]; then diff --git a/contrib/monodevelop b/contrib/monodevelop index 29bf0cad..1aa117b0 100644 --- a/contrib/monodevelop +++ b/contrib/monodevelop @@ -4,7 +4,7 @@ have monodevelop && _monodevelop() { local cur - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-? -help -help2 -ipc-tcp -newwindow -nologo \ @@ -23,8 +23,7 @@ _mdtool() COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do if [[ ${COMP_WORDS[i]} == @(build|generate-makefiles|setup) ]]; then diff --git a/contrib/mount b/contrib/mount index a22b0788..b14eef3e 100644 --- a/contrib/mount +++ b/contrib/mount @@ -80,8 +80,7 @@ _mount() local cur sm host prev COMPREPLY=() - cur=`_get_cword ':'` - prev=`_get_pword ':'` + _get_comp_words_by_ref -n : cur prev case $prev in -t|--types) @@ -138,10 +137,10 @@ complete -F _mount -o default -o dirnames mount have umount && _umount() { + local cur + _get_comp_words_by_ref cur COMPREPLY=() - local cur=`_get_cword` - if [[ $(uname -s) = Linux && -r /proc/mounts ]]; then # Linux /proc/mounts is properly quoted. This is important when # unmounting usb devices with pretty names. diff --git a/contrib/mplayer b/contrib/mplayer index 119023eb..2786b7ad 100644 --- a/contrib/mplayer +++ b/contrib/mplayer @@ -15,8 +15,7 @@ _mplayer() COMPREPLY=() cmd=${COMP_WORDS[0]} - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -[av][cfo]|-[av]fm|-vop|-fstype|-demuxer|-o[av]c|-of|-profile) @@ -237,7 +236,7 @@ _mplayer() -e "/^-\(Total\|.*\*\)\{0,1\}$/!p" )' -- "$cur" ) ) ;; *) - _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|fl[iv]|FL[IV]|fxm|FXM|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m4[av]|M4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m[24]v|M[24]V|dv|DV|rmvb|RMVB|mid|MID|ts|TS|3g[p2]|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2ts|M2TS|vdr|VDR|xvid|XVID|ape|APE)' + _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|fl[iv]|FL[IV]|fxm|FXM|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m4[av]|M4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m[24]v|M[24]V|dv|DV|rmvb|RMVB|mid|MID|t[ps]|T[PS]|3g[p2]|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2ts|M2TS|vdr|VDR|xvid|XVID|ape|APE|gif|GIF)' ;; esac diff --git a/contrib/msynctool b/contrib/msynctool index 0ab178ec..3f9afb7f 100644 --- a/contrib/msynctool +++ b/contrib/msynctool @@ -6,11 +6,7 @@ _msynctool() local cur prev anteprev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} - if [ $COMP_CWORD -ge 2 ]; then - anteprev=${COMP_WORDS[COMP_CWORD-2]} - fi + _get_comp_words_by_ref cur prev anteprev case $anteprev in --configure) diff --git a/contrib/mtx b/contrib/mtx index 4b20ba70..0454f032 100644 --- a/contrib/mtx +++ b/contrib/mtx @@ -6,8 +6,7 @@ _mtx() local cur prev options tapes drives COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev options="-f nobarcode invert noattach --version inquiry noattach \ inventory status load unload eepos first last next" diff --git a/contrib/munin-node b/contrib/munin-node index 405ece7f..abf2b0f6 100644 --- a/contrib/munin-node +++ b/contrib/munin-node @@ -6,8 +6,7 @@ _munin_run() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=`_get_pword` + _get_comp_words_by_ref cur prev case $prev in --config|--sconffile) @@ -36,8 +35,7 @@ _munindoc() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=`_get_pword` + _get_comp_words_by_ref cur prev COMPREPLY=( $( compgen -W '$( command ls /usr/share/munin/plugins )' \ -- "$cur" ) ) @@ -50,8 +48,7 @@ _munin_update() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=`_get_pword` + _get_comp_words_by_ref cur prev case $prev in --config) @@ -78,8 +75,7 @@ _munin_node_configure() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=`_get_pword` + _get_comp_words_by_ref cur prev case $prev in --config) diff --git a/contrib/mutt b/contrib/mutt index 8d1d86b5..f86e6759 100644 --- a/contrib/mutt +++ b/contrib/mutt @@ -58,7 +58,7 @@ _muttconffiles() while [[ "$1" ]]; do newconffiles=( $(sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval echo $1) ) ) for file in "${newconffiles[@]}"; do - [[ ! "$file" ]] || [[ "${sofar/ ${file} / }" != "$sofar" ]] && + [[ ! "$file" || "${sofar/ ${file} / }" != "$sofar" ]] && continue sofar="$sofar $file" sofar=" $(eval _muttconffiles \"$sofar\" $file) " @@ -137,8 +137,9 @@ _muttfiledir() _mutt() { local cur prev - cur=`_get_cword =+!` - prev=`_get_pword =+!` + _get_comp_words_by_ref -n =+! cur prev + #cur=`_get_cword =+!` + #prev=`_get_pword =+!` COMPREPLY=() diff --git a/contrib/mysqladmin b/contrib/mysqladmin index 247fa7d1..a7e002d3 100644 --- a/contrib/mysqladmin +++ b/contrib/mysqladmin @@ -6,8 +6,7 @@ _mysqladmin() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/ncftp b/contrib/ncftp index ba003aaf..b831f444 100644 --- a/contrib/ncftp +++ b/contrib/ncftp @@ -6,7 +6,7 @@ _ncftp() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ $COMP_CWORD -eq 1 && -f ~/.ncftp/bookmarks ]]; then COMPREPLY=( $( compgen -W '$( sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \ diff --git a/contrib/net-tools b/contrib/net-tools index 15e39782..5b86a64a 100644 --- a/contrib/net-tools +++ b/contrib/net-tools @@ -6,8 +6,7 @@ _mii_tool() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -41,8 +40,7 @@ _mii_diag() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -76,8 +74,7 @@ _route() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev if [ "$prev" = dev ]; then _available_interfaces diff --git a/contrib/ntpdate b/contrib/ntpdate index 233f69f1..bf004b55 100644 --- a/contrib/ntpdate +++ b/contrib/ntpdate @@ -6,8 +6,7 @@ _ntpdate() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -k) diff --git a/contrib/openldap b/contrib/openldap index 4231bbb7..e4bbba1f 100644 --- a/contrib/openldap +++ b/contrib/openldap @@ -16,8 +16,7 @@ _ldapsearch() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -h) @@ -64,8 +63,7 @@ _ldapaddmodify() local cur prev options COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -h) @@ -102,8 +100,7 @@ _ldapdelete() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -h) @@ -136,8 +133,7 @@ _ldapcompare() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -h) @@ -170,8 +166,7 @@ _ldapmodrdn() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -h) @@ -204,8 +199,7 @@ _ldapwhoami() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -h) @@ -238,8 +232,7 @@ _ldappasswd() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -h) diff --git a/contrib/openssl b/contrib/openssl index 2db79de2..568f2dbf 100644 --- a/contrib/openssl +++ b/contrib/openssl @@ -32,7 +32,7 @@ _openssl() local cur prev commands command options formats COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur prev commands='asn1parse ca ciphers crl crl2pkcs7 dgst dh dhparam dsa \ dsaparam ec ecparam enc engine errstr gendh gendsa genrsa \ @@ -53,7 +53,6 @@ _openssl() COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) else command=${COMP_WORDS[1]} - prev=${COMP_WORDS[COMP_CWORD-1]} case $prev in -CA|-CAfile|-CAkey|-CAserial|-cert|-certfile|-config|-content| \ -dcert|-dkey|-dhparam|-extfile|-in|-inkey|-kfile|-key|-keyout| \ diff --git a/contrib/p4 b/contrib/p4 index 4f5c66bb..0795a28e 100644 --- a/contrib/p4 +++ b/contrib/p4 @@ -6,8 +6,7 @@ _p4() local cur prev preprev p4commands p4filetypes COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev preprev # rename isn't really a command p4commands="$( p4 help commands | awk 'NF>3 {print $1}' )" @@ -31,7 +30,6 @@ _p4() ;; esac elif [ $COMP_CWORD -gt 2 ]; then - preprev=${COMP_WORDS[COMP_CWORD-2]} case $prev in -t) case $preprev in diff --git a/contrib/perl b/contrib/perl index af85d8f6..67996f94 100644 --- a/contrib/perl +++ b/contrib/perl @@ -14,8 +14,7 @@ _perl() local optPrefix optSuffix COMPREPLY=() - cur=`_get_cword :` - prev=`_get_pword :` + _get_comp_words_by_ref -n : cur prev prefix="" # If option not followed by whitespace, reassign prev and cur @@ -55,8 +54,7 @@ _perldoc() local cur prev prefix temp COMPREPLY=() - cur=`_get_cword :` - prev=`_get_pword :` + _get_comp_words_by_ref -n : cur prev prefix="" # completing an option (may or may not be separated by a space) diff --git a/contrib/pine b/contrib/pine index 7335635d..2f069287 100644 --- a/contrib/pine +++ b/contrib/pine @@ -6,7 +6,7 @@ _pineaddr() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur COMPREPLY=( $( compgen -W '$( awk "{print \$1}" ~/.addressbook \ 2>/dev/null)' -- "$cur" ) ) diff --git a/contrib/pkg-config b/contrib/pkg-config index 78729604..b999bd81 100644 --- a/contrib/pkg-config +++ b/contrib/pkg-config @@ -6,8 +6,7 @@ _pkg_config() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/pkg_install b/contrib/pkg_install index 562596cd..577d9c94 100644 --- a/contrib/pkg_install +++ b/contrib/pkg_install @@ -8,8 +8,7 @@ _pkg_delete() local cur pkgdir prev pkgdir=${PKG_DBDIR:-/var/db/pkg}/ - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev [[ "$prev" == -o || "$prev" == -p || "$prev" == -W ]] && return 0 diff --git a/contrib/pm-utils b/contrib/pm-utils index 85d4f21c..4deb82e7 100644 --- a/contrib/pm-utils +++ b/contrib/pm-utils @@ -3,7 +3,8 @@ have pm-is-supported && _pm_is_supported() { - local cur=`_get_cword` + local cur + _get_comp_words_by_ref cur COMPREPLY=( $( compgen -W '--help --suspend --hibernate --suspend-hybrid' \ -- "$cur" ) ) } && @@ -12,7 +13,8 @@ complete -F _pm_is_supported pm-is-supported have pm-hibernate || have pm-suspend || have pm-suspend-hybrid && _pm_action() { - local cur=`_get_cword` + local cur + _get_comp_words_by_ref cur COMPREPLY=( $( compgen -W "--help $( _parse_help "$1" )" -- "$cur" ) ) } && complete -F _pm_action pm-hibernate pm-suspend pm-suspend-hybrid @@ -20,7 +22,8 @@ complete -F _pm_action pm-hibernate pm-suspend pm-suspend-hybrid have pm-powersave && _pm_powersave() { - local cur=`_get_cword` + local cur + _get_comp_words_by_ref cur COMPREPLY=( $( compgen -W "true false" -- "$cur" ) ) } && complete -F _pm_powersave pm-powersave diff --git a/contrib/portupgrade b/contrib/portupgrade index d66fca90..5389a5ca 100644 --- a/contrib/portupgrade +++ b/contrib/portupgrade @@ -6,8 +6,7 @@ _portupgrade() local cur pkgdir prev pkgdir=${PKG_DBDIR:-/var/db/pkg}/ - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0 @@ -26,8 +25,7 @@ _portinstall() local -a COMPREPLY2 portsdir=${PORTSDIR:-/usr/ports}/ - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev # First try INDEX-5 indexfile=$portsdir/INDEX-5 # Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x diff --git a/contrib/postfix b/contrib/postfix index 2a650511..ec91c1a3 100644 --- a/contrib/postfix +++ b/contrib/postfix @@ -8,8 +8,7 @@ _postfix() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -c) @@ -39,8 +38,7 @@ _postmap() local cur prev len idx COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -c) @@ -84,8 +82,7 @@ _postcat() local cur prev pval len idx qfile COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -c) @@ -128,8 +125,7 @@ _postconf() local cur prev pval len idx eqext COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -b|-t) @@ -171,8 +167,7 @@ _postsuper() local cur prev pval len idx COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -c) diff --git a/contrib/postgresql b/contrib/postgresql index 57b4c2df..392c9aa6 100644 --- a/contrib/postgresql +++ b/contrib/postgresql @@ -25,8 +25,7 @@ _createdb() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -68,8 +67,7 @@ _dropdb() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -106,8 +104,7 @@ _psql() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/povray b/contrib/povray index b98c0819..cd03b940 100644 --- a/contrib/povray +++ b/contrib/povray @@ -7,8 +7,7 @@ _povray() defoext=png # default output extension, if cannot be determined FIXME COMPREPLY=() - povcur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref povcur prev _expand || return 0 diff --git a/contrib/procps b/contrib/procps new file mode 100644 index 00000000..db8fc3d5 --- /dev/null +++ b/contrib/procps @@ -0,0 +1,49 @@ +# Completions for tools included in procps and related + +# killall(1) (Linux and FreeBSD) and pkill(1) completion. +# +[[ $UNAME == Linux || $UNAME == FreeBSD ]] || have pkill && +_killall() +{ + local cur + + COMPREPLY=() + _get_comp_words_by_ref cur + + if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then + _signals + else + _pnames + fi + + return 0 +} +[[ $UNAME == Linux || $UNAME == FreeBSD ]] && complete -F _killall killall +have pkill && complete -F _killall pkill + +# pgrep(1) completion. +# +[ $UNAME = Linux ] || have pgrep && +_pgrep() +{ + local cur + + COMPREPLY=() + _get_comp_words_by_ref cur + + _pnames + + return 0 +} +have pgrep && complete -F _pgrep pgrep + +# Linux pidof(8) completion. +[ $UNAME = Linux ] && complete -F _pgrep pidof + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/contrib/python b/contrib/python index 3d28f98c..9d8fcc9d 100644 --- a/contrib/python +++ b/contrib/python @@ -6,8 +6,7 @@ _python() local prev cur i COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]##*/} + _get_comp_words_by_ref cur prev case $prev in -Q) diff --git a/contrib/qdbus b/contrib/qdbus index e153a761..879df68d 100644 --- a/contrib/qdbus +++ b/contrib/qdbus @@ -6,7 +6,8 @@ _qdbus() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur + [ -n "$cur" ] && unset COMP_WORDS[${#COMP_WORDS[@]}-1] COMPREPLY=( $( compgen -W '$( command ${COMP_WORDS[@]} 2>/dev/null | \ sed s/\(.*\)// )' -- "$cur" ) ) diff --git a/contrib/qemu b/contrib/qemu index 4910bd95..1c7a8da0 100644 --- a/contrib/qemu +++ b/contrib/qemu @@ -6,8 +6,7 @@ _qemu() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -fd[ab]|-hd[abcd]|-cdrom|-option-rom|-kernel|-initrd|-bootp|-pidfile| \ diff --git a/contrib/quota-tools b/contrib/quota-tools index 77dbe531..2b528d92 100644 --- a/contrib/quota-tools +++ b/contrib/quota-tools @@ -35,8 +35,7 @@ _quota() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -65,8 +64,7 @@ _setquota() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -105,8 +103,7 @@ _edquota() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -138,8 +135,7 @@ _quotacheck() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -168,8 +164,7 @@ _repquota() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -198,8 +193,7 @@ _quotaon() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -226,8 +220,7 @@ _quotaoff() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/rcs b/contrib/rcs index 36ebaa5a..42ac8d5a 100644 --- a/contrib/rcs +++ b/contrib/rcs @@ -6,8 +6,7 @@ _rcs() local cur prev file dir i COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev file=${cur##*/} dir=${cur%/*} diff --git a/contrib/rdesktop b/contrib/rdesktop index 799d5459..7acf47a5 100644 --- a/contrib/rdesktop +++ b/contrib/rdesktop @@ -6,8 +6,7 @@ _rdesktop() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -k) diff --git a/contrib/reportbug b/contrib/reportbug index 1e5b4d5d..51e37fb7 100644 --- a/contrib/reportbug +++ b/contrib/reportbug @@ -6,8 +6,7 @@ _reportbug() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -f|--filename|-i|--include|--mta|-o|--output) @@ -42,7 +41,7 @@ _reportbug() COMPREPLY=( $( compgen -W "gnats debbugs" -- "$cur" ) ) return 0 ;; - -T|--tags) + -T|--tag) COMPREPLY=( $( compgen -W "none \ woody potato sarge sarge-ignore etch etch-ignore \ lenny lenny-ignore sid experimental confirmed \ @@ -51,23 +50,30 @@ _reportbug() unreproducible upstream wontfix ipv6 lfs" -- "$cur" )) return 0 ;; + --from-buildd) + COMPREPLY=( $( compgen -S "_" -W '$( apt-cache dumpavail | \ + command grep "^Source: $cur" | sort -u | cut -f2 -d" " )' )) + return 0 + ;; *) ;; esac - COMPREPLY=($( compgen -W '-h --help -v --version -a --af -b \ - --no-query-bts --query-bts -B --bts -c --configure \ - --no-config-files --check-available -d --debug \ - --no-check-available -e --editor --email -f \ - --filename -g --gnupg -H --header -i --include -j \ - --justification -l --ldap --no-ldap -L --list-cc -m \ - --maintonly --mode --mua --mta --mutt -n --mh --nmh \ - -o --output -p --print -P --pgp --proxy --http_proxy\ - -q --quiet -Q --query-only --realname --report-quiet \ - --reply-to --replyto -s --subject -S --severity \ - --smtphost -t --type -T --tags --template -V -x \ - --no-cc --package-version -z --no-compress \ - --ui --interface -u \ + COMPREPLY=($( compgen -W '--help --version --attach \ + --no-query-bts --query-bts --bts --body --body-file --bodyfile \ + --no-config-files --class --configure --check-available --debug \ + --no-check-available --debconf --test --draftpath --editor --email \ + --exit-prompt --filename --from-buildd --gnupg --gpg --path --gnus \ + --header --include --no-check-installed --check-installed \ + --justification --kudos --keyid --license --list-cc \ + --maintonly --mirror --mode --mua --mta --mutt --mh --nmh \ + --bugnumber --no-bug-script --no-cc-menu --output --offline \ + --print --paranoid --no-paranoid --pgp --proxy --http_proxy \ + --pseudo-header --quiet --query-only --query-source --no-query-source \ + --realname --report-quiet --reply-to --replyto --subject --severity \ + --smtphost --timeout --tls --smtpuser --smtppasswd --src --source --type \ + --tag --template --verify --no-verify --no-cc --package-version \ + --no-compress --ui --interface \ wnpp boot-floppies kernel bugs.debian.org \ cdimage.debian.org general installation-reports \ listarchives lists.debian.org mirrors nm.debian.org \ @@ -86,8 +92,7 @@ _querybts() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/resolvconf b/contrib/resolvconf index 92c2da41..9773696d 100644 --- a/contrib/resolvconf +++ b/contrib/resolvconf @@ -6,8 +6,7 @@ _resolvconf() local cur command COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -a|-d) diff --git a/contrib/rfkill b/contrib/rfkill index ec331e0d..5c51ff9d 100644 --- a/contrib/rfkill +++ b/contrib/rfkill @@ -6,7 +6,7 @@ _rfkill() local cur prev COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur prev if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--version' -- "$cur" ) ) @@ -17,7 +17,6 @@ _rfkill() -- "$cur" ) ) ;; 2) - prev=${COMP_WORDS[COMP_CWORD-1]} if [[ $prev == block || $prev == unblock ]]; then COMPREPLY=( $( compgen -W "$(rfkill list | awk -F: \ '/^[0-9]/ {print $1}') all wifi bluetooth uwb wimax \ diff --git a/contrib/ri b/contrib/ri index 5d2b7b5e..be66d98f 100644 --- a/contrib/ri +++ b/contrib/ri @@ -38,7 +38,7 @@ _ri() local -a classes COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur ri_path=$(type -p ri) # which version of ri are we using? diff --git a/contrib/rpcdebug b/contrib/rpcdebug index 525ab7d7..be2a8709 100644 --- a/contrib/rpcdebug +++ b/contrib/rpcdebug @@ -24,8 +24,7 @@ _rpcdebug() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -s) diff --git a/contrib/rpm b/contrib/rpm index ca5fe311..20f98522 100644 --- a/contrib/rpm +++ b/contrib/rpm @@ -55,8 +55,7 @@ _rpm() local cur prev opts nodig nosig COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev nodig="" nosig="" _rpm_nodigsig diff --git a/contrib/rpmcheck b/contrib/rpmcheck index 49240fd1..5d9aada7 100644 --- a/contrib/rpmcheck +++ b/contrib/rpmcheck @@ -6,8 +6,7 @@ _rpmcheck() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -base) diff --git a/contrib/rrdtool b/contrib/rrdtool index 891df683..0b15a23f 100644 --- a/contrib/rrdtool +++ b/contrib/rrdtool @@ -3,7 +3,9 @@ have rrdtool && _rrdtool () { - cur=`_get_cword` + local cur + _get_comp_words_by_ref cur + COMPREPLY=( $( compgen -W 'create update updatev graph dump restore last \ lastupdate first info fetch tune resize xport' -- "$cur" ) ) } && diff --git a/contrib/rsync b/contrib/rsync index 31324e53..b0f2d106 100644 --- a/contrib/rsync +++ b/contrib/rsync @@ -6,8 +6,8 @@ _rsync() # TODO: _split_longopt COMPREPLY=() - local cur=`_get_cword :` - local prev=`_get_pword :` + local cur prev + _get_comp_words_by_ref -n : cur prev _expand || return 0 diff --git a/contrib/rtcwake b/contrib/rtcwake index 0169fb61..c95c1d76 100644 --- a/contrib/rtcwake +++ b/contrib/rtcwake @@ -4,7 +4,8 @@ have rtcwake && _rtcwake() { COMPREPLY=() - local cur=`_get_cword` prev=`_get_pword` split=false + local cur prev split=false + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/samba b/contrib/samba index 9c7651f2..61d78abc 100644 --- a/contrib/samba +++ b/contrib/samba @@ -32,8 +32,7 @@ _smbclient() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -99,8 +98,7 @@ _smbget() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -132,8 +130,7 @@ _smbcacls() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -166,8 +163,7 @@ _smbcquotas() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -201,8 +197,7 @@ _smbpasswd() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -r) @@ -235,8 +230,7 @@ _smbtar() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -r|-t) @@ -265,8 +259,7 @@ _smbtree() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/sbcl b/contrib/sbcl index 5dfc6723..a43ec1fc 100644 --- a/contrib/sbcl +++ b/contrib/sbcl @@ -7,7 +7,7 @@ _sbcl() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur # completing an option (may or may not be separated by a space) if [[ "$cur" == -* ]]; then diff --git a/contrib/screen b/contrib/screen index faed765a..cabc4b7a 100644 --- a/contrib/screen +++ b/contrib/screen @@ -16,20 +16,19 @@ _screen_sessions() } && _screen() { - local cur prev preprev + local cur prev words cword COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev words cword - [ "$COMP_CWORD" -ge 2 ] && preprev=${COMP_WORDS[COMP_CWORD-2]} - - case $preprev in - -[dD]) - _screen_sessions - return 0 - ;; - esac + if ((cword > 2)); then + case ${words[cword-2]} in + -[dD]) + _screen_sessions + return 0 + ;; + esac + fi case $prev in -[rR]) diff --git a/contrib/service b/contrib/service new file mode 100644 index 00000000..ffd24366 --- /dev/null +++ b/contrib/service @@ -0,0 +1,47 @@ +# service(8) and /etc/init.d/* completion + +# This completes on a list of all available service scripts for the +# 'service' command and/or the SysV init.d directory, followed by +# that script's available commands +# +{ have service || [ -d /etc/init.d/ ]; } && +_service() +{ + local cur prev sysvdir + + COMPREPLY=() + _get_comp_words_by_ref cur prev + + # don't complete for things like killall, ssh and mysql if it's + # the standalone command, rather than the init script + [[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|service) ]] && return 0 + + # don't complete past 2nd token + [ $COMP_CWORD -gt 2 ] && return 0 + + [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d + + if [[ $COMP_CWORD -eq 1 && $prev == "service" ]]; then + _services + else + COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \ + -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \ + $sysvdir/${prev##*/} 2>/dev/null`' -- "$cur" ) ) + fi + + return 0 +} && +complete -F _service service +for svc in /etc/init.d/*; do + [ ! -x "$svc" ] || complete -p "${svc##*/}" &>/dev/null || \ + complete -F _service -o default "${svc##*/}" +done +unset svc + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/contrib/shadow b/contrib/shadow index 3e19e638..a3451b7b 100644 --- a/contrib/shadow +++ b/contrib/shadow @@ -6,8 +6,7 @@ _useradd() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -57,8 +56,7 @@ _usermod() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -106,7 +104,7 @@ _userdel() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--force --help --remove' -- "$cur" ) ) @@ -123,8 +121,7 @@ _chage() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -152,8 +149,7 @@ _passwd() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -n|-x|-w|-i|-\?|--help|--usage) @@ -177,8 +173,7 @@ _chpasswd() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -209,8 +204,7 @@ _newusers() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -243,7 +237,7 @@ _pwck() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-q -r -s' -- "$cur" ) ) @@ -260,8 +254,7 @@ _groupadd() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -290,8 +283,7 @@ _groupmod() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -334,8 +326,7 @@ _gpasswd() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -a|-d|-A|-M) @@ -359,8 +350,7 @@ _groupmems() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -a|-d) @@ -386,7 +376,7 @@ _grpck() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-r -s' -- "$cur" ) ) @@ -403,8 +393,7 @@ _vipw() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -h|--help) @@ -426,8 +415,7 @@ _faillog() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true @@ -457,8 +445,7 @@ _lastlog() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/sitecopy b/contrib/sitecopy index 1c980566..616bc5e4 100644 --- a/contrib/sitecopy +++ b/contrib/sitecopy @@ -8,7 +8,7 @@ _sitecopy() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur case $cur in --*) diff --git a/contrib/smartctl b/contrib/smartctl index 883b4ca6..74e42816 100644 --- a/contrib/smartctl +++ b/contrib/smartctl @@ -67,8 +67,7 @@ _smartctl() local cur prev split=false COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev _split_longopt && split=true diff --git a/contrib/snownews b/contrib/snownews index 4430ce81..9c99ed7c 100644 --- a/contrib/snownews +++ b/contrib/snownews @@ -6,7 +6,7 @@ _snownews() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then # return list of available options diff --git a/contrib/sqlite3 b/contrib/sqlite3 new file mode 100644 index 00000000..f02b2e09 --- /dev/null +++ b/contrib/sqlite3 @@ -0,0 +1,39 @@ +# sqlite3(1) completion + +have sqlite3 && +_sqlite3() +{ + COMPREPLY=() + local cur prev + _get_comp_words_by_ref cur prev + + local dbexts='@(sqlite?(3)|?(s?(3))db)' + + case $prev in + -help|-version|-separator|-nullvalue|*.$dbexts) + return 0 + ;; + -init) + _filedir + return 0 + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '-help -init -echo -header -noheader -bail + -interactive -batch -column -csv -html -line -list -separator + -nullvalue -version' -- "$cur" ) ) + return 0 + fi + + _filedir $dbexts +} && +complete -F _sqlite3 -o filenames sqlite3 + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/contrib/ssh b/contrib/ssh index 86f21295..b4bafdee 100644 --- a/contrib/ssh +++ b/contrib/ssh @@ -120,8 +120,9 @@ _ssh() local -a config COMPREPLY=() - cur=`_get_cword :` - prev=`_get_pword` + _get_comp_words_by_ref -n : cur prev + #cur=`_get_cword :` + #prev=`_get_pword` _ssh_suboption_check && return 0 @@ -198,8 +199,7 @@ _sftp() local cur prev configfile COMPREPLY=() - cur=`_get_cword` - prev=`_get_pword` + _get_comp_words_by_ref cur prev _ssh_suboption_check && return 0 @@ -316,8 +316,7 @@ _scp() local configfile cur prev prefix COMPREPLY=() - cur=`_get_cword ":"` - prev=`_get_pword ":"` + _get_comp_words_by_ref -n : cur prev _ssh_suboption_check && { COMPREPLY=( "${COMPREPLY[@]/%/ }" ) @@ -399,8 +398,7 @@ _ssh_copy_id() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=`_get_pword` + _get_comp_words_by_ref cur prev case $prev in -i) diff --git a/contrib/sshfs b/contrib/sshfs index 78bf11d2..d7945f88 100644 --- a/contrib/sshfs +++ b/contrib/sshfs @@ -6,7 +6,7 @@ _sshfs() local cur userhost path COMPREPLY=() - cur=`_get_cword ":"` + _get_comp_words_by_ref -n : cur _expand || return 0 diff --git a/contrib/strace b/contrib/strace index 4011303a..9b3e2676 100644 --- a/contrib/strace +++ b/contrib/strace @@ -27,8 +27,7 @@ _strace() else COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -e) diff --git a/contrib/svk b/contrib/svk index 06d86fd7..c809d2eb 100644 --- a/contrib/svk +++ b/contrib/svk @@ -6,7 +6,7 @@ _svk() local cur prev commands options command COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur prev commands='add admin annotate ann blame praise cat checkout co cleanup \ cmerge cm commit ci copy cp delete del remove rm depotmap \ @@ -23,8 +23,6 @@ _svk() COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) fi else - - prev=${COMP_WORDS[COMP_CWORD-1]} case $prev in -F|--file|--targets) _filedir diff --git a/contrib/sysctl b/contrib/sysctl index cd40c453..41cbd7ee 100644 --- a/contrib/sysctl +++ b/contrib/sysctl @@ -6,7 +6,7 @@ _sysctl() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur COMPREPLY=( $( compgen -W "$(sysctl -N -a 2>/dev/null)" -- "$cur" ) ) diff --git a/contrib/sysv-rc b/contrib/sysv-rc index c04c3182..735a4042 100644 --- a/contrib/sysv-rc +++ b/contrib/sysv-rc @@ -7,8 +7,7 @@ _update_rc_d() { local cur prev sysvdir services options valid_options - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \ || sysvdir=/etc/init.d @@ -72,8 +71,7 @@ _invoke_rc_d() { local cur prev sysvdir services options valid_options - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \ || sysvdir=/etc/init.d diff --git a/contrib/tar b/contrib/tar index 8f4fc540..400daa62 100644 --- a/contrib/tar +++ b/contrib/tar @@ -6,7 +6,7 @@ _tar() local cur ext regex tar untar COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -W 'c t x u r d A' -- "$cur" ) ) diff --git a/contrib/tcpdump b/contrib/tcpdump index 094897f8..259f13e0 100644 --- a/contrib/tcpdump +++ b/contrib/tcpdump @@ -6,8 +6,7 @@ _tcpdump() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -r|-w|-F) diff --git a/contrib/unace b/contrib/unace index 7d065c01..5ceb7646 100644 --- a/contrib/unace +++ b/contrib/unace @@ -6,8 +6,7 @@ _unace() local cur COMPREPLY=() - cur=`_get_cword` - + _get_comp_words_by_ref cur if [[ "$cur" == -* ]] ; then COMPREPLY=( $( compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur" ) ) diff --git a/contrib/unrar b/contrib/unrar index 278b6a7b..3fb24dbb 100644 --- a/contrib/unrar +++ b/contrib/unrar @@ -6,7 +6,7 @@ _unrar() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]] ; then COMPREPLY=( $( compgen -W '-ad -ap -av- -c- -cfg- -cl -cu \ diff --git a/contrib/update-alternatives b/contrib/update-alternatives index b04a5c5c..ebed294d 100644 --- a/contrib/update-alternatives +++ b/contrib/update-alternatives @@ -22,8 +22,7 @@ _update_alternatives() local cur prev mode args i COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --altdir|--admindir) diff --git a/contrib/util-linux b/contrib/util-linux new file mode 100644 index 00000000..8017ebb2 --- /dev/null +++ b/contrib/util-linux @@ -0,0 +1,76 @@ +# Completions for tools included in util-linux (not necessarily Linux specific) + +# renice(8) completion +# +have renice && +_renice() +{ + local command cur curopt i + + COMPREPLY=() + _get_comp_words_by_ref cur + command=$1 + + i=0 + # walk back through command line and find last option + while [[ $i -le $COMP_CWORD && ${#COMPREPLY[@]} -eq 0 ]]; do + curopt=${COMP_WORDS[COMP_CWORD-$i]} + case "$curopt" in + -u) + COMPREPLY=( $( compgen -u -- "$cur" ) ) + ;; + -g) + _pgids + ;; + -p|$command) + _pids + ;; + esac + i=$(( ++i )) + done +} && +complete -F _renice renice + +# kill(1) completion +# +have kill && +_kill() +{ + local cur + + COMPREPLY=() + _get_comp_words_by_ref cur + + if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then + # return list of available signals + _signals + else + # return list of available PIDs + _pids + fi +} && +complete -F _kill kill + +# look(1) completion +# +have look && +_look() +{ + local cur + + COMPREPLY=() + _get_comp_words_by_ref cur + + if [ $COMP_CWORD = 1 ]; then + COMPREPLY=( $( compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur" ) ) + fi +} && +complete -F _look -o default look + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/contrib/vncviewer b/contrib/vncviewer index 0701929e..296eb8af 100644 --- a/contrib/vncviewer +++ b/contrib/vncviewer @@ -23,8 +23,7 @@ _tightvncviewer() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -passwd) @@ -65,8 +64,7 @@ _xvnc4viewer() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev # Convert double dash to single dash case ${prev/#--/-} in diff --git a/contrib/vpnc b/contrib/vpnc index 3b1ac072..722fee3a 100644 --- a/contrib/vpnc +++ b/contrib/vpnc @@ -6,8 +6,7 @@ _vpnc() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --pfs) diff --git a/contrib/wireless-tools b/contrib/wireless-tools index 0f034e7e..56ba0db8 100644 --- a/contrib/wireless-tools +++ b/contrib/wireless-tools @@ -9,8 +9,7 @@ _iwconfig() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in mode) @@ -101,8 +100,7 @@ _iwlist() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev if [ $COMP_CWORD -eq 1 ]; then if [[ "$cur" == -* ]]; then @@ -125,7 +123,7 @@ _iwspy() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [ $COMP_CWORD -eq 1 ]; then if [[ "$cur" == -* ]]; then @@ -146,8 +144,7 @@ _iwpriv() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in roam) diff --git a/contrib/wodim b/contrib/wodim index ada800c6..5fa69a8b 100644 --- a/contrib/wodim +++ b/contrib/wodim @@ -6,8 +6,7 @@ _cdrecord() local cur prev i generic_options track_options track_mode COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev # foo=bar style option if [[ "$cur" == *=* ]]; then diff --git a/contrib/wtf b/contrib/wtf index 56d0d2e0..2b6c4d01 100644 --- a/contrib/wtf +++ b/contrib/wtf @@ -7,8 +7,7 @@ _wtf() local cur prev db COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev [ "$prev" = -f ] && _filedir && return 0 [[ "$cur" == -* ]] && COMPREPLY=( -f ) && return 0 diff --git a/contrib/wvdial b/contrib/wvdial index 10d9c2ca..101112ca 100644 --- a/contrib/wvdial +++ b/contrib/wvdial @@ -6,8 +6,7 @@ _wvdial() local cur prev config i IFS=$'\t\n' COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --config) diff --git a/contrib/xhost b/contrib/xhost index 84981d8a..cec4adcf 100644 --- a/contrib/xhost +++ b/contrib/xhost @@ -3,7 +3,8 @@ have xhost && _xhost () { - local cur=`_get_cword` + local cur + _get_comp_words_by_ref cur case $cur in +*) _known_hosts_real -p+ "${cur:1}" ;; diff --git a/contrib/xm b/contrib/xm index 9431bcee..4087a710 100644 --- a/contrib/xm +++ b/contrib/xm @@ -20,7 +20,7 @@ _xm() local cur prev command options COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur prev commands='console create new delete destroy domid domname dump-core \ list mem-max mem-set migrate pause reboot rename restore \ @@ -35,7 +35,6 @@ _xm() if [[ $COMP_CWORD -eq 1 ]] ; then COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) else - prev=${COMP_WORDS[COMP_CWORD-1]} if [[ "$cur" == *=* ]]; then prev=${cur/=*/} cur=${cur/*=/} diff --git a/contrib/xmllint b/contrib/xmllint index ef41596d..82feb4a3 100644 --- a/contrib/xmllint +++ b/contrib/xmllint @@ -6,8 +6,7 @@ _xmllint() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -o|--output) diff --git a/contrib/xmlwf b/contrib/xmlwf index 6d926fde..7109bcd3 100644 --- a/contrib/xmlwf +++ b/contrib/xmlwf @@ -6,8 +6,7 @@ _xmlwf() local cur prev COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in -d) diff --git a/contrib/xmms b/contrib/xmms index 4559c3c7..42c5402c 100644 --- a/contrib/xmms +++ b/contrib/xmms @@ -6,7 +6,7 @@ _xmms() local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-h --help -r --rew -p --play \ diff --git a/contrib/xrandr b/contrib/xrandr index 08c9e847..70de80f7 100644 --- a/contrib/xrandr +++ b/contrib/xrandr @@ -5,8 +5,7 @@ _xrandr() { local cur prev output modes COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + _get_comp_words_by_ref cur prev case $prev in --output) diff --git a/contrib/xsltproc b/contrib/xsltproc index 3576f980..f71d3f11 100644 --- a/contrib/xsltproc +++ b/contrib/xsltproc @@ -5,8 +5,7 @@ _xsltproc() { local cur prev COMPREPLY=() - cur=`_get_cword` - prev=`_get_pword` + _get_comp_words_by_ref cur prev case $prev in --output|-o) diff --git a/contrib/xz b/contrib/xz index 3a543f33..46420b01 100644 --- a/contrib/xz +++ b/contrib/xz @@ -4,8 +4,8 @@ have xz && _xz() { COMPREPLY=() - local cur=`_get_cword` - local prev=${COMP_WORDS[COMP_CWORD-1]} + local cur prev + _get_comp_words_by_ref cur prev if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--compress --decompress --test --list \ @@ -64,8 +64,8 @@ have xzdec && _xzdec() { COMPREPLY=() - local cur=`_get_cword` - local prev=${COMP_WORDS[COMP_CWORD-1]} + local cur prev + _get_comp_words_by_ref cur prev if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--memory --help --version' -- "$cur" ) ) diff --git a/contrib/yp-tools b/contrib/yp-tools index 4644ba5b..7252a129 100644 --- a/contrib/yp-tools +++ b/contrib/yp-tools @@ -6,7 +6,7 @@ _ypmatch() local cur map cmd COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur cmd=${1##*/} [[ $cmd == ypcat && $COMP_CWORD -gt 1 ]] && return 0 diff --git a/contrib/yum-arch b/contrib/yum-arch index fe70e77a..3728335c 100644 --- a/contrib/yum-arch +++ b/contrib/yum-arch @@ -5,7 +5,7 @@ _yum_arch() { local cur COMPREPLY=() - cur=`_get_cword` + _get_comp_words_by_ref cur if [[ "$cur" == -* ]] ; then COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l -q' -- "$cur" ) ) diff --git a/test/completion/chgrp.exp b/test/completion/chgrp.exp new file mode 100644 index 00000000..2b1d2251 --- /dev/null +++ b/test/completion/chgrp.exp @@ -0,0 +1 @@ +assert_source_completions chgrp diff --git a/test/completion/crontab.exp b/test/completion/crontab.exp new file mode 100644 index 00000000..2a649491 --- /dev/null +++ b/test/completion/crontab.exp @@ -0,0 +1 @@ +assert_source_completions crontab diff --git a/test/completion/hping2.exp b/test/completion/hping2.exp new file mode 100644 index 00000000..e9df7c2b --- /dev/null +++ b/test/completion/hping2.exp @@ -0,0 +1 @@ +assert_source_completions hping2 diff --git a/test/completion/ipsec.exp b/test/completion/ipsec.exp new file mode 100644 index 00000000..f904429b --- /dev/null +++ b/test/completion/ipsec.exp @@ -0,0 +1 @@ +assert_source_completions ipsec diff --git a/test/completion/lrzip.exp b/test/completion/lrzip.exp new file mode 100644 index 00000000..60616f00 --- /dev/null +++ b/test/completion/lrzip.exp @@ -0,0 +1 @@ +assert_source_completions lrzip diff --git a/test/completion/pgrep.exp b/test/completion/pgrep.exp new file mode 100644 index 00000000..6deac165 --- /dev/null +++ b/test/completion/pgrep.exp @@ -0,0 +1 @@ +assert_source_completions pgrep diff --git a/test/completion/pkill.exp b/test/completion/pkill.exp new file mode 100644 index 00000000..56e30836 --- /dev/null +++ b/test/completion/pkill.exp @@ -0,0 +1 @@ +assert_source_completions pkill diff --git a/test/completion/sqlite3.exp b/test/completion/sqlite3.exp new file mode 100644 index 00000000..88195e0d --- /dev/null +++ b/test/completion/sqlite3.exp @@ -0,0 +1 @@ +assert_source_completions sqlite3 diff --git a/test/config/default.exp b/test/config/default.exp index d1c04e71..029f11d5 100644 --- a/test/config/default.exp +++ b/test/config/default.exp @@ -1,23 +1,23 @@ - # Set default expect fallback routines +# Set default expect fallback routines expect_after { eof { if {[info exists test]} { fail "$test at eof" } else { fail "[info level 1] at eof" - }; # if - }; # eof + } + } timeout { if {[info exists test]} { fail "$test at timeout" } else { fail "[info level 1] at timeout" - }; # if - }; # timeout -}; # expect_after() + } + } +} - # Call tool_start(), if available +# Call tool_start(), if available if { [info procs "${tool}_start"] != "" } { ${tool}_start -}; # if +} diff --git a/test/generate b/test/generate index aa282a2c..dc400cb6 100755 --- a/test/generate +++ b/test/generate @@ -32,12 +32,12 @@ generate_test_lib_completions() { cat < "$path" proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/a2ps.exp b/test/lib/completions/a2ps.exp index 796e14cc..77cd07f5 100644 --- a/test/lib/completions/a2ps.exp +++ b/test/lib/completions/a2ps.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/abook.exp b/test/lib/completions/abook.exp index 3f4e301f..43f62729 100644 --- a/test/lib/completions/abook.exp +++ b/test/lib/completions/abook.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/acroread.exp b/test/lib/completions/acroread.exp index 4f11f905..f1754e98 100644 --- a/test/lib/completions/acroread.exp +++ b/test/lib/completions/acroread.exp @@ -1,13 +1,13 @@ proc setup {} { save_env assert_bash_exec "touch fixtures/shared/default/t.pdf"; # Create temporary files -}; # setup() +} proc teardown {} { assert_bash_exec "rm fixtures/shared/default/t.pdf"; # Remove temporary files assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/add_members.exp b/test/lib/completions/add_members.exp index 02cd762d..46c7a688 100644 --- a/test/lib/completions/add_members.exp +++ b/test/lib/completions/add_members.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/alias.exp b/test/lib/completions/alias.exp index e6b88d00..9dba4e62 100644 --- a/test/lib/completions/alias.exp +++ b/test/lib/completions/alias.exp @@ -3,13 +3,13 @@ proc setup {} { assert_bash_exec "alias foo=bar" assert_bash_exec "alias bar='foo foo'" save_env -}; # setup() +} proc teardown {} { assert_bash_exec "unalias -a"; # Remove all aliases assert_env_unmodified -}; # teardown() +} setup @@ -34,7 +34,7 @@ expect { -re "^alias foo\b\b\bfoo=foo\b\b\b$" { fail "$test: Wrong cursor position" } -re /@ { unresolved "$test" } default { unresolved "$test" } -}; # expect +} sync_after_int diff --git a/test/lib/completions/animate.exp b/test/lib/completions/animate.exp index 26065d25..12314d79 100644 --- a/test/lib/completions/animate.exp +++ b/test/lib/completions/animate.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ant.exp b/test/lib/completions/ant.exp index 81294439..de57f24a 100644 --- a/test/lib/completions/ant.exp +++ b/test/lib/completions/ant.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/apache2ctl.exp b/test/lib/completions/apache2ctl.exp index e63abb16..88e53fc2 100644 --- a/test/lib/completions/apache2ctl.exp +++ b/test/lib/completions/apache2ctl.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/apt-build.exp b/test/lib/completions/apt-build.exp index fd09d0eb..01ff04b4 100644 --- a/test/lib/completions/apt-build.exp +++ b/test/lib/completions/apt-build.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/apt-cache.exp b/test/lib/completions/apt-cache.exp index 5336beab..63be48a8 100644 --- a/test/lib/completions/apt-cache.exp +++ b/test/lib/completions/apt-cache.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/apt-get.exp b/test/lib/completions/apt-get.exp index 6bd0f3a2..66887bd0 100644 --- a/test/lib/completions/apt-get.exp +++ b/test/lib/completions/apt-get.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/aptitude.exp b/test/lib/completions/aptitude.exp index dde6d26e..e6e82abb 100644 --- a/test/lib/completions/aptitude.exp +++ b/test/lib/completions/aptitude.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/arch.exp b/test/lib/completions/arch.exp index 9f7114c4..0550c76b 100644 --- a/test/lib/completions/arch.exp +++ b/test/lib/completions/arch.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/arpspoof.exp b/test/lib/completions/arpspoof.exp index 7db79f50..91ef5182 100644 --- a/test/lib/completions/arpspoof.exp +++ b/test/lib/completions/arpspoof.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/aspell.exp b/test/lib/completions/aspell.exp index 4edeb03b..9dd5f61a 100644 --- a/test/lib/completions/aspell.exp +++ b/test/lib/completions/aspell.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/autoconf.exp b/test/lib/completions/autoconf.exp index 4a44b651..53b096db 100644 --- a/test/lib/completions/autoconf.exp +++ b/test/lib/completions/autoconf.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/automake.exp b/test/lib/completions/automake.exp index cf27364a..f875da56 100644 --- a/test/lib/completions/automake.exp +++ b/test/lib/completions/automake.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/autorpm.exp b/test/lib/completions/autorpm.exp index 99b743ca..2ae4ff80 100644 --- a/test/lib/completions/autorpm.exp +++ b/test/lib/completions/autorpm.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/awk.exp b/test/lib/completions/awk.exp index 4288adbf..260dabcc 100644 --- a/test/lib/completions/awk.exp +++ b/test/lib/completions/awk.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/bash.exp b/test/lib/completions/bash.exp index 4caf58fc..bf01e76d 100644 --- a/test/lib/completions/bash.exp +++ b/test/lib/completions/bash.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/bc.exp b/test/lib/completions/bc.exp index c437d037..23c22b62 100644 --- a/test/lib/completions/bc.exp +++ b/test/lib/completions/bc.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/bison.exp b/test/lib/completions/bison.exp index a3dea1e0..4bbb59fa 100644 --- a/test/lib/completions/bison.exp +++ b/test/lib/completions/bison.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/bk.exp b/test/lib/completions/bk.exp index 4915136e..b652e6b0 100644 --- a/test/lib/completions/bk.exp +++ b/test/lib/completions/bk.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/brctl.exp b/test/lib/completions/brctl.exp index d87002a2..57c9edff 100644 --- a/test/lib/completions/brctl.exp +++ b/test/lib/completions/brctl.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/btdownloadcurses.py.exp b/test/lib/completions/btdownloadcurses.py.exp index 9dc0ba5a..71a00de7 100644 --- a/test/lib/completions/btdownloadcurses.py.exp +++ b/test/lib/completions/btdownloadcurses.py.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/btdownloadgui.py.exp b/test/lib/completions/btdownloadgui.py.exp index 03897a53..65f56776 100644 --- a/test/lib/completions/btdownloadgui.py.exp +++ b/test/lib/completions/btdownloadgui.py.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/btdownloadheadless.py.exp b/test/lib/completions/btdownloadheadless.py.exp index 69c62950..3c833bb8 100644 --- a/test/lib/completions/btdownloadheadless.py.exp +++ b/test/lib/completions/btdownloadheadless.py.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/bzip2.exp b/test/lib/completions/bzip2.exp index e5389a2a..2813dd0e 100644 --- a/test/lib/completions/bzip2.exp +++ b/test/lib/completions/bzip2.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/c++.exp b/test/lib/completions/c++.exp index 1fe4bb13..4dffb042 100644 --- a/test/lib/completions/c++.exp +++ b/test/lib/completions/c++.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/cancel.exp b/test/lib/completions/cancel.exp index 24ca47c4..fc2600ba 100644 --- a/test/lib/completions/cancel.exp +++ b/test/lib/completions/cancel.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -22,7 +22,7 @@ if {[assert_exec {lp -H hold fixtures/shared/default/foo} job "" "untested"]} { assert_complete $jobs "cancel " # Remove/cancel the test print job assert_exec "cancel $job_id" -}; # if +} sync_after_int diff --git a/test/lib/completions/cardctl.exp b/test/lib/completions/cardctl.exp index b5d7e88d..9df90f48 100644 --- a/test/lib/completions/cardctl.exp +++ b/test/lib/completions/cardctl.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/cat.exp b/test/lib/completions/cat.exp index 46e8775f..01b3659e 100644 --- a/test/lib/completions/cat.exp +++ b/test/lib/completions/cat.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/cc.exp b/test/lib/completions/cc.exp index 1d63d006..eb722dea 100644 --- a/test/lib/completions/cc.exp +++ b/test/lib/completions/cc.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/cd.exp b/test/lib/completions/cd.exp index 58233575..2101f035 100644 --- a/test/lib/completions/cd.exp +++ b/test/lib/completions/cd.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -29,7 +29,7 @@ expect { -re "^cd fixtures/shared/default/foo\b\b\bfoo.d/foo\b\b\b$" { fail "$test: Wrong cursor position" } -re /@ { unresolved "$test at prompt" } default { unresolved "$test" } -}; # expect +} sync_after_int diff --git a/test/lib/completions/cdrecord.exp b/test/lib/completions/cdrecord.exp index d369f79d..192d2ded 100644 --- a/test/lib/completions/cdrecord.exp +++ b/test/lib/completions/cdrecord.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/change_pw.exp b/test/lib/completions/change_pw.exp index ca9bcdbd..28301941 100644 --- a/test/lib/completions/change_pw.exp +++ b/test/lib/completions/change_pw.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/check_db.exp b/test/lib/completions/check_db.exp index ca59a715..fe34ead2 100644 --- a/test/lib/completions/check_db.exp +++ b/test/lib/completions/check_db.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/check_perms.exp b/test/lib/completions/check_perms.exp index a58995b0..b40b78fc 100644 --- a/test/lib/completions/check_perms.exp +++ b/test/lib/completions/check_perms.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/chgrp.exp b/test/lib/completions/chgrp.exp new file mode 100644 index 00000000..e9238bde --- /dev/null +++ b/test/lib/completions/chgrp.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "chgrp " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/chkconfig.exp b/test/lib/completions/chkconfig.exp index e7469b34..dae3b3bd 100644 --- a/test/lib/completions/chkconfig.exp +++ b/test/lib/completions/chkconfig.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/chown.exp b/test/lib/completions/chown.exp index 953b2b02..a758cc1d 100644 --- a/test/lib/completions/chown.exp +++ b/test/lib/completions/chown.exp @@ -1,10 +1,10 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/chsh.exp b/test/lib/completions/chsh.exp index 99262a2c..a26ac93f 100644 --- a/test/lib/completions/chsh.exp +++ b/test/lib/completions/chsh.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ci.exp b/test/lib/completions/ci.exp index 09105eec..15ef2ecc 100644 --- a/test/lib/completions/ci.exp +++ b/test/lib/completions/ci.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/civclient.exp b/test/lib/completions/civclient.exp index 8159c2bc..c0047468 100644 --- a/test/lib/completions/civclient.exp +++ b/test/lib/completions/civclient.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/civserver.exp b/test/lib/completions/civserver.exp index df459688..3739f50e 100644 --- a/test/lib/completions/civserver.exp +++ b/test/lib/completions/civserver.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/cksfv.exp b/test/lib/completions/cksfv.exp index a40a5023..2b9be04c 100644 --- a/test/lib/completions/cksfv.exp +++ b/test/lib/completions/cksfv.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/cleanarch.exp b/test/lib/completions/cleanarch.exp index e3145e81..a5f3bfe6 100644 --- a/test/lib/completions/cleanarch.exp +++ b/test/lib/completions/cleanarch.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/clisp.exp b/test/lib/completions/clisp.exp index 2bc599ac..dfbad4f3 100644 --- a/test/lib/completions/clisp.exp +++ b/test/lib/completions/clisp.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/clone_member.exp b/test/lib/completions/clone_member.exp index 34b4db57..d83d73bc 100644 --- a/test/lib/completions/clone_member.exp +++ b/test/lib/completions/clone_member.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/co.exp b/test/lib/completions/co.exp index 49fe3a64..215268b6 100644 --- a/test/lib/completions/co.exp +++ b/test/lib/completions/co.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/composite.exp b/test/lib/completions/composite.exp index e39ce72f..aba9af3b 100644 --- a/test/lib/completions/composite.exp +++ b/test/lib/completions/composite.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/config_list.exp b/test/lib/completions/config_list.exp index 5246c860..27699239 100644 --- a/test/lib/completions/config_list.exp +++ b/test/lib/completions/config_list.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/configure.exp b/test/lib/completions/configure.exp index 74afba1b..b4399cb1 100644 --- a/test/lib/completions/configure.exp +++ b/test/lib/completions/configure.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/convert.exp b/test/lib/completions/convert.exp index d8a77e35..07032040 100644 --- a/test/lib/completions/convert.exp +++ b/test/lib/completions/convert.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/cowsay.exp b/test/lib/completions/cowsay.exp index dfbefe1a..382f400f 100644 --- a/test/lib/completions/cowsay.exp +++ b/test/lib/completions/cowsay.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/cp.exp b/test/lib/completions/cp.exp index 9fe46537..703bf263 100644 --- a/test/lib/completions/cp.exp +++ b/test/lib/completions/cp.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/cpio.exp b/test/lib/completions/cpio.exp index b02f2719..93f6f3c1 100644 --- a/test/lib/completions/cpio.exp +++ b/test/lib/completions/cpio.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/createdb.exp b/test/lib/completions/createdb.exp index 1e5cdbe7..aafff1b6 100644 --- a/test/lib/completions/createdb.exp +++ b/test/lib/completions/createdb.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/crontab.exp b/test/lib/completions/crontab.exp new file mode 100644 index 00000000..18e2269f --- /dev/null +++ b/test/lib/completions/crontab.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "crontab " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/cryptsetup.exp b/test/lib/completions/cryptsetup.exp index e94c3ac1..4c20bc5d 100644 --- a/test/lib/completions/cryptsetup.exp +++ b/test/lib/completions/cryptsetup.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/csplit.exp b/test/lib/completions/csplit.exp index 3a66a627..87b89dea 100644 --- a/test/lib/completions/csplit.exp +++ b/test/lib/completions/csplit.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/cut.exp b/test/lib/completions/cut.exp index b9bcf6c5..edb558ea 100644 --- a/test/lib/completions/cut.exp +++ b/test/lib/completions/cut.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/cvs.exp b/test/lib/completions/cvs.exp index 2a26da8e..f6853946 100644 --- a/test/lib/completions/cvs.exp +++ b/test/lib/completions/cvs.exp @@ -1,7 +1,7 @@ proc setup {} { save_env assert_bash_exec {OLDHOME=$HOME ; HOME=$TESTDIR/fixtures/cvs} -}; # setup() +} proc teardown {} { @@ -9,7 +9,7 @@ proc teardown {} { assert_env_unmodified { /OLDHOME=/d } -}; # teardown() +} setup @@ -27,7 +27,7 @@ send "$cmd\t" expect { -re "^$cmd\r\n.*:pserver:.*\r\n/@$cmd:pserver:.*$" { pass "$test" } default { fail "$test" } -}; # expect +} sync_after_int diff --git a/test/lib/completions/cvsps.exp b/test/lib/completions/cvsps.exp index 1fd4a0a9..def4a11b 100644 --- a/test/lib/completions/cvsps.exp +++ b/test/lib/completions/cvsps.exp @@ -1,7 +1,7 @@ proc setup {} { save_env assert_bash_exec {OLDHOME=$HOME ; HOME=$TESTDIR/fixtures/cvs} -}; # setup() +} proc teardown {} { @@ -9,7 +9,7 @@ proc teardown {} { assert_env_unmodified { /OLDHOME=/d } -}; # teardown() +} setup @@ -27,7 +27,7 @@ send "$cmd\t" expect { -re "^$cmd\r\n.*:pserver:.*\r\n/@$cmd:pserver:.*$" { pass "$test" } default { fail "$test" } -}; # expect +} sync_after_int diff --git a/test/lib/completions/date.exp b/test/lib/completions/date.exp index 9d75f5f3..ee970cf7 100644 --- a/test/lib/completions/date.exp +++ b/test/lib/completions/date.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dcop.exp b/test/lib/completions/dcop.exp index 6ed800c5..1e27346b 100644 --- a/test/lib/completions/dcop.exp +++ b/test/lib/completions/dcop.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {dcop} words]} { assert_complete $words "dcop " -}; # if +} sync_after_int diff --git a/test/lib/completions/dd.exp b/test/lib/completions/dd.exp index 400dd143..e02e037c 100644 --- a/test/lib/completions/dd.exp +++ b/test/lib/completions/dd.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -24,7 +24,7 @@ expect -ex "$cmd" expect { -re "^=$" { pass $test } -re {^\\=$} { xfail $test } -}; # expect +} sync_after_int diff --git a/test/lib/completions/df.exp b/test/lib/completions/df.exp index 487d70a9..acf212a9 100644 --- a/test/lib/completions/df.exp +++ b/test/lib/completions/df.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dhclient.exp b/test/lib/completions/dhclient.exp index 42c14c82..6caff5fc 100644 --- a/test/lib/completions/dhclient.exp +++ b/test/lib/completions/dhclient.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dict.exp b/test/lib/completions/dict.exp index 32fb4988..402e0c5c 100644 --- a/test/lib/completions/dict.exp +++ b/test/lib/completions/dict.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/diff.exp b/test/lib/completions/diff.exp index c009f640..918bf7fd 100644 --- a/test/lib/completions/diff.exp +++ b/test/lib/completions/diff.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dir.exp b/test/lib/completions/dir.exp index 6e20d37d..c9f61cd5 100644 --- a/test/lib/completions/dir.exp +++ b/test/lib/completions/dir.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/display.exp b/test/lib/completions/display.exp index 9a9d6901..e9fe766a 100644 --- a/test/lib/completions/display.exp +++ b/test/lib/completions/display.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dnsspoof.exp b/test/lib/completions/dnsspoof.exp index 3223a349..4aefb956 100644 --- a/test/lib/completions/dnsspoof.exp +++ b/test/lib/completions/dnsspoof.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dpkg-deb.exp b/test/lib/completions/dpkg-deb.exp index c8656610..37ece08d 100644 --- a/test/lib/completions/dpkg-deb.exp +++ b/test/lib/completions/dpkg-deb.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dpkg-reconfigure.exp b/test/lib/completions/dpkg-reconfigure.exp index 267594be..0212666b 100644 --- a/test/lib/completions/dpkg-reconfigure.exp +++ b/test/lib/completions/dpkg-reconfigure.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dpkg-source.exp b/test/lib/completions/dpkg-source.exp index a21eff45..a42759b9 100644 --- a/test/lib/completions/dpkg-source.exp +++ b/test/lib/completions/dpkg-source.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dpkg.exp b/test/lib/completions/dpkg.exp index 2bd1fb6e..f358e172 100644 --- a/test/lib/completions/dpkg.exp +++ b/test/lib/completions/dpkg.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -20,7 +20,7 @@ sync_after_int # Build list of installed packages if {[assert_exec {dpkg --get-selections | command grep \[\[:space:\]\]install$ | cut -f1} packages]} { assert_complete $packages "dpkg -L " -}; # if +} sync_after_int diff --git a/test/lib/completions/dropdb.exp b/test/lib/completions/dropdb.exp index e78a2ba7..8f2d5bfb 100644 --- a/test/lib/completions/dropdb.exp +++ b/test/lib/completions/dropdb.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dselect.exp b/test/lib/completions/dselect.exp index f6257294..634db05e 100644 --- a/test/lib/completions/dselect.exp +++ b/test/lib/completions/dselect.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dsniff.exp b/test/lib/completions/dsniff.exp index a0cc43ac..cb8912b6 100644 --- a/test/lib/completions/dsniff.exp +++ b/test/lib/completions/dsniff.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/du.exp b/test/lib/completions/du.exp index d1ffa8ca..6ddeb9b2 100644 --- a/test/lib/completions/du.exp +++ b/test/lib/completions/du.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/dumpdb.exp b/test/lib/completions/dumpdb.exp index 240214b3..5b617b11 100644 --- a/test/lib/completions/dumpdb.exp +++ b/test/lib/completions/dumpdb.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/enscript.exp b/test/lib/completions/enscript.exp index 7fefabdd..c859b50f 100644 --- a/test/lib/completions/enscript.exp +++ b/test/lib/completions/enscript.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/env.exp b/test/lib/completions/env.exp index f03f5395..4f213748 100644 --- a/test/lib/completions/env.exp +++ b/test/lib/completions/env.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {env --help} "" "" "unsupported"]} { assert_complete_any "env --" -}; # if +} sync_after_int diff --git a/test/lib/completions/evince.exp b/test/lib/completions/evince.exp index 22279a26..607c4428 100644 --- a/test/lib/completions/evince.exp +++ b/test/lib/completions/evince.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified {/OLDPWD=/d} -}; # teardown() +} setup diff --git a/test/lib/completions/expand.exp b/test/lib/completions/expand.exp index d5cd6b17..76b6eafa 100644 --- a/test/lib/completions/expand.exp +++ b/test/lib/completions/expand.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {expand --help} "" "" "unsupported"]} { assert_complete_any "expand --" -}; # if +} sync_after_int diff --git a/test/lib/completions/filesnarf.exp b/test/lib/completions/filesnarf.exp index 53cf01e4..03755056 100644 --- a/test/lib/completions/filesnarf.exp +++ b/test/lib/completions/filesnarf.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/find.exp b/test/lib/completions/find.exp index 4b1728dc..aab08225 100644 --- a/test/lib/completions/find.exp +++ b/test/lib/completions/find.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified {/OLDPWD=/d} -}; # teardown() +} setup @@ -50,28 +50,26 @@ sync_after_int set test "-uid should complete uids" - # Complete set cmd "find -uid " send "$cmd\t" expect { -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" } -re /@ { unresolved "$test at prompt" } -re eof { unresolved "eof" } -}; # expect +} sync_after_int set test "-gid should complete gids" - # Complete set cmd "find -gid " send "$cmd\t" expect { -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" } -re /@ { unresolved "$test at prompt" } -re eof { unresolved "eof" } -}; # expect +} sync_after_int diff --git a/test/lib/completions/find_member.exp b/test/lib/completions/find_member.exp index 58fac7d2..55672091 100644 --- a/test/lib/completions/find_member.exp +++ b/test/lib/completions/find_member.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/finger.exp b/test/lib/completions/finger.exp index 30f2b080..ae86a2d9 100644 --- a/test/lib/completions/finger.exp +++ b/test/lib/completions/finger.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -16,7 +16,7 @@ set test "Tab should complete usernames" set users {} foreach u [exec bash -c "compgen -A user"] { lappend users $u -}; # foreach +} assert_complete $users "finger " $test @@ -45,9 +45,9 @@ foreach h [get_known_hosts] { if {$first == $char && [lsearch -exact $hosts "test@$h"] == -1} { # Prefix hosts with username 'test@' lappend hosts "test@$h" - }; # if - }; # if -}; # foreach + } + } +} assert_complete $hosts "finger test@$char" $test diff --git a/test/lib/completions/fmt.exp b/test/lib/completions/fmt.exp index 28570682..7d3cc17f 100644 --- a/test/lib/completions/fmt.exp +++ b/test/lib/completions/fmt.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {fmt --help} "" "" "unsupported"]} { assert_complete_any "fmt -" -}; # if +} sync_after_int diff --git a/test/lib/completions/fold.exp b/test/lib/completions/fold.exp index a5230b03..f447f08b 100644 --- a/test/lib/completions/fold.exp +++ b/test/lib/completions/fold.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {fold --help} "" "" "unsupported"]} { assert_complete_any "fold --" -}; # if +} sync_after_int diff --git a/test/lib/completions/g++.exp b/test/lib/completions/g++.exp index 4dc2591a..4dbe73f4 100644 --- a/test/lib/completions/g++.exp +++ b/test/lib/completions/g++.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/g4.exp b/test/lib/completions/g4.exp index 203de061..7d575f10 100644 --- a/test/lib/completions/g4.exp +++ b/test/lib/completions/g4.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/g77.exp b/test/lib/completions/g77.exp index 8802aca9..e23745b7 100644 --- a/test/lib/completions/g77.exp +++ b/test/lib/completions/g77.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gcc.exp b/test/lib/completions/gcc.exp index 8e52a120..00097cc2 100644 --- a/test/lib/completions/gcc.exp +++ b/test/lib/completions/gcc.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gcj.exp b/test/lib/completions/gcj.exp index db52d59a..cde07700 100644 --- a/test/lib/completions/gcj.exp +++ b/test/lib/completions/gcj.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gcl.exp b/test/lib/completions/gcl.exp index 7cead846..1846d0d1 100644 --- a/test/lib/completions/gcl.exp +++ b/test/lib/completions/gcl.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gdb.exp b/test/lib/completions/gdb.exp index 982f0878..2e389edb 100644 --- a/test/lib/completions/gdb.exp +++ b/test/lib/completions/gdb.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/genaliases.exp b/test/lib/completions/genaliases.exp index 064eb386..bb4d5e0e 100644 --- a/test/lib/completions/genaliases.exp +++ b/test/lib/completions/genaliases.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/getent.exp b/test/lib/completions/getent.exp index 121f3b38..6500b22d 100644 --- a/test/lib/completions/getent.exp +++ b/test/lib/completions/getent.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gkrellm.exp b/test/lib/completions/gkrellm.exp index f8b0dd4d..009770fc 100644 --- a/test/lib/completions/gkrellm.exp +++ b/test/lib/completions/gkrellm.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gmplayer.exp b/test/lib/completions/gmplayer.exp index d9032698..a110cb2f 100644 --- a/test/lib/completions/gmplayer.exp +++ b/test/lib/completions/gmplayer.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gnatmake.exp b/test/lib/completions/gnatmake.exp index 902aa062..bad4da33 100644 --- a/test/lib/completions/gnatmake.exp +++ b/test/lib/completions/gnatmake.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gpc.exp b/test/lib/completions/gpc.exp index 6c4d0383..71eddacc 100644 --- a/test/lib/completions/gpc.exp +++ b/test/lib/completions/gpc.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gperf.exp b/test/lib/completions/gperf.exp index aa24333e..1cf77678 100644 --- a/test/lib/completions/gperf.exp +++ b/test/lib/completions/gperf.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gpg.exp b/test/lib/completions/gpg.exp index 29fd2244..ea6805fa 100644 --- a/test/lib/completions/gpg.exp +++ b/test/lib/completions/gpg.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gprof.exp b/test/lib/completions/gprof.exp index 592786af..996a1efd 100644 --- a/test/lib/completions/gprof.exp +++ b/test/lib/completions/gprof.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {gprof --help} "" "" "unsupported"]} { assert_complete_any "gprof --" -}; # if +} sync_after_int diff --git a/test/lib/completions/grep.exp b/test/lib/completions/grep.exp index 3814df71..c94ae727 100644 --- a/test/lib/completions/grep.exp +++ b/test/lib/completions/grep.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/grub.exp b/test/lib/completions/grub.exp index 9578e789..b88d1f26 100644 --- a/test/lib/completions/grub.exp +++ b/test/lib/completions/grub.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/gzip.exp b/test/lib/completions/gzip.exp index f212c61a..32acf428 100644 --- a/test/lib/completions/gzip.exp +++ b/test/lib/completions/gzip.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -19,7 +19,7 @@ expect { -re "^$cmd\r\n.*$cmd$" { pass "$test" } -re /@ { unresolved "$test at prompt" } -re eof { unresolved "eof" } -}; # expect +} sync_after_int diff --git a/test/lib/completions/hcitool.exp b/test/lib/completions/hcitool.exp index 9283adff..e6ae0032 100644 --- a/test/lib/completions/hcitool.exp +++ b/test/lib/completions/hcitool.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/head.exp b/test/lib/completions/head.exp index 0d4f6a20..7edb8a1b 100644 --- a/test/lib/completions/head.exp +++ b/test/lib/completions/head.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {head --help} "" "" "unsupported"]} { assert_complete_any "head --" -}; # if +} sync_after_int diff --git a/test/lib/completions/hping2.exp b/test/lib/completions/hping2.exp new file mode 100644 index 00000000..8919626d --- /dev/null +++ b/test/lib/completions/hping2.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "hping2 " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/iconv.exp b/test/lib/completions/iconv.exp index 420e923c..dcce330f 100644 --- a/test/lib/completions/iconv.exp +++ b/test/lib/completions/iconv.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/id.exp b/test/lib/completions/id.exp index 155af52c..b03ee721 100644 --- a/test/lib/completions/id.exp +++ b/test/lib/completions/id.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/identify.exp b/test/lib/completions/identify.exp index 8f38ae47..3347c5cd 100644 --- a/test/lib/completions/identify.exp +++ b/test/lib/completions/identify.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ifdown.exp b/test/lib/completions/ifdown.exp index 68225bb9..7849f3f7 100644 --- a/test/lib/completions/ifdown.exp +++ b/test/lib/completions/ifdown.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ifup.exp b/test/lib/completions/ifup.exp index 9d717178..2c1c010e 100644 --- a/test/lib/completions/ifup.exp +++ b/test/lib/completions/ifup.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/indent.exp b/test/lib/completions/indent.exp index e8fc32b1..5c5bb1c7 100644 --- a/test/lib/completions/indent.exp +++ b/test/lib/completions/indent.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/info.exp b/test/lib/completions/info.exp index ed769f1a..e7c79e6e 100644 --- a/test/lib/completions/info.exp +++ b/test/lib/completions/info.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/inject.exp b/test/lib/completions/inject.exp index 7c093146..4f95be23 100644 --- a/test/lib/completions/inject.exp +++ b/test/lib/completions/inject.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/insmod.exp b/test/lib/completions/insmod.exp index 8e83f0b4..a312c894 100644 --- a/test/lib/completions/insmod.exp +++ b/test/lib/completions/insmod.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/invoke-rc.d.exp b/test/lib/completions/invoke-rc.d.exp index 4dc9f1d8..d217d17e 100644 --- a/test/lib/completions/invoke-rc.d.exp +++ b/test/lib/completions/invoke-rc.d.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ipsec.exp b/test/lib/completions/ipsec.exp new file mode 100644 index 00000000..74ef638c --- /dev/null +++ b/test/lib/completions/ipsec.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ipsec " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ipv6calc.exp b/test/lib/completions/ipv6calc.exp index 74ce95f7..42201f0c 100644 --- a/test/lib/completions/ipv6calc.exp +++ b/test/lib/completions/ipv6calc.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/irb.exp b/test/lib/completions/irb.exp index 81bea6d2..720edfdf 100644 --- a/test/lib/completions/irb.exp +++ b/test/lib/completions/irb.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/isql.exp b/test/lib/completions/isql.exp index 87e16bca..ca40faca 100644 --- a/test/lib/completions/isql.exp +++ b/test/lib/completions/isql.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified {/ODBCINI=/d} -}; # teardown() +} setup diff --git a/test/lib/completions/iwconfig.exp b/test/lib/completions/iwconfig.exp index f09719d7..82ae11f3 100644 --- a/test/lib/completions/iwconfig.exp +++ b/test/lib/completions/iwconfig.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/iwlist.exp b/test/lib/completions/iwlist.exp index 80a2c367..43c919ef 100644 --- a/test/lib/completions/iwlist.exp +++ b/test/lib/completions/iwlist.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/iwpriv.exp b/test/lib/completions/iwpriv.exp index f3102cc5..86b1ee95 100644 --- a/test/lib/completions/iwpriv.exp +++ b/test/lib/completions/iwpriv.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/iwspy.exp b/test/lib/completions/iwspy.exp index 5fa0bee5..2894ca4e 100644 --- a/test/lib/completions/iwspy.exp +++ b/test/lib/completions/iwspy.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/jar.exp b/test/lib/completions/jar.exp index 0e11f684..d2cb476b 100644 --- a/test/lib/completions/jar.exp +++ b/test/lib/completions/jar.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/jarsigner.exp b/test/lib/completions/jarsigner.exp index 075e0263..7ea7cb2e 100644 --- a/test/lib/completions/jarsigner.exp +++ b/test/lib/completions/jarsigner.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/java.exp b/test/lib/completions/java.exp index 14610b2f..16b60054 100644 --- a/test/lib/completions/java.exp +++ b/test/lib/completions/java.exp @@ -1,12 +1,12 @@ proc setup {} { assert_bash_exec {CLASSPATH=$TESTDIR/fixtures/java/a:$TESTDIR/fixtures/java/bashcomp.jar} save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/javac.exp b/test/lib/completions/javac.exp index 6013de11..948fe8c8 100644 --- a/test/lib/completions/javac.exp +++ b/test/lib/completions/javac.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/javadoc.exp b/test/lib/completions/javadoc.exp index 40c922ca..0af8a3da 100644 --- a/test/lib/completions/javadoc.exp +++ b/test/lib/completions/javadoc.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/k3b.exp b/test/lib/completions/k3b.exp index 86942d67..cde14b86 100644 --- a/test/lib/completions/k3b.exp +++ b/test/lib/completions/k3b.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/kdvi.exp b/test/lib/completions/kdvi.exp index 0196049a..c7881da1 100644 --- a/test/lib/completions/kdvi.exp +++ b/test/lib/completions/kdvi.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified {/OLDPWD=/d} -}; # teardown() +} setup diff --git a/test/lib/completions/kill.exp b/test/lib/completions/kill.exp index ca02650c..1e80fe69 100644 --- a/test/lib/completions/kill.exp +++ b/test/lib/completions/kill.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/killall.exp b/test/lib/completions/killall.exp index 763c8e7d..ae8b3d60 100644 --- a/test/lib/completions/killall.exp +++ b/test/lib/completions/killall.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/kldload.exp b/test/lib/completions/kldload.exp index 0493a10a..a1d87c97 100644 --- a/test/lib/completions/kldload.exp +++ b/test/lib/completions/kldload.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/kldunload.exp b/test/lib/completions/kldunload.exp index 192159a5..476c5104 100644 --- a/test/lib/completions/kldunload.exp +++ b/test/lib/completions/kldunload.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/kpdf.exp b/test/lib/completions/kpdf.exp index 010abcfb..4066c9c6 100644 --- a/test/lib/completions/kpdf.exp +++ b/test/lib/completions/kpdf.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified {/OLDPWD=/d} -}; # teardown() +} setup diff --git a/test/lib/completions/kplayer.exp b/test/lib/completions/kplayer.exp index 34c9b3bf..4fdfa672 100644 --- a/test/lib/completions/kplayer.exp +++ b/test/lib/completions/kplayer.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/larch.exp b/test/lib/completions/larch.exp index 076016f2..cefcbe02 100644 --- a/test/lib/completions/larch.exp +++ b/test/lib/completions/larch.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ld.exp b/test/lib/completions/ld.exp index 60377991..ee660fcb 100644 --- a/test/lib/completions/ld.exp +++ b/test/lib/completions/ld.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ldd.exp b/test/lib/completions/ldd.exp index e45d1df7..1c3239c7 100644 --- a/test/lib/completions/ldd.exp +++ b/test/lib/completions/ldd.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/less.exp b/test/lib/completions/less.exp index 269c9b5c..78d6ef14 100644 --- a/test/lib/completions/less.exp +++ b/test/lib/completions/less.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lftp.exp b/test/lib/completions/lftp.exp index a49a1935..9fcc9a67 100644 --- a/test/lib/completions/lftp.exp +++ b/test/lib/completions/lftp.exp @@ -1,12 +1,12 @@ proc setup {} { assert_bash_exec {HOME=$TESTDIR/fixtures/lftp} save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lftpget.exp b/test/lib/completions/lftpget.exp index 7d80216e..0eadb6e9 100644 --- a/test/lib/completions/lftpget.exp +++ b/test/lib/completions/lftpget.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lilo.exp b/test/lib/completions/lilo.exp index 505a1470..36ea2c66 100644 --- a/test/lib/completions/lilo.exp +++ b/test/lib/completions/lilo.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/links.exp b/test/lib/completions/links.exp index 9f4896aa..4124e2f4 100644 --- a/test/lib/completions/links.exp +++ b/test/lib/completions/links.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lisp.exp b/test/lib/completions/lisp.exp index 21663628..5131b45d 100644 --- a/test/lib/completions/lisp.exp +++ b/test/lib/completions/lisp.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/list_admins.exp b/test/lib/completions/list_admins.exp index e1c9c4dd..3b412136 100644 --- a/test/lib/completions/list_admins.exp +++ b/test/lib/completions/list_admins.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/list_lists.exp b/test/lib/completions/list_lists.exp index 789ab1a8..a62dca25 100644 --- a/test/lib/completions/list_lists.exp +++ b/test/lib/completions/list_lists.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/list_members.exp b/test/lib/completions/list_members.exp index c93b53d7..8c74cdfb 100644 --- a/test/lib/completions/list_members.exp +++ b/test/lib/completions/list_members.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/list_owners.exp b/test/lib/completions/list_owners.exp index c96e0229..65e3ba8e 100644 --- a/test/lib/completions/list_owners.exp +++ b/test/lib/completions/list_owners.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ln.exp b/test/lib/completions/ln.exp index 34786071..61405020 100644 --- a/test/lib/completions/ln.exp +++ b/test/lib/completions/ln.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/look.exp b/test/lib/completions/look.exp index 53a3c464..8f93db24 100644 --- a/test/lib/completions/look.exp +++ b/test/lib/completions/look.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {look foo | grep ^foo} words]} { assert_complete $words "look foo" -}; # if +} sync_after_int diff --git a/test/lib/completions/lrzip.exp b/test/lib/completions/lrzip.exp new file mode 100644 index 00000000..97bc1235 --- /dev/null +++ b/test/lib/completions/lrzip.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lrzip " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ls.exp b/test/lib/completions/ls.exp index db2d41d3..a7537dc7 100644 --- a/test/lib/completions/ls.exp +++ b/test/lib/completions/ls.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,18 @@ setup if {[assert_exec {ls --help} "" "" "unsupported"]} { assert_complete_any "ls --" -}; # if +} + + +sync_after_int + + +set test "~part should complete to ~full" +assert_bash_exec {compgen -u} {} /@ users +find_unique_completion_pair $users part full +# If home directory exists, append slash "/", else space " " +set trail [expr {[llength [glob -nocomplain ~$full]] ? "/" : " "}] +assert_complete "~$full$trail" "ls ~$part" $test sync_after_int diff --git a/test/lib/completions/lvchange.exp b/test/lib/completions/lvchange.exp index ec3886b8..6587a260 100644 --- a/test/lib/completions/lvchange.exp +++ b/test/lib/completions/lvchange.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lvcreate.exp b/test/lib/completions/lvcreate.exp index 46dceb79..91cb0d81 100644 --- a/test/lib/completions/lvcreate.exp +++ b/test/lib/completions/lvcreate.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lvdisplay.exp b/test/lib/completions/lvdisplay.exp index 5a01a0e5..6fa9c294 100644 --- a/test/lib/completions/lvdisplay.exp +++ b/test/lib/completions/lvdisplay.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lvextend.exp b/test/lib/completions/lvextend.exp index 24a63853..ded34695 100644 --- a/test/lib/completions/lvextend.exp +++ b/test/lib/completions/lvextend.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lvm.exp b/test/lib/completions/lvm.exp index 1c67825e..91fe0dcd 100644 --- a/test/lib/completions/lvm.exp +++ b/test/lib/completions/lvm.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lvmdiskscan.exp b/test/lib/completions/lvmdiskscan.exp index 27e566d4..6553865f 100644 --- a/test/lib/completions/lvmdiskscan.exp +++ b/test/lib/completions/lvmdiskscan.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lvreduce.exp b/test/lib/completions/lvreduce.exp index edd5150d..e2708f89 100644 --- a/test/lib/completions/lvreduce.exp +++ b/test/lib/completions/lvreduce.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lvremove.exp b/test/lib/completions/lvremove.exp index 1cd63150..8ca1517b 100644 --- a/test/lib/completions/lvremove.exp +++ b/test/lib/completions/lvremove.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lvrename.exp b/test/lib/completions/lvrename.exp index 51624222..17179ce9 100644 --- a/test/lib/completions/lvrename.exp +++ b/test/lib/completions/lvrename.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lvresize.exp b/test/lib/completions/lvresize.exp index 830b9ab1..2b3e1044 100644 --- a/test/lib/completions/lvresize.exp +++ b/test/lib/completions/lvresize.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lvs.exp b/test/lib/completions/lvs.exp index 8b239f5d..e531f7e9 100644 --- a/test/lib/completions/lvs.exp +++ b/test/lib/completions/lvs.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lvscan.exp b/test/lib/completions/lvscan.exp index 841fd0ed..7b09e5e1 100644 --- a/test/lib/completions/lvscan.exp +++ b/test/lib/completions/lvscan.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lzma.exp b/test/lib/completions/lzma.exp index 79d78854..56364d13 100644 --- a/test/lib/completions/lzma.exp +++ b/test/lib/completions/lzma.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/lzop.exp b/test/lib/completions/lzop.exp index c33e814e..a7d3da25 100644 --- a/test/lib/completions/lzop.exp +++ b/test/lib/completions/lzop.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/m4.exp b/test/lib/completions/m4.exp index 2cc884b3..334132db 100644 --- a/test/lib/completions/m4.exp +++ b/test/lib/completions/m4.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {m4 --help} "" "" "unsupported"]} { assert_complete_any "m4 --" -}; # if +} sync_after_int diff --git a/test/lib/completions/macof.exp b/test/lib/completions/macof.exp index e21b1e77..873ae1da 100644 --- a/test/lib/completions/macof.exp +++ b/test/lib/completions/macof.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mailmanctl.exp b/test/lib/completions/mailmanctl.exp index a69b7650..2924806a 100644 --- a/test/lib/completions/mailmanctl.exp +++ b/test/lib/completions/mailmanctl.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mailsnarf.exp b/test/lib/completions/mailsnarf.exp index df9981b7..9fb937f3 100644 --- a/test/lib/completions/mailsnarf.exp +++ b/test/lib/completions/mailsnarf.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/make.exp b/test/lib/completions/make.exp index 90b9e68b..64a393da 100644 --- a/test/lib/completions/make.exp +++ b/test/lib/completions/make.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/man.exp b/test/lib/completions/man.exp index 62c14c86..47a6575f 100644 --- a/test/lib/completions/man.exp +++ b/test/lib/completions/man.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mc.exp b/test/lib/completions/mc.exp index 866161ba..eb97246d 100644 --- a/test/lib/completions/mc.exp +++ b/test/lib/completions/mc.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mcrypt.exp b/test/lib/completions/mcrypt.exp index bfc5d2d2..525ccbc3 100644 --- a/test/lib/completions/mcrypt.exp +++ b/test/lib/completions/mcrypt.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/md5sum.exp b/test/lib/completions/md5sum.exp index 25290b56..54ed6416 100644 --- a/test/lib/completions/md5sum.exp +++ b/test/lib/completions/md5sum.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mdecrypt.exp b/test/lib/completions/mdecrypt.exp index 4e49ae12..8d9d9f59 100644 --- a/test/lib/completions/mdecrypt.exp +++ b/test/lib/completions/mdecrypt.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mencoder.exp b/test/lib/completions/mencoder.exp index 169dcb71..db29f66a 100644 --- a/test/lib/completions/mencoder.exp +++ b/test/lib/completions/mencoder.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/minicom.exp b/test/lib/completions/minicom.exp index 935502f1..dfc96c01 100644 --- a/test/lib/completions/minicom.exp +++ b/test/lib/completions/minicom.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mkdir.exp b/test/lib/completions/mkdir.exp index 43dfec7e..a9333564 100644 --- a/test/lib/completions/mkdir.exp +++ b/test/lib/completions/mkdir.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mkfifo.exp b/test/lib/completions/mkfifo.exp index c6343f8d..59412a2e 100644 --- a/test/lib/completions/mkfifo.exp +++ b/test/lib/completions/mkfifo.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mkinitrd.exp b/test/lib/completions/mkinitrd.exp index cfb316e5..007f278d 100644 --- a/test/lib/completions/mkinitrd.exp +++ b/test/lib/completions/mkinitrd.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mkisofs.exp b/test/lib/completions/mkisofs.exp index ad24ea06..98780b1e 100644 --- a/test/lib/completions/mkisofs.exp +++ b/test/lib/completions/mkisofs.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -25,7 +25,7 @@ expect { -re "^$cmd\r\n\\d+.*$cmd$" { pass "$test" } -re /@ { unresolved "$test at prompt" } -re eof { unresolved "eof" } -}; # expect +} sync_after_int @@ -39,7 +39,7 @@ expect { -re "^$cmd\r\n\\d+.*$cmd$" { pass "$test" } -re /@ { unresolved "$test at prompt" } -re eof { unresolved "eof" } -}; # expect +} sync_after_int diff --git a/test/lib/completions/mknod.exp b/test/lib/completions/mknod.exp index 2c58cade..145f4531 100644 --- a/test/lib/completions/mknod.exp +++ b/test/lib/completions/mknod.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mmsitepass.exp b/test/lib/completions/mmsitepass.exp index d69fa202..4dde214f 100644 --- a/test/lib/completions/mmsitepass.exp +++ b/test/lib/completions/mmsitepass.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/module.exp b/test/lib/completions/module.exp index a34667d4..5e36a6da 100644 --- a/test/lib/completions/module.exp +++ b/test/lib/completions/module.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mogrify.exp b/test/lib/completions/mogrify.exp index ef7e18ee..84ceeff5 100644 --- a/test/lib/completions/mogrify.exp +++ b/test/lib/completions/mogrify.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/montage.exp b/test/lib/completions/montage.exp index 736609a5..4d85e1a4 100644 --- a/test/lib/completions/montage.exp +++ b/test/lib/completions/montage.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mplayer.exp b/test/lib/completions/mplayer.exp index 69e5d971..9230a86d 100644 --- a/test/lib/completions/mplayer.exp +++ b/test/lib/completions/mplayer.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/msgsnarf.exp b/test/lib/completions/msgsnarf.exp index 74f458ff..c542e33e 100644 --- a/test/lib/completions/msgsnarf.exp +++ b/test/lib/completions/msgsnarf.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mtx.exp b/test/lib/completions/mtx.exp index a518d79f..1de15269 100644 --- a/test/lib/completions/mtx.exp +++ b/test/lib/completions/mtx.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mutt.exp b/test/lib/completions/mutt.exp index 6c727daf..91eb2457 100644 --- a/test/lib/completions/mutt.exp +++ b/test/lib/completions/mutt.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified {/OLDPWD=/d} -}; # teardown() +} setup diff --git a/test/lib/completions/muttng.exp b/test/lib/completions/muttng.exp index 25a474ad..32239128 100644 --- a/test/lib/completions/muttng.exp +++ b/test/lib/completions/muttng.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mv.exp b/test/lib/completions/mv.exp index f2576df7..d65c4868 100644 --- a/test/lib/completions/mv.exp +++ b/test/lib/completions/mv.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/mysqladmin.exp b/test/lib/completions/mysqladmin.exp index 76381587..ae9b8ce8 100644 --- a/test/lib/completions/mysqladmin.exp +++ b/test/lib/completions/mysqladmin.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ncftp.exp b/test/lib/completions/ncftp.exp index ad71f226..52d70756 100644 --- a/test/lib/completions/ncftp.exp +++ b/test/lib/completions/ncftp.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/netstat.exp b/test/lib/completions/netstat.exp index 0e6414d6..e4ef676c 100644 --- a/test/lib/completions/netstat.exp +++ b/test/lib/completions/netstat.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/newlist.exp b/test/lib/completions/newlist.exp index bebf600d..0696ec5e 100644 --- a/test/lib/completions/newlist.exp +++ b/test/lib/completions/newlist.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/nl.exp b/test/lib/completions/nl.exp index 02076dff..b7255ac2 100644 --- a/test/lib/completions/nl.exp +++ b/test/lib/completions/nl.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/nm.exp b/test/lib/completions/nm.exp index 551f49e9..9ce73d45 100644 --- a/test/lib/completions/nm.exp +++ b/test/lib/completions/nm.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ntpdate.exp b/test/lib/completions/ntpdate.exp index 6a6456f4..7a7dd716 100644 --- a/test/lib/completions/ntpdate.exp +++ b/test/lib/completions/ntpdate.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/objcopy.exp b/test/lib/completions/objcopy.exp index acb6539a..29be7e62 100644 --- a/test/lib/completions/objcopy.exp +++ b/test/lib/completions/objcopy.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/objdump.exp b/test/lib/completions/objdump.exp index 5eec35d6..c1f62e35 100644 --- a/test/lib/completions/objdump.exp +++ b/test/lib/completions/objdump.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/od.exp b/test/lib/completions/od.exp index 5838218c..e2712d12 100644 --- a/test/lib/completions/od.exp +++ b/test/lib/completions/od.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/openssl.exp b/test/lib/completions/openssl.exp index 651e5e6d..25fc1367 100644 --- a/test/lib/completions/openssl.exp +++ b/test/lib/completions/openssl.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -19,7 +19,7 @@ expect { -re "^$cmd\r\n.*$cmd$" { pass "$test" } -re /@ { unresolved "$test at prompt" } -re eof { unresolved "eof" } -}; # expect +} sync_after_int diff --git a/test/lib/completions/p4.exp b/test/lib/completions/p4.exp index 369d2c6b..20d8fb6e 100644 --- a/test/lib/completions/p4.exp +++ b/test/lib/completions/p4.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pack200.exp b/test/lib/completions/pack200.exp index f96eff13..537bf327 100644 --- a/test/lib/completions/pack200.exp +++ b/test/lib/completions/pack200.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/paste.exp b/test/lib/completions/paste.exp index 3a4e93be..224d9dd9 100644 --- a/test/lib/completions/paste.exp +++ b/test/lib/completions/paste.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/patch.exp b/test/lib/completions/patch.exp index a44fa130..07e88f15 100644 --- a/test/lib/completions/patch.exp +++ b/test/lib/completions/patch.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/perl.exp b/test/lib/completions/perl.exp index 2199c994..e02bd454 100644 --- a/test/lib/completions/perl.exp +++ b/test/lib/completions/perl.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/perldoc.exp b/test/lib/completions/perldoc.exp index b3ff83b3..d4461df9 100644 --- a/test/lib/completions/perldoc.exp +++ b/test/lib/completions/perldoc.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -29,7 +29,7 @@ expect { -re "perldoc File::File::" { fail "$test" } -re /@ { unresolved "$test" } default { unresolved "$test" } -}; # expect +} sync_after_int diff --git a/test/lib/completions/pgrep.exp b/test/lib/completions/pgrep.exp new file mode 100644 index 00000000..c27c4f21 --- /dev/null +++ b/test/lib/completions/pgrep.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pgrep " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/pine.exp b/test/lib/completions/pine.exp index 0a0c3f40..622bf064 100644 --- a/test/lib/completions/pine.exp +++ b/test/lib/completions/pine.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ping.exp b/test/lib/completions/ping.exp index b600849b..3e419966 100644 --- a/test/lib/completions/ping.exp +++ b/test/lib/completions/ping.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pkg-config.exp b/test/lib/completions/pkg-config.exp index 477dba08..adf9a301 100644 --- a/test/lib/completions/pkg-config.exp +++ b/test/lib/completions/pkg-config.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pkg_deinstall.exp b/test/lib/completions/pkg_deinstall.exp index 8f3d8c3d..e61d0ce3 100644 --- a/test/lib/completions/pkg_deinstall.exp +++ b/test/lib/completions/pkg_deinstall.exp @@ -1,12 +1,12 @@ proc setup {} { assert_bash_exec {PKG_DBDIR=fixtures/pkgtools/db} save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pkg_delete.exp b/test/lib/completions/pkg_delete.exp index b0c1a2a5..37ce4035 100644 --- a/test/lib/completions/pkg_delete.exp +++ b/test/lib/completions/pkg_delete.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pkg_info.exp b/test/lib/completions/pkg_info.exp index 3f253ccf..ad8ed84e 100644 --- a/test/lib/completions/pkg_info.exp +++ b/test/lib/completions/pkg_info.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pkill.exp b/test/lib/completions/pkill.exp new file mode 100644 index 00000000..6faddfc3 --- /dev/null +++ b/test/lib/completions/pkill.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pkill " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/portinstall.exp b/test/lib/completions/portinstall.exp index d70f5db6..9f44e96b 100644 --- a/test/lib/completions/portinstall.exp +++ b/test/lib/completions/portinstall.exp @@ -1,13 +1,13 @@ proc setup {} { assert_bash_exec {PORTSDIR=fixtures/pkgtools/ports ; sed -e s,PORTSDIR,$PORTSDIR,g $PORTSDIR/INDEX.dist > $PORTSDIR/INDEX ; cp $PORTSDIR/INDEX $PORTSDIR/INDEX-5} save_env -}; # setup() +} proc teardown {} { assert_bash_exec {rm fixtures/pkgtools/ports/INDEX fixtures/pkgtools/ports/INDEX-5} assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/portupgrade.exp b/test/lib/completions/portupgrade.exp index cb583923..62b5789d 100644 --- a/test/lib/completions/portupgrade.exp +++ b/test/lib/completions/portupgrade.exp @@ -1,12 +1,12 @@ proc setup {} { assert_bash_exec {PKG_DBDIR=fixtures/pkgtools/db} save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/povray.exp b/test/lib/completions/povray.exp index 1efeeddb..30d58e48 100644 --- a/test/lib/completions/povray.exp +++ b/test/lib/completions/povray.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pr.exp b/test/lib/completions/pr.exp index 5d7a96c3..478017b2 100644 --- a/test/lib/completions/pr.exp +++ b/test/lib/completions/pr.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/psql.exp b/test/lib/completions/psql.exp index 56d56666..3dbffaf2 100644 --- a/test/lib/completions/psql.exp +++ b/test/lib/completions/psql.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ptx.exp b/test/lib/completions/ptx.exp index 2defe049..220243c3 100644 --- a/test/lib/completions/ptx.exp +++ b/test/lib/completions/ptx.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pvchange.exp b/test/lib/completions/pvchange.exp index fd4b73d0..a43ae9cd 100644 --- a/test/lib/completions/pvchange.exp +++ b/test/lib/completions/pvchange.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pvcreate.exp b/test/lib/completions/pvcreate.exp index 47cebf7a..6bc9d4eb 100644 --- a/test/lib/completions/pvcreate.exp +++ b/test/lib/completions/pvcreate.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pvdisplay.exp b/test/lib/completions/pvdisplay.exp index 151064cd..b9db558b 100644 --- a/test/lib/completions/pvdisplay.exp +++ b/test/lib/completions/pvdisplay.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pvmove.exp b/test/lib/completions/pvmove.exp index 81c05e98..24d17006 100644 --- a/test/lib/completions/pvmove.exp +++ b/test/lib/completions/pvmove.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pvremove.exp b/test/lib/completions/pvremove.exp index dd145bf6..1febcf37 100644 --- a/test/lib/completions/pvremove.exp +++ b/test/lib/completions/pvremove.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pvs.exp b/test/lib/completions/pvs.exp index 6e5527e1..e50501a3 100644 --- a/test/lib/completions/pvs.exp +++ b/test/lib/completions/pvs.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/pvscan.exp b/test/lib/completions/pvscan.exp index e92cdbe0..d3b8ad33 100644 --- a/test/lib/completions/pvscan.exp +++ b/test/lib/completions/pvscan.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/python.exp b/test/lib/completions/python.exp index c9d70b43..57520cdf 100644 --- a/test/lib/completions/python.exp +++ b/test/lib/completions/python.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/qrunner.exp b/test/lib/completions/qrunner.exp index b8fcf191..0dec16cc 100644 --- a/test/lib/completions/qrunner.exp +++ b/test/lib/completions/qrunner.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/querybts.exp b/test/lib/completions/querybts.exp index dc75cd62..4ed09d8a 100644 --- a/test/lib/completions/querybts.exp +++ b/test/lib/completions/querybts.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/rcs.exp b/test/lib/completions/rcs.exp index 19ae4d50..781ac37f 100644 --- a/test/lib/completions/rcs.exp +++ b/test/lib/completions/rcs.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/rcsdiff.exp b/test/lib/completions/rcsdiff.exp index 8383cdb9..23b009c6 100644 --- a/test/lib/completions/rcsdiff.exp +++ b/test/lib/completions/rcsdiff.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/rdict.exp b/test/lib/completions/rdict.exp index aa132617..5d6ad847 100644 --- a/test/lib/completions/rdict.exp +++ b/test/lib/completions/rdict.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/readelf.exp b/test/lib/completions/readelf.exp index a084a41e..c2d5ee5b 100644 --- a/test/lib/completions/readelf.exp +++ b/test/lib/completions/readelf.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/readonly.exp b/test/lib/completions/readonly.exp index 84be3c96..cf64ca0a 100644 --- a/test/lib/completions/readonly.exp +++ b/test/lib/completions/readonly.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/remove_members.exp b/test/lib/completions/remove_members.exp index 63d6a70e..59f7b6c4 100644 --- a/test/lib/completions/remove_members.exp +++ b/test/lib/completions/remove_members.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/removepkg.exp b/test/lib/completions/removepkg.exp index 7cf98805..882f1e70 100644 --- a/test/lib/completions/removepkg.exp +++ b/test/lib/completions/removepkg.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/renice.exp b/test/lib/completions/renice.exp index c91e0212..fdc859b4 100644 --- a/test/lib/completions/renice.exp +++ b/test/lib/completions/renice.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -19,7 +19,7 @@ expect { -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" } -re /@ { unresolved "$test at prompt" } -re eof { unresolved "eof" } -}; # expect +} sync_after_int @@ -33,7 +33,7 @@ expect { -re "$cmd\r\n\\d+.*/@$cmd$" { pass "$test" } -re /@ { unresolved "$test at prompt" } -re eof { unresolved "eof" } -}; # expect +} sync_after_int diff --git a/test/lib/completions/reportbug.exp b/test/lib/completions/reportbug.exp index 1f66df2c..660778f7 100644 --- a/test/lib/completions/reportbug.exp +++ b/test/lib/completions/reportbug.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ri.exp b/test/lib/completions/ri.exp index 160dc9a7..cd138ea0 100644 --- a/test/lib/completions/ri.exp +++ b/test/lib/completions/ri.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/rlog.exp b/test/lib/completions/rlog.exp index cbc06857..87984a8d 100644 --- a/test/lib/completions/rlog.exp +++ b/test/lib/completions/rlog.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/rm.exp b/test/lib/completions/rm.exp index ae670e83..f764a8e7 100644 --- a/test/lib/completions/rm.exp +++ b/test/lib/completions/rm.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/rmdir.exp b/test/lib/completions/rmdir.exp index 2b23a9c5..cc604761 100644 --- a/test/lib/completions/rmdir.exp +++ b/test/lib/completions/rmdir.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/rmlist.exp b/test/lib/completions/rmlist.exp index 91519ee8..d530d117 100644 --- a/test/lib/completions/rmlist.exp +++ b/test/lib/completions/rmlist.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/rpcdebug.exp b/test/lib/completions/rpcdebug.exp index 8629c947..7f1a1c2f 100644 --- a/test/lib/completions/rpcdebug.exp +++ b/test/lib/completions/rpcdebug.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/rpm.exp b/test/lib/completions/rpm.exp index 3ed154a9..82ab28dc 100644 --- a/test/lib/completions/rpm.exp +++ b/test/lib/completions/rpm.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -20,7 +20,7 @@ sync_after_int # Build list of installed packages if {[assert_exec {rpm -qa --qf=%\{NAME\}\n | sort -u} packages]} { assert_complete $packages "rpm -q " -}; # if +} sync_after_int diff --git a/test/lib/completions/rsync.exp b/test/lib/completions/rsync.exp index fb301a35..221d090b 100644 --- a/test/lib/completions/rsync.exp +++ b/test/lib/completions/rsync.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/rtcwake.exp b/test/lib/completions/rtcwake.exp index 0b9a974b..21c05eab 100644 --- a/test/lib/completions/rtcwake.exp +++ b/test/lib/completions/rtcwake.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/sbcl-mt.exp b/test/lib/completions/sbcl-mt.exp index 45e81f79..d328fec3 100644 --- a/test/lib/completions/sbcl-mt.exp +++ b/test/lib/completions/sbcl-mt.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/sbcl.exp b/test/lib/completions/sbcl.exp index b68b2dce..c6f908f6 100644 --- a/test/lib/completions/sbcl.exp +++ b/test/lib/completions/sbcl.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/scp.exp b/test/lib/completions/scp.exp index efe2b686..e1f7336e 100644 --- a/test/lib/completions/scp.exp +++ b/test/lib/completions/scp.exp @@ -1,6 +1,6 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { @@ -9,7 +9,7 @@ proc teardown {} { /BASH_SOURCE=/d /OLDPWD=/d } -}; # teardown() +} setup @@ -31,7 +31,7 @@ if { # in `$HOME/.ssh/config' or `/etc/ssh_config' set host_pwd "" unsupported $test -}; # if +} # Try completion @@ -41,7 +41,7 @@ sync_after_tab expect { -re "^$cmd$host_pwd.*$" { pass "$test" } -re /@ { unresolved "$test at prompt" } -}; # expect +} sync_after_int @@ -56,7 +56,7 @@ set test "Tab should complete known-hosts" set expected {} foreach host [get_hosts] { lappend expected "$host:" -}; # foreach +} lappend expected doo: gee: hus: ike: # Append local filenames lappend expected config known_hosts "spaced\\ \\ conf" @@ -76,7 +76,7 @@ expect { -re "^$cmd\r\n.*\r\n/@" { pass "$test" } -re /@ { unresolved "$test at prompt" } default { unresolved "$test" } -}; # expect +} sync_after_int @@ -88,7 +88,7 @@ set test "Config file containing space should work" set expected {} foreach host [get_hosts] { lappend expected "$host:" -}; # foreach +} # Hosts `gee', `hus' and `jar' are defined in "./fixtures/scp/spaced conf" # Hosts `doo' and `ike' are defined in ./fixtures/scp/known_hosts lappend expected doo: gee: hus: ike: jar: @@ -105,12 +105,12 @@ if {[match_items [lsort -unique $expected] $test]} { expect { -re $prompt { pass "$test" } -re eof { unresolved "eof" } - }; # expect + } } else { # Expected failure (known bug) because of bash-4 bug in quoted words: # http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html if {[lindex $::BASH_VERSINFO 0] >= 4} {xfail "$test"} {fail "$test"} -}; # if +} sync_after_int $prompt assert_bash_exec {cd "$TESTDIR"} diff --git a/test/lib/completions/screen.exp b/test/lib/completions/screen.exp index 985862c1..a1a20138 100644 --- a/test/lib/completions/screen.exp +++ b/test/lib/completions/screen.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified {/OLDPWD=/d} -}; # teardown() +} setup @@ -40,7 +40,7 @@ expect { } -re $prompt { unresolved "$test at prompt" } default { unresolved "$test" } -}; # expect +} sync_after_int $prompt assert_bash_exec {cd "$TESTDIR"} diff --git a/test/lib/completions/sed.exp b/test/lib/completions/sed.exp index 8764cfb8..dd480a60 100644 --- a/test/lib/completions/sed.exp +++ b/test/lib/completions/sed.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {sed --help} "" "" "unsupported"]} { assert_complete_any "sed --" -}; # if +} sync_after_int diff --git a/test/lib/completions/seq.exp b/test/lib/completions/seq.exp index b5333ef9..6e5ef8dc 100644 --- a/test/lib/completions/seq.exp +++ b/test/lib/completions/seq.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/service.exp b/test/lib/completions/service.exp index 917c5dcb..f3cf7355 100644 --- a/test/lib/completions/service.exp +++ b/test/lib/completions/service.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/set.exp b/test/lib/completions/set.exp index 2b2d40e9..c14ecff6 100644 --- a/test/lib/completions/set.exp +++ b/test/lib/completions/set.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/sftp.exp b/test/lib/completions/sftp.exp index 24c37cb5..7a197c7c 100644 --- a/test/lib/completions/sftp.exp +++ b/test/lib/completions/sftp.exp @@ -1,6 +1,6 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { @@ -9,7 +9,7 @@ proc teardown {} { /BASH_SOURCE=/d /OLDPWD=/d } -}; # teardown() +} setup @@ -36,7 +36,7 @@ expect { -re "^$cmd\r\n.*\r\n/@" { pass "$test" } -re /@ { unresolved "$test at prompt" } default { unresolved "$test" } -}; # expect +} sync_after_int @@ -69,7 +69,7 @@ expect { -re "aced conf" { xfail "$test" } -re $prompt { unresolved "$test at prompt" } default { unresolved "$test" } -}; # expect +} sync_after_int $prompt assert_bash_exec {cd "$TESTDIR"} diff --git a/test/lib/completions/sha1sum.exp b/test/lib/completions/sha1sum.exp index 17519087..c5983044 100644 --- a/test/lib/completions/sha1sum.exp +++ b/test/lib/completions/sha1sum.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/shar.exp b/test/lib/completions/shar.exp index 7ace9d6e..604a2031 100644 --- a/test/lib/completions/shar.exp +++ b/test/lib/completions/shar.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/sitecopy.exp b/test/lib/completions/sitecopy.exp index 49b78918..7e0c87fe 100644 --- a/test/lib/completions/sitecopy.exp +++ b/test/lib/completions/sitecopy.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/smartctl.exp b/test/lib/completions/smartctl.exp index a9eeb956..24919396 100644 --- a/test/lib/completions/smartctl.exp +++ b/test/lib/completions/smartctl.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/snownews.exp b/test/lib/completions/snownews.exp index 7502e587..c8ad6741 100644 --- a/test/lib/completions/snownews.exp +++ b/test/lib/completions/snownews.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/sort.exp b/test/lib/completions/sort.exp index 20516cc8..a130bbc8 100644 --- a/test/lib/completions/sort.exp +++ b/test/lib/completions/sort.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/split.exp b/test/lib/completions/split.exp index b74da369..e13df49a 100644 --- a/test/lib/completions/split.exp +++ b/test/lib/completions/split.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {split --help} "" "" "unsupported"]} { assert_complete_any "split --" -}; # if +} sync_after_int diff --git a/test/lib/completions/spovray.exp b/test/lib/completions/spovray.exp index 30d81853..2b2c33de 100644 --- a/test/lib/completions/spovray.exp +++ b/test/lib/completions/spovray.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/sqlite3.exp b/test/lib/completions/sqlite3.exp new file mode 100644 index 00000000..af1ada82 --- /dev/null +++ b/test/lib/completions/sqlite3.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "sqlite3 " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ssh.exp b/test/lib/completions/ssh.exp index 91955c1d..7a511eab 100644 --- a/test/lib/completions/ssh.exp +++ b/test/lib/completions/ssh.exp @@ -1,6 +1,6 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { @@ -9,7 +9,7 @@ proc teardown {} { /BASH_SOURCE=/d /OLDPWD=/d } -}; # teardown() +} setup @@ -27,7 +27,7 @@ expect { -re $expected { pass "$test" } -re $prompt { unresolved "$test at prompt" } default { unresolved "$test" } -}; # expect +} sync_after_int $prompt assert_bash_exec {cd "$TESTDIR"} @@ -45,7 +45,7 @@ expect { -re "^$cmd\r\n.*\r\n/@" { pass "$test" } -re /@ { unresolved "$test at prompt" } default { unresolved "$test" } -}; # expect +} sync_after_int @@ -82,7 +82,7 @@ expect { -re "aced conf" { xfail "$test" } -re $prompt { unresolved "$test at prompt" } default { unresolved "$test" } -}; # expect +} sync_after_int $prompt assert_bash_exec {cd "$TESTDIR"} diff --git a/test/lib/completions/sshmitm.exp b/test/lib/completions/sshmitm.exp index b8f8a2c9..13b50673 100644 --- a/test/lib/completions/sshmitm.exp +++ b/test/lib/completions/sshmitm.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/sshow.exp b/test/lib/completions/sshow.exp index 36a6cc2c..074d7b12 100644 --- a/test/lib/completions/sshow.exp +++ b/test/lib/completions/sshow.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/strace.exp b/test/lib/completions/strace.exp index 55004d20..933d1b48 100644 --- a/test/lib/completions/strace.exp +++ b/test/lib/completions/strace.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/strip.exp b/test/lib/completions/strip.exp index 46d9f362..00f4ab9c 100644 --- a/test/lib/completions/strip.exp +++ b/test/lib/completions/strip.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/sudo.exp b/test/lib/completions/sudo.exp index 1299a6da..e7a39162 100644 --- a/test/lib/completions/sudo.exp +++ b/test/lib/completions/sudo.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/svk.exp b/test/lib/completions/svk.exp index a08674dc..a794a008 100644 --- a/test/lib/completions/svk.exp +++ b/test/lib/completions/svk.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/svn.exp b/test/lib/completions/svn.exp index fe40d6f7..d1a08ae4 100644 --- a/test/lib/completions/svn.exp +++ b/test/lib/completions/svn.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/svnadmin.exp b/test/lib/completions/svnadmin.exp index 35e07021..f20d52cf 100644 --- a/test/lib/completions/svnadmin.exp +++ b/test/lib/completions/svnadmin.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/svnlook.exp b/test/lib/completions/svnlook.exp index 33b67052..114435ec 100644 --- a/test/lib/completions/svnlook.exp +++ b/test/lib/completions/svnlook.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/sync_members.exp b/test/lib/completions/sync_members.exp index 4cb84ad8..817432bb 100644 --- a/test/lib/completions/sync_members.exp +++ b/test/lib/completions/sync_members.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/sysctl.exp b/test/lib/completions/sysctl.exp index e1866f55..d163ea5a 100644 --- a/test/lib/completions/sysctl.exp +++ b/test/lib/completions/sysctl.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {sysctl -N -a 2>/dev/null | grep ^kern | sort -u} values]} { assert_complete $values "sysctl kern" -}; # if +} sync_after_int diff --git a/test/lib/completions/tac.exp b/test/lib/completions/tac.exp index 21230052..d4fe7937 100644 --- a/test/lib/completions/tac.exp +++ b/test/lib/completions/tac.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/tail.exp b/test/lib/completions/tail.exp index c8a82d97..fd685b1a 100644 --- a/test/lib/completions/tail.exp +++ b/test/lib/completions/tail.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {tail --help} "" "" "unsupported"]} { assert_complete_any "tail --" -}; # if +} sync_after_int diff --git a/test/lib/completions/tar.exp b/test/lib/completions/tar.exp index 43c60ff9..37f1ae4b 100644 --- a/test/lib/completions/tar.exp +++ b/test/lib/completions/tar.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/tcpkill.exp b/test/lib/completions/tcpkill.exp index e8cc9c10..d3a45e43 100644 --- a/test/lib/completions/tcpkill.exp +++ b/test/lib/completions/tcpkill.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/tcpnice.exp b/test/lib/completions/tcpnice.exp index 44bb59c6..b4b93097 100644 --- a/test/lib/completions/tcpnice.exp +++ b/test/lib/completions/tcpnice.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/tee.exp b/test/lib/completions/tee.exp index c25057ba..1058bb8e 100644 --- a/test/lib/completions/tee.exp +++ b/test/lib/completions/tee.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/texindex.exp b/test/lib/completions/texindex.exp index d5b8cd77..43b4c09a 100644 --- a/test/lib/completions/texindex.exp +++ b/test/lib/completions/texindex.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/tightvncviewer.exp b/test/lib/completions/tightvncviewer.exp index 6eba24c2..ee987f60 100644 --- a/test/lib/completions/tightvncviewer.exp +++ b/test/lib/completions/tightvncviewer.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/time.exp b/test/lib/completions/time.exp index b114318b..3bed4fdf 100644 --- a/test/lib/completions/time.exp +++ b/test/lib/completions/time.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/touch.exp b/test/lib/completions/touch.exp index f0960ef7..61d22b33 100644 --- a/test/lib/completions/touch.exp +++ b/test/lib/completions/touch.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {touch --help} "" "" "unsupported"]} { assert_complete_any "touch --" -}; # if +} sync_after_int diff --git a/test/lib/completions/tr.exp b/test/lib/completions/tr.exp index 68b11a36..c10c8ba1 100644 --- a/test/lib/completions/tr.exp +++ b/test/lib/completions/tr.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {tr --help} "" "" "unsupported"]} { assert_complete_any "tr --" -}; # if +} sync_after_int diff --git a/test/lib/completions/unace.exp b/test/lib/completions/unace.exp index 0afbaafb..c9d7606e 100644 --- a/test/lib/completions/unace.exp +++ b/test/lib/completions/unace.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/uname.exp b/test/lib/completions/uname.exp index 2179dafd..0c363ab5 100644 --- a/test/lib/completions/uname.exp +++ b/test/lib/completions/uname.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {uname --help} "" "" "unsupported"]} { assert_complete_any "uname --" -}; # if +} sync_after_int diff --git a/test/lib/completions/unexpand.exp b/test/lib/completions/unexpand.exp index 31822561..c9aecc25 100644 --- a/test/lib/completions/unexpand.exp +++ b/test/lib/completions/unexpand.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {unexpand --help} "" "" "unsupported"]} { assert_complete_any "unexpand --" -}; # if +} sync_after_int diff --git a/test/lib/completions/uniq.exp b/test/lib/completions/uniq.exp index 20dbcfac..d516106c 100644 --- a/test/lib/completions/uniq.exp +++ b/test/lib/completions/uniq.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {uniq --help} "" "" "unsupported"]} { assert_complete_any "uniq --" -}; # if +} sync_after_int diff --git a/test/lib/completions/units.exp b/test/lib/completions/units.exp index a40b5f3f..96ec91d1 100644 --- a/test/lib/completions/units.exp +++ b/test/lib/completions/units.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {units --help} "" "" "unsupported"]} { assert_complete_any "units --" -}; # if +} sync_after_int diff --git a/test/lib/completions/unpack200.exp b/test/lib/completions/unpack200.exp index 845701dd..b4360491 100644 --- a/test/lib/completions/unpack200.exp +++ b/test/lib/completions/unpack200.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/unrar.exp b/test/lib/completions/unrar.exp index e66e3c8b..b5e27b21 100644 --- a/test/lib/completions/unrar.exp +++ b/test/lib/completions/unrar.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/unset.exp b/test/lib/completions/unset.exp index a5e7fc9b..42e753cb 100644 --- a/test/lib/completions/unset.exp +++ b/test/lib/completions/unset.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/unshunt.exp b/test/lib/completions/unshunt.exp index 964cac68..96cd5860 100644 --- a/test/lib/completions/unshunt.exp +++ b/test/lib/completions/unshunt.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/update-alternatives.exp b/test/lib/completions/update-alternatives.exp index 10ff4e6d..b94d88c5 100644 --- a/test/lib/completions/update-alternatives.exp +++ b/test/lib/completions/update-alternatives.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/update-rc.d.exp b/test/lib/completions/update-rc.d.exp index 9c2c2464..f2eafea5 100644 --- a/test/lib/completions/update-rc.d.exp +++ b/test/lib/completions/update-rc.d.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/urlsnarf.exp b/test/lib/completions/urlsnarf.exp index c5b26922..ed543629 100644 --- a/test/lib/completions/urlsnarf.exp +++ b/test/lib/completions/urlsnarf.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vdir.exp b/test/lib/completions/vdir.exp index b525c382..c0e5ee43 100644 --- a/test/lib/completions/vdir.exp +++ b/test/lib/completions/vdir.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgcfgbackup.exp b/test/lib/completions/vgcfgbackup.exp index 19ceeeca..b7e509a2 100644 --- a/test/lib/completions/vgcfgbackup.exp +++ b/test/lib/completions/vgcfgbackup.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgcfgrestore.exp b/test/lib/completions/vgcfgrestore.exp index e1c3c3b9..e40cd213 100644 --- a/test/lib/completions/vgcfgrestore.exp +++ b/test/lib/completions/vgcfgrestore.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgchange.exp b/test/lib/completions/vgchange.exp index 645eedb4..b6c0e1df 100644 --- a/test/lib/completions/vgchange.exp +++ b/test/lib/completions/vgchange.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgck.exp b/test/lib/completions/vgck.exp index 67209b15..b4d58aec 100644 --- a/test/lib/completions/vgck.exp +++ b/test/lib/completions/vgck.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgconvert.exp b/test/lib/completions/vgconvert.exp index 065c4828..362c44b6 100644 --- a/test/lib/completions/vgconvert.exp +++ b/test/lib/completions/vgconvert.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgcreate.exp b/test/lib/completions/vgcreate.exp index 7c324e62..4cb7dd45 100644 --- a/test/lib/completions/vgcreate.exp +++ b/test/lib/completions/vgcreate.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgdisplay.exp b/test/lib/completions/vgdisplay.exp index b6bc9125..6a8ed84d 100644 --- a/test/lib/completions/vgdisplay.exp +++ b/test/lib/completions/vgdisplay.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgexport.exp b/test/lib/completions/vgexport.exp index 2ad4230e..2900960f 100644 --- a/test/lib/completions/vgexport.exp +++ b/test/lib/completions/vgexport.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgextend.exp b/test/lib/completions/vgextend.exp index 18a491d2..3c46a8f0 100644 --- a/test/lib/completions/vgextend.exp +++ b/test/lib/completions/vgextend.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgimport.exp b/test/lib/completions/vgimport.exp index e4568f3b..ed04e282 100644 --- a/test/lib/completions/vgimport.exp +++ b/test/lib/completions/vgimport.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgmerge.exp b/test/lib/completions/vgmerge.exp index 8ba5e893..a4f8833b 100644 --- a/test/lib/completions/vgmerge.exp +++ b/test/lib/completions/vgmerge.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgmknodes.exp b/test/lib/completions/vgmknodes.exp index d24552f0..5c9feeb3 100644 --- a/test/lib/completions/vgmknodes.exp +++ b/test/lib/completions/vgmknodes.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgreduce.exp b/test/lib/completions/vgreduce.exp index 887ba8de..f6af3150 100644 --- a/test/lib/completions/vgreduce.exp +++ b/test/lib/completions/vgreduce.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgremove.exp b/test/lib/completions/vgremove.exp index 26dadf95..0dc5eda8 100644 --- a/test/lib/completions/vgremove.exp +++ b/test/lib/completions/vgremove.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgrename.exp b/test/lib/completions/vgrename.exp index 8ddaa758..81438631 100644 --- a/test/lib/completions/vgrename.exp +++ b/test/lib/completions/vgrename.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgs.exp b/test/lib/completions/vgs.exp index a27e3650..22ab176b 100644 --- a/test/lib/completions/vgs.exp +++ b/test/lib/completions/vgs.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgscan.exp b/test/lib/completions/vgscan.exp index 4bb8c35e..ae8168c8 100644 --- a/test/lib/completions/vgscan.exp +++ b/test/lib/completions/vgscan.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vgsplit.exp b/test/lib/completions/vgsplit.exp index 54e7034f..b183cfda 100644 --- a/test/lib/completions/vgsplit.exp +++ b/test/lib/completions/vgsplit.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/vncviewer.exp b/test/lib/completions/vncviewer.exp index 3d47f49f..8c51e0b2 100644 --- a/test/lib/completions/vncviewer.exp +++ b/test/lib/completions/vncviewer.exp @@ -1,13 +1,13 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified { /declare -f _vncviewer_bootstrap/d } -}; # teardown() +} setup diff --git a/test/lib/completions/wc.exp b/test/lib/completions/wc.exp index 8ad2bf8d..b261b6a7 100644 --- a/test/lib/completions/wc.exp +++ b/test/lib/completions/wc.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {wc --help} "" "" "unsupported"]} { assert_complete_any "wc --" -}; # if +} sync_after_int diff --git a/test/lib/completions/webmitm.exp b/test/lib/completions/webmitm.exp index 1d48a3a6..adb97cc2 100644 --- a/test/lib/completions/webmitm.exp +++ b/test/lib/completions/webmitm.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/wget.exp b/test/lib/completions/wget.exp index 245b27be..8e830a12 100644 --- a/test/lib/completions/wget.exp +++ b/test/lib/completions/wget.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/who.exp b/test/lib/completions/who.exp index 73928ef7..6cca6795 100644 --- a/test/lib/completions/who.exp +++ b/test/lib/completions/who.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -13,7 +13,7 @@ setup if {[assert_exec {who --help} "" "" "unsupported"]} { assert_complete_any "who --" -}; # if +} sync_after_int diff --git a/test/lib/completions/withlist.exp b/test/lib/completions/withlist.exp index 6310466d..e1f91f6a 100644 --- a/test/lib/completions/withlist.exp +++ b/test/lib/completions/withlist.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/wol.exp b/test/lib/completions/wol.exp index 84a2d88d..a06a2ae9 100644 --- a/test/lib/completions/wol.exp +++ b/test/lib/completions/wol.exp @@ -2,13 +2,13 @@ proc setup {} { # See fixtures/shared/bin/{arp,ifconfig} assert_bash_exec {OLDPATH="$PATH"; PATH="$TESTDIR/fixtures/shared/bin:$PATH";} save_env -}; # setup() +} proc teardown {} { assert_env_unmodified assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH} -}; # teardown() +} setup diff --git a/test/lib/completions/wtf.exp b/test/lib/completions/wtf.exp index 8250becc..b1693c80 100644 --- a/test/lib/completions/wtf.exp +++ b/test/lib/completions/wtf.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/wvdial.exp b/test/lib/completions/wvdial.exp index 8d4669de..5b52daa8 100644 --- a/test/lib/completions/wvdial.exp +++ b/test/lib/completions/wvdial.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/xhost.exp b/test/lib/completions/xhost.exp index aeceadb6..d4098ade 100644 --- a/test/lib/completions/xhost.exp +++ b/test/lib/completions/xhost.exp @@ -1,12 +1,12 @@ proc setup {} { assert_bash_exec {HOME=$TESTDIR} save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup @@ -17,7 +17,7 @@ set test "Tab should complete hostnames" set hosts {} foreach h [exec bash -c "compgen -A hostname"] { lappend hosts $h -}; # foreach +} assert_complete $hosts "xhost " $test @@ -33,8 +33,8 @@ foreach h [exec bash -c "compgen -A hostname"] { # Only append hostname if starting with $char if {[string range $h 0 0] == "$char"} { lappend hosts $h - }; # if -}; # foreach + } +} assert_complete $hosts "xhost $char" $test @@ -46,7 +46,7 @@ set test "Tab should complete hostnames prefixed with +" set hosts {} foreach h [exec bash -c "compgen -A hostname"] { lappend hosts "+$h" -}; # foreach +} assert_complete $hosts "xhost \+" $test @@ -61,8 +61,8 @@ foreach h [exec bash -c "compgen -A hostname"] { # Only append hostname if starting with $char if {[string range $h 0 0] == "$char"} { lappend hosts "+$h" - }; # if -}; # foreach + } +} assert_complete $hosts "xhost +$char" @@ -74,7 +74,7 @@ set test "Tab should complete hostnames prefixed with -" set hosts {} foreach h [exec bash -c "compgen -A hostname"] { lappend hosts "-$h" -}; # foreach +} assert_complete $hosts "xhost -" $test @@ -89,8 +89,8 @@ foreach h [exec bash -c "compgen -A hostname"] { # Only append hostname if starting with $char if {[string range $h 0 0] == "$char"} { lappend hosts "-$h" - }; # if -}; # foreach + } +} assert_complete $hosts "xhost -$char" $test diff --git a/test/lib/completions/xmllint.exp b/test/lib/completions/xmllint.exp index 15451471..20daab6d 100644 --- a/test/lib/completions/xmllint.exp +++ b/test/lib/completions/xmllint.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/xmlwf.exp b/test/lib/completions/xmlwf.exp index a996d458..6c306f34 100644 --- a/test/lib/completions/xmlwf.exp +++ b/test/lib/completions/xmlwf.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/xmms.exp b/test/lib/completions/xmms.exp index c4ad64e8..1f1f6d57 100644 --- a/test/lib/completions/xmms.exp +++ b/test/lib/completions/xmms.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/xpovray.exp b/test/lib/completions/xpovray.exp index 92cc903d..53a5fcd0 100644 --- a/test/lib/completions/xpovray.exp +++ b/test/lib/completions/xpovray.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/xrandr.exp b/test/lib/completions/xrandr.exp index 649ed43b..14beb762 100644 --- a/test/lib/completions/xrandr.exp +++ b/test/lib/completions/xrandr.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/xsltproc.exp b/test/lib/completions/xsltproc.exp index 2470c22e..2c558ff1 100644 --- a/test/lib/completions/xsltproc.exp +++ b/test/lib/completions/xsltproc.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/xvnc4viewer.exp b/test/lib/completions/xvnc4viewer.exp index 3456c3e7..b10e272c 100644 --- a/test/lib/completions/xvnc4viewer.exp +++ b/test/lib/completions/xvnc4viewer.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/xz.exp b/test/lib/completions/xz.exp index 820b0689..83b1f350 100644 --- a/test/lib/completions/xz.exp +++ b/test/lib/completions/xz.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ypcat.exp b/test/lib/completions/ypcat.exp index f1bd0c0e..a8249dc2 100644 --- a/test/lib/completions/ypcat.exp +++ b/test/lib/completions/ypcat.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/ypmatch.exp b/test/lib/completions/ypmatch.exp index f1695f67..ac264c18 100644 --- a/test/lib/completions/ypmatch.exp +++ b/test/lib/completions/ypmatch.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/yum-arch.exp b/test/lib/completions/yum-arch.exp index defb7bf4..85c47c22 100644 --- a/test/lib/completions/yum-arch.exp +++ b/test/lib/completions/yum-arch.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/completions/yum.exp b/test/lib/completions/yum.exp index 09d7282c..899ecddb 100644 --- a/test/lib/completions/yum.exp +++ b/test/lib/completions/yum.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified -}; # teardown() +} setup diff --git a/test/lib/library.exp b/test/lib/library.exp index c76d9854..a79ec526 100644 --- a/test/lib/library.exp +++ b/test/lib/library.exp @@ -22,7 +22,7 @@ proc assert_bash_exec {{aCmd ""} {title ""} {prompt /@} {out -1}} { if {[string length $aCmd] != 0} { send "$aCmd\r" expect -ex "$aCmd\r\n" - }; # if + } if {[string length $title] == 0} {set title $aCmd} expect -ex $prompt set results $expect_out(buffer); # Catch output @@ -35,9 +35,9 @@ proc assert_bash_exec {{aCmd ""} {title ""} {prompt /@} {out -1}} { if {$out == -1 && [string length $results] > 0} { if {[info exists multipass_name]} { fail "ERROR Unexpected output from bash command \"$title\"" - }; # if + } send_user "ERROR Unexpected output from bash command \"$title\":\n$results" - }; # if + } set cmd "echo $?" send "$cmd\r" @@ -46,11 +46,11 @@ proc assert_bash_exec {{aCmd ""} {title ""} {prompt /@} {out -1}} { $prompt { if {[info exists multipass_name]} { fail "ERROR executing bash command \"$title\"" - }; # if + } send_user "ERROR executing bash command \"$title\"" } - }; # expect -}; # assert_bash_exec() + } +} # Test `type ...' in bash @@ -64,10 +64,10 @@ proc assert_bash_type {command} { expect { -ex 0 { set result true } -ex 1 { set result false; unsupported "$test" } - }; # expect + } expect "/@" return $result -}; # assert_bash_type() +} # Make sure the expected list is returned by executing the specified command. @@ -103,7 +103,7 @@ proc assert_bash_list_dir {expected cmd dir {test ""} {prompt /@} {size 20}} { assert_bash_list $expected $cmd $test $prompt $size sync_after_int $prompt assert_bash_exec {cd "$TESTDIR"} -}; # assert_bash_list_dir() +} # Make sure the expected items are returned by TAB-completing the specified @@ -140,23 +140,23 @@ proc assert_complete {expected cmd {test ""} {prompt /@} {size 20} {cword ""} {f # Assume last word of `$cmd' is word to complete on. set index [expr [llength $words] - 1] set cur [lindex $words $index] - }; # if + } # Remove second word from beginning of single item $expected if {[string first $cur $expected] == 0} { set expected [list [string range $expected [string length $cur] end]] - }; # if - }; # if + } + } } else { expect -ex "$cmd\r\n" # Make sure expected items are unique set expected [lsort -unique $expected] - }; # if + } if {[lsearch -exact $filters "ltrim_colon_completions"] != -1} { # If partial contains colon (:), remove partial from begin of items # See also: bash_completion.__ltrim_colon_completions() _ltrim_colon_completions cword expected - }; # if + } if {[match_items $expected $test $prompt $size]} { if {[llength $expected] == 1} { @@ -169,7 +169,7 @@ proc assert_complete {expected cmd {test ""} {prompt /@} {size 20} {cword ""} {f set cmd2 $cmd } else { set cmd2 [_remove_cword_from_cmd $cmd $cword] - }; # if + } # Determine common prefix of completions set common [::textutil::string::longestCommonPrefixList $expected] @@ -178,13 +178,13 @@ proc assert_complete {expected cmd {test ""} {prompt /@} {size 20} {cword ""} {f -ex "$prompt$cmd2$common" { pass "$test" } -re $prompt { unresolved "$test at prompt" } -re eof { unresolved "eof" } - }; # expect - }; # if + } + } } else { fail "$test" - }; # if - }; # if -}; # assert_complete() + } + } +} # @param string $cmd Command to remove cword from @@ -203,7 +203,7 @@ proc _remove_cword_from_cmd {cmd {cword ""}} { # Remove $cword from end of $cmd if {[string last $cword $cmd] == [string length $cmd] - [string length $cword]} { set cmd2 [string range $cmd 0 [expr [string last $cword $cmd] - 1]] - }; # if + } } else { # No, $cword not specified; # Check if last argument is really an-argument-to-complete, i.e. @@ -217,10 +217,10 @@ proc _remove_cword_from_cmd {cmd {cword ""}} { # Remove argument-to-complete from end of $cmd set cmd2 [lrange [split $cmd] 0 end-1] append cmd2 " " - }; # if - }; # if + } + } return $cmd2 -}; # _remove_cword_from_cmd() +} # Escape regexp special characters @@ -253,8 +253,8 @@ proc assert_complete_any {cmd {test ""} {prompt /@}} { } -re $prompt { unresolved "$test at prompt" } eof { unresolved "eof" } - }; # expect -}; # assert_complete_any() + } +} # Make sure the expected files are returned by TAB-completing the @@ -273,7 +273,7 @@ proc assert_complete_dir {expected cmd dir {test ""} {size 20} {cword ""}} { assert_complete $expected $cmd $test $prompt $size $cword sync_after_int $prompt assert_bash_exec {cd "$TESTDIR"} -}; # assert_complete_dir +} @@ -304,11 +304,11 @@ proc assert_complete_partial {expected cmd {partial ""} {test ""} {prompt /@} {s # Only append item if starting with $partial if {[string range $item 0 [expr [string length $partial] - 1]] == "$partial"} { lappend pick $item - }; # if - }; # foreach + } + } assert_complete $pick "$cmd $partial" $test $prompt $size $partial $filters - }; # if -}; # assert_complete_partial() + } +} # See also: bash_completion._ltrim_colon_completions @@ -329,11 +329,11 @@ proc _ltrim_colon_completions {cword items} { if {[string first $cword_out $item] == 0} { # Strip colon-prefix lset items_out $i [string range $item [string length $cword_out] end] - }; # if - }; # for + } + } #set cword_out "" - }; # if -}; # _ltrim_colon_completions() + } +} # Make sure the bash environment hasn't changed between now and the last call @@ -370,7 +370,7 @@ proc assert_env_unmodified {{sed ""} {file ""} {diff ""}} { append diff "\r\n" } else { set diff "" - }; # if + } # Execute diff @@ -392,11 +392,11 @@ proc assert_env_unmodified {{sed ""} {file ""} {diff ""}} { # Remove possible `\r\n[wd]@' from end of diff if {[string last "\r\n[wd]@" $diff] == [string length $diff] - [string length "\r\n[wd]@"]} { set diff [string range $diff 0 [expr [string last "\r\n[wd]@" $diff] - 1]] - }; # if + } send_user $diff; } - }; # expect -}; # assert_env_unmodified() + } +} # Make sure the specified command executed from within Tcl/Expect. @@ -426,10 +426,10 @@ proc assert_exec {cmd {stdout ''} {test ''} {failcmd "unresolved"}} { unsupported "$test" } else { $failcmd "$test" - }; # if - }; # if + } + } return $result -}; # assert_exec() +} # Check that no completion is attempted on a certain command. @@ -439,7 +439,7 @@ proc assert_exec {cmd {stdout ''} {test ''} {failcmd "unresolved"}} { proc assert_no_complete {{cmd} {test ""}} { if {[string length $test] == 0} { set test "$cmd shouldn't complete" - }; # if + } send "$cmd\t" expect -ex "$cmd" @@ -451,8 +451,8 @@ proc assert_no_complete {{cmd} {test ""}} { -re "^$endguard$" { pass "$test" } default { fail "$test" } timeout { fail "$test" } - }; # expect -}; # assert_no_complete() + } +} # Check that no output is generated on a certain command. @@ -510,7 +510,7 @@ proc get_known_hosts {{cword ''}} { assert_bash_exec "_known_hosts_real '$cword'; echo_array COMPREPLY" \ {} /@ result return $result -}; # get_known_hosts() +} # Get hostnames @@ -524,9 +524,9 @@ proc get_hosts {} { set avahi_hosts [get_hosts_avahi] if {[llength $avahi_hosts] > 0} { lappend hosts $avahi_hosts - }; # if + } return $hosts -}; # get_hosts() +} # Get hostnames according to avahi @@ -540,9 +540,9 @@ proc get_hosts_avahi {} { # No, retrieving hosts yields error; # Reset hosts set hosts {} - }; # if + } return $hosts -}; # get_hosts_avahi() +} # Get signals @@ -558,10 +558,10 @@ proc get_signals {} { set signal [string range $signal 3 end] # Add signal (with dash (-) prefix) to list lappend signals -$signal - }; # if - }; # foreach + } + } return $signals -}; # get_signals() +} # Initialize tcl globals with bash variables @@ -572,7 +572,7 @@ proc init_tcl_bash_globals {} { set BASH_VERSINFO [eval list $BASH_VERSINFO] assert_bash_exec {printf "%s" "$BASH_VERSION"} "" /@ BASH_VERSION assert_bash_exec {printf "%s" "$TESTDIR"} "" /@ TESTDIR -}; # init_tcl_bash_globals() +} # Check whether completion is installed for the specified command by executing @@ -590,13 +590,13 @@ proc is_bash_completion_installed_for {command} { } expect "/@" return $result -}; # is_bash_completion_installed_for() +} # Detect if test suite is running under Cygwin/Windows proc is_cygwin {} { expr {[string first [string tolower [exec uname -s]] cygwin] >= 0} -}; # is_cygwin() +} # Expect items. @@ -615,7 +615,7 @@ proc match_items {items test {prompt /@} {size 20}} { _escape_regexp_chars item append expected $item if {[llength $items] > 1} {append expected {\s+}}; - }; # for + } if {[llength $items] == 1} { expect { -re "^$expected\r\n$" { set result true } @@ -625,17 +625,17 @@ proc match_items {items test {prompt /@} {size 20}} { "\r\n" { set result false; break } default { set result false; break } timeout { set result false; break } - }; # expect + } } else { expect { -re "^$expected" { set result true } default { set result false; break } timeout { set result false; break } - }; # expect - }; # if - }; # for + } + } + } return $result -}; # match_items() +} @@ -651,10 +651,10 @@ proc realcommand {cmd} { set result [exec readlink -f $path] } else { set result $path - }; # if - }; # if + } + } return $result -}; # realcommand() +} # Generate filename to save environment to. @@ -674,10 +674,10 @@ proc gen_env_filename {{file ""} {seq 1}} { # Remove possible '.exp' suffix from filename if {[string last ".exp" $file] == [string length $file] - [string length ".exp"]} { set file [string range $file 0 [expr [string last ".exp" $file] - 1]] - }; # if - }; # if + } + } return "\$TESTDIR/tmp/$file.env$seq~" -}; # gen_env_filename() +} # Save the environment for later comparison @@ -685,7 +685,7 @@ proc gen_env_filename {{file ""} {seq 1}} { # `gen_env_filename()'. proc save_env {{file ""}} { _save_env [gen_env_filename $file 1] -}; # save_env() +} # Save the environment for later comparison @@ -693,7 +693,7 @@ proc save_env {{file ""}} { # @see assert_env_unmodified() proc _save_env {{file ""}} { assert_bash_exec "{ set; declare -F; shopt -p; } > \"$file\"" -}; # _save_env() +} # Source bash_completion package @@ -702,7 +702,7 @@ proc source_bash_completion {} { assert_bash_exec {BASH_COMPLETION_COMPAT_DIR=$BASH_COMPLETION_DIR} assert_bash_exec {BASH_COMPLETION=$(cd "$TESTDIR/.."; pwd)/bash_completion} assert_bash_exec {source "$BASH_COMPLETION"} -}; # source_bash_completion() +} # Split line into words, disregarding backslash escapes (e.g. \b (backspace), @@ -727,7 +727,7 @@ proc split_words_bash {line} { set part [string range $part 0 [expr [string length $part] - [string length "\\"] - 1]] # Indicate glue on next run set glue_next true - }; # if + } # Must `part' be appended to latest word (= glue)? if {[llength $words] > 0 && [string is true $glue]} { # Yes, join `part' to latest word; @@ -738,11 +738,11 @@ proc split_words_bash {line} { # No, don't append word to latest word; # Append `part' as separate word lappend words $part - }; # if + } set glue $glue_next - }; # foreach + } return $words -}; # split_words_bash() +} # Given a list of items this proc finds a (part, full) pair so that when @@ -826,7 +826,7 @@ proc start_bash {} { # for bash < 3.2.41. # -- FVu, Tue Sep 15 22:52:00 CEST 2009 assert_bash_exec {is_bash_version_minimal 3 2 41 || set +o history} -}; # start_bash() +} # Redirect xtrace output to a file. @@ -896,7 +896,7 @@ proc sync_after_tab {} { # installed, so that "^$cdm.*$" doesn't match too early - before # comp_install has finished sleep .4 -}; # sync_after_tab() +} # Return current working directory with `TESTDIR' stripped @@ -905,4 +905,4 @@ proc wd {} { global TESTDIR # Remove `$TESTDIR' prefix from current working directory set wd [string replace [pwd] 0 [expr [string length $TESTDIR] - 1]]/ -}; # wd() +} diff --git a/test/run b/test/run index b798676f..498d98b7 100755 --- a/test/run +++ b/test/run @@ -44,7 +44,7 @@ while [[ $# > 0 ]]; do --timeout=*) timeout=${1/--timeout=};; --tool=*) set_tool "${1#/--tool=}";; --tool) shift; set_tool "$1";; - */completion/*.exp|*/unit/*.exp) + completion/*.exp|*/completion/*.exp|unit/*.exp|*/unit/*.exp) arg=${1%/*} set_tool "${arg##*/}" args+=("${1##*/}") diff --git a/test/unit/__expand_tilde_by_ref.exp b/test/unit/__expand_tilde_by_ref.exp index d4a75d11..000d3516 100644 --- a/test/unit/__expand_tilde_by_ref.exp +++ b/test/unit/__expand_tilde_by_ref.exp @@ -8,14 +8,14 @@ proc setup {home user} { set _home [string trim $_home] assert_bash_exec {echo "$USER"} {} /@ _user set _user [string trim $_user] -}; # setup() +} proc teardown {} { assert_env_unmodified { /var=/d } -}; # teardown() +} setup home user diff --git a/test/unit/_count_args.exp b/test/unit/_count_args.exp index da61bdb6..a1419481 100644 --- a/test/unit/_count_args.exp +++ b/test/unit/_count_args.exp @@ -1,7 +1,7 @@ proc setup {} { assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS} save_env -}; # setup() +} proc teardown {} { @@ -12,7 +12,7 @@ proc teardown {} { d } } -}; # teardown() +} setup diff --git a/test/unit/_get_comp_words_by_ref.exp b/test/unit/_get_comp_words_by_ref.exp index 67862b3a..c88ad6f6 100644 --- a/test/unit/_get_comp_words_by_ref.exp +++ b/test/unit/_get_comp_words_by_ref.exp @@ -1,18 +1,21 @@ proc setup {} { assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS} save_env -}; # setup() +} proc teardown {} { - assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS cur prev prev2} + assert_bash_exec { \ + unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS cur prev words cword \ + cur2 prev2 words2 cword2 \ + } # Delete 'COMP_WORDBREAKS' occupying two lines assert_env_unmodified { /COMP_WORDBREAKS=/{N d } } -}; # teardown() +} setup @@ -46,8 +49,8 @@ sync_after_int set test "a b |"; # | = cursor position -set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_comp_words_by_ref cur prev prev2; echo "$cur $prev $prev2"} -assert_bash_list {" b a"} $cmd $test +set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_comp_words_by_ref cur prev; echo "$cur $prev"} +assert_bash_list {" b"} $cmd $test sync_after_int @@ -102,7 +105,7 @@ if { set cmd {COMP_WORDS=(a "'" b c); COMP_CWORD=3} } else { set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1} -}; # if +} append cmd {; COMP_LINE="a 'b c"; COMP_POINT=6; _get_comp_words_by_ref cur prev; echo "$cur $prev"} send "$cmd\r" expect -ex "$cmd\r\n" @@ -115,7 +118,7 @@ expect { [lindex $::BASH_VERSINFO 2] < 35 } {xfail "$test"} {fail "$test"} } -}; # expect +} sync_after_int @@ -130,7 +133,7 @@ if { set cmd {COMP_WORDS=(a "\"" b c); COMP_CWORD=3} } else { set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1} -}; # if +} append cmd {; COMP_LINE="a \"b c"; COMP_POINT=6} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref cur prev; echo "$cur $prev"}; @@ -145,7 +148,7 @@ expect { [lindex $::BASH_VERSINFO 2] < 35 } {xfail "$test"} {fail "$test"} } -}; # expect +} sync_after_int @@ -158,7 +161,7 @@ if {[lindex $::BASH_VERSINFO 0] <= 3} { } else { set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3} set expected {"c :"} -}; # if +} append cmd {; COMP_LINE='a b:c'; COMP_POINT=5} # NOTE: Split-send cmd to prevent backspaces (\008) in output assert_bash_exec $cmd $test @@ -174,7 +177,7 @@ if {[lindex $::BASH_VERSINFO 0] <= 3} { set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1} } else { set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} -}; # if +} append cmd {; COMP_LINE='a b:c'; COMP_POINT=5} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"} @@ -189,11 +192,11 @@ if {[lindex $::BASH_VERSINFO 0] <= 3} { set cmd {COMP_WORDS=(a b c:); COMP_CWORD=2} } else { set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3} -}; # if +} append cmd {; COMP_LINE='a b c:'; COMP_POINT=6} assert_bash_exec $cmd $test -set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev $prev2"} -assert_bash_list {"c: b a"} $cmd $test +set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"} +assert_bash_list {"c: b"} $cmd $test sync_after_int @@ -214,7 +217,7 @@ if {[lindex $::BASH_VERSINFO 0] <= 3} { set cmd {COMP_WORDS=(a "b::"); COMP_CWORD=1} } else { set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2} -}; # if +} append cmd {; COMP_LINE='a b::'; COMP_POINT=5} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"} @@ -253,7 +256,7 @@ if {[lindex $::BASH_VERSINFO] <= 3} { } else { set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3} set expected c -}; # if +} append cmd {; COMP_LINE='a b=c'; COMP_POINT=5} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref cur prev; echo "$cur"} @@ -283,7 +286,7 @@ expect { -ex "\$(b c/@" { pass "$test" } # Expected failure on bash-4 -ex "c/@" { xfail "$test" } -}; # expect +} sync_after_int @@ -300,7 +303,7 @@ expect { -ex "\$(b c\\ d/@" { pass "$test" } # Expected failure on bash-4 -ex "c\\ d/@" { xfail "$test" } -}; # expect +} sync_after_int @@ -315,7 +318,7 @@ if { set cmd {COMP_WORDS=(a "'" b "&" c); COMP_CWORD=4} } else { set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1} -}; # if +} append cmd {; COMP_LINE="a 'b&c"; COMP_POINT=6} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref cur prev; printf %s "$cur"} @@ -330,7 +333,51 @@ expect { [lindex $::BASH_VERSINFO 2] < 35 } {xfail "$test"} {fail "$test"} } -}; # expect +} + + +sync_after_int + + +set test {unknown argument should raise error} +set cmd {_get_comp_words_by_ref dummy} +assert_bash_list {"bash: _get_comp_words_by_ref(): `dummy': unknown argument"} $cmd $test + + +sync_after_int + + +set test "a b| to all vars"; # | = cursor position +set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3} +assert_bash_exec $cmd +set cmd { \ + _get_comp_words_by_ref words cword prev cur; echo "${words[@]} $cword $cur $prev" \ +} +assert_bash_list {"a b 1 b a"} $cmd $test + + +sync_after_int + + +set test "a b| to alternate vars"; # | = cursor position +set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3;} +assert_bash_exec $cmd +set cmd {_get_comp_words_by_ref -c cur2 -p prev2 -w words2 -i cword2} +assert_bash_exec $cmd +set cmd {echo "$cur2 $prev2 ${words2[@]} $cword2"} +assert_bash_list {"b a a b 1"} $cmd $test + + +sync_after_int + + +set test "a b| to alternate vars"; # | = cursor position +set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3;} +assert_bash_exec $cmd +set cmd {_get_comp_words_by_ref -c cur2 -p prev2 -w words2 -i cword2} +assert_bash_exec $cmd +set cmd {echo "$cur2 $prev2 ${words2[@]} $cword2"} +assert_bash_list {"b a a b 1"} $cmd $test sync_after_int diff --git a/test/unit/_get_cword.exp b/test/unit/_get_cword.exp index 1e6e9bfb..c3fbe2ae 100644 --- a/test/unit/_get_cword.exp +++ b/test/unit/_get_cword.exp @@ -1,7 +1,7 @@ proc setup {} { assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS} save_env -}; # setup() +} proc teardown {} { @@ -12,7 +12,7 @@ proc teardown {} { d } } -}; # teardown() +} setup @@ -105,7 +105,7 @@ if { set cmd {COMP_WORDS=(a "'" b c); COMP_CWORD=3} } else { set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1} -}; # if +} append cmd {; COMP_LINE="a 'b c"; COMP_POINT=6; _get_cword} send "$cmd\r" expect -ex "$cmd\r\n" @@ -118,7 +118,7 @@ expect { [lindex $::BASH_VERSINFO 2] < 35 } {xfail "$test"} {fail "$test"} } -}; # expect +} sync_after_int @@ -133,7 +133,7 @@ if { set cmd {COMP_WORDS=(a "\"" b c); COMP_CWORD=3} } else { set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1} -}; # if +} append cmd {; COMP_LINE="a \"b c"; COMP_POINT=6; _get_cword}; send "$cmd\r" expect -ex "$cmd\r\n" @@ -146,7 +146,7 @@ expect { [lindex $::BASH_VERSINFO 2] < 35 } {xfail "$test"} {fail "$test"} } -}; # expect +} sync_after_int @@ -159,7 +159,7 @@ if {[lindex $::BASH_VERSINFO 0] <= 3} { } else { set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3} set expected c -}; # if +} append cmd {; COMP_LINE='a b:c'; COMP_POINT=5; _get_cword} assert_bash_list $expected $cmd $test @@ -172,7 +172,7 @@ if {[lindex $::BASH_VERSINFO 0] <= 3} { set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1} } else { set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} -}; # if +} append cmd {; COMP_LINE='a b:c'; COMP_POINT=5; _get_cword :} assert_bash_list b:c $cmd $test @@ -185,7 +185,7 @@ if {[lindex $::BASH_VERSINFO 0] <= 3} { set cmd {COMP_WORDS=(a b c:); COMP_CWORD=2} } else { set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3} -}; # if +} append cmd {; COMP_LINE='a b c:'; COMP_POINT=6; _get_cword :} assert_bash_list c: $cmd $test @@ -206,7 +206,7 @@ if {[lindex $::BASH_VERSINFO 0] <= 3} { set cmd {COMP_WORDS=(a "b::"); COMP_CWORD=1} } else { set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2} -}; # if +} append cmd {; COMP_LINE='a b::'; COMP_POINT=5; _get_cword :} assert_bash_list b:: $cmd $test @@ -239,7 +239,7 @@ if {[lindex $::BASH_VERSINFO] <= 3} { } else { set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3} set expected c -}; # if +} append cmd {; COMP_LINE='a b=c'; COMP_POINT=5; _get_cword} assert_bash_list $expected $cmd $test @@ -264,7 +264,7 @@ expect { -ex "\$(b c/@" { pass "$test" } # Expected failure on bash-4 -ex "c/@" { xfail "$test" } -}; # expect +} sync_after_int @@ -279,7 +279,7 @@ expect { -ex "\$(b c\\ d/@" { pass "$test" } # Expected failure on bash-4 -ex "c\\ d/@" { xfail "$test" } -}; # expect +} sync_after_int @@ -294,7 +294,7 @@ if { set cmd {COMP_WORDS=(a "'" b "&" c); COMP_CWORD=4} } else { set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1} -}; # if +} append cmd {; COMP_LINE="a 'b&c"; COMP_POINT=6; _get_cword} send "$cmd\r" expect -ex "$cmd\r\n" @@ -307,7 +307,7 @@ expect { [lindex $::BASH_VERSINFO 2] < 35 } {xfail "$test"} {fail "$test"} } -}; # expect +} sync_after_int diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp index 152cf885..31842792 100644 --- a/test/unit/_known_hosts_real.exp +++ b/test/unit/_known_hosts_real.exp @@ -1,6 +1,6 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { @@ -8,7 +8,7 @@ proc teardown {} { /COMPREPLY=/d /OLDHOME=/d } -}; # teardown() +} setup @@ -35,7 +35,7 @@ set hosts [lsort -ascii $hosts] set expected {} foreach host $hosts { lappend expected "user@$host:" -}; # foreach +} # Call _known_hosts set cmd {unset COMPREPLY; _known_hosts_real -acF fixtures/_known_hosts_real/config 'user@'; echo_array COMPREPLY} assert_bash_list $expected $cmd $test @@ -66,7 +66,7 @@ expect { -re "^$hosts_config\r\n/@$" { fail "$test (known hosts file)" } -re /@ { unresolved "$test at prompt" } default { unresolved "$test" } -}; # expect +} sync_after_int @@ -89,7 +89,7 @@ expect -ex "$cmd\r\n" expect { -re "^$hosts\r\n/@$" { pass "$test" } default { unresolved "$test" } -}; # expect +} # Teardown environment set cmd {HOME=$OLDHOME} send "$cmd\r" diff --git a/test/unit/_tilde.exp b/test/unit/_tilde.exp new file mode 100644 index 00000000..54394cb8 --- /dev/null +++ b/test/unit/_tilde.exp @@ -0,0 +1,51 @@ +# @param string $part Reference to variable to hold partial unique username +# @param string $full Reference to variable to hold full unique username +proc setup {part full} { + upvar $part _part + upvar $full _full + + assert_bash_exec {compgen -u} {} /@ users + find_unique_completion_pair $users _part _full + save_env +} + + +proc teardown {} { + assert_env_unmodified { + /COMPREPLY=/d + } +} + + +setup part full + + +set test "function should run without errors" +assert_bash_exec {_tilde > /dev/null} $test + + +sync_after_int + + +set test "function should not pollute environment" +# NOTE: A possible environment pollution is detected by assert_env_modified() in teardown() +assert_bash_exec {foo() { local aa="~"; _tilde "$aa"; }; foo; unset foo} $test + + +sync_after_int + + +set test "~full should complete to ~full unmodified" +set cmd [format {_tilde "~%s"; printf "%%s" "${COMPREPLY[@]}"} $full] +assert_bash_list "~$full" $cmd $test + + +sync_after_int + + +set test "~part should complete to ~full" +set cmd [format {_tilde "~%s"; printf "%%s" "${COMPREPLY[@]}"} $part] +assert_bash_list "~$full" $cmd $test + + +teardown diff --git a/test/unit/compgen.exp b/test/unit/compgen.exp index 6673bf0e..8596cfa5 100644 --- a/test/unit/compgen.exp +++ b/test/unit/compgen.exp @@ -1,11 +1,11 @@ proc setup {} { save_env -}; # setup() +} proc teardown {} { assert_env_unmodified {/OLDPWD/d} -}; # teardown() +} setup @@ -17,7 +17,7 @@ if {[lindex $::BASH_VERSINFO 0] <= 3} { } else { set test {compgen -f a\\\'b/ on bash-4 should return a\'b/c}; set cmd {compgen -f a\\\'b/} -}; # if +} set dir fixtures/compgen set prompt "/$dir/@" assert_bash_exec "cd $dir" "" $prompt @@ -39,7 +39,7 @@ expect { } -re $prompt { pass "$test" } -re eof { unresolved "eof" } -}; # expect +} sync_after_int $prompt assert_bash_exec {cd "$TESTDIR"}