diff options
author | Gabriel F. T. Gomes <gabriel@inconstante.eti.br> | 2018-03-18 12:02:11 -0300 |
---|---|---|
committer | Gabriel F. T. Gomes <gabriel@inconstante.eti.br> | 2018-03-18 12:02:11 -0300 |
commit | 9cd22d1df8f0f5b554858471c86faa9f37b8fed4 (patch) | |
tree | 6399b936aecc388506ec32cfc10fdb06cfc1949f | |
parent | 6d88f1055806932d9291f96847d2b691cccda2cd (diff) | |
download | bash-completion-9cd22d1df8f0f5b554858471c86faa9f37b8fed4.tar.gz |
New upstream version 2.8upstream/2.8
274 files changed, 2712 insertions, 1006 deletions
diff --git a/.travis.yml b/.travis.yml index c287960c..d3573a74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ env: - DIST=ubuntu14 before_install: - - docker build -t bashcomp:$DIST -f test/docker/Dockerfile-$DIST . + - docker build -t bash-completion:$DIST -f test/docker/Dockerfile-$DIST . script: - - docker run -e CI=true -e DIST=$DIST -t bashcomp:$DIST test/docker/docker-script.sh + - docker run -e CI=true -e DIST=$DIST -t bash-completion:$DIST test/docker/docker-script.sh @@ -1,3 +1,172 @@ +bash-completion (2.8) + + [ Andrea Dari ] + * dpkg: Add -V/--verify arg completion + + [ Ben Wiederhake ] + * Add support for .lz4 extension to file-roller (#158) + + [ Eric A. Zarko ] + * unzip, zipinfo: Associate *.gar (#165) + + [ Gabriel F. T. Gomes ] + * openssl: Add completion for the genpkey, pkey, pkeyparam, and + pkeyutl commands + + [ Gonzalo TornarĆa ] + * test: run bash with --norc to avoid system bashrc + + [ GĆ”bor BernĆ”t ] + * tox: New completion (#163) + + [ Halt ] + * mplayer: Disable user config when parsing options + + [ Henry-Joseph AudĆ©oud ] + * ebtables: new completion (#150) + + [ Jakub Jelen ] + * ssh,ssh-add,ssh-keygen: Complete pkcs11 options with *.so + + [ Kevin Pulo ] + * mkdir: Complete on files in addition to dirs + + [ Luca Capello ] + * dpkg-query: Fix -W/--show completion + + [ Mark Friedenbach ] + * Add support for .lzo extension (--lzop) to tar (#155) + + [ Martin d'Anjou ] + * java: Complete *.war + + [ Mateusz Piotrowski ] + * kldunload: Increase robustness of compgen filters (#185) + * kldunload: Show modules with digits + + [ MichaÅ GĆ³rny ] + * lftp: Support ~/.local/... bookmark location (#144) + * test suite: Support overriding default match buffer size (#141) + + [ Pawel ] + * man: Don't use $MANPATH directly (#161) + + [ Uwe Storbeck ] + * dpkg: Complete --vextract on deb files + * dpkg: Fix man page section in comment + + [ Ville SkyttƤ ] + * make-changelog.py: Use python3 + * test: Fix getting username in non-login shells + * test/unit: Whitespace tweaks + * info, man, rsync: Defer _expand invocation + * _expand: Reuse __expand_tilde_by_ref and _tilde logic, clean up + * test: Add some _expand unit tests + * bzip2, gzip, and other compressors: Use _tilde instead of _expand + * test: Add assert_complete_homedir, use in dpkg and ls + * dd, find, gcc: Remove unnecessary tilde expansion + * dd: Omit space only when offering one completion ending with = + * __expand_tilde_by_ref: Eval tilde expansion only, simplify + * Bump copyright years to -2018 + * mkdir: Complete files without appending space + * __load_completion: Load "xspec" completions dynamically too + * __load_completion: Code cleanup + * _avaiable_interfaces: Get rid of eval + * make: Pass script to sed as parameter instead of using process + substitution + * ccze: New completion + * *: Comma separated opt arg completion improvements + * test suite: Some more mplayer and mencoder coverage + * tox: Complete comma separated -e arguments + * xdg-mime,xdg-settings: Fix inclusion in tarball + * geoiplookup: New completion + * ping*,ssh,scp,sftp,tracepath6: Filter IPv4/IPv6 literal addresses + * _known_hosts_real: Add option to filter IPv4 and IPv6 addresses + * radvdump: New completion + * lsscsi: New completion + * python: Support completing dotted module hierarchies + * test/docker: Tweak work dir, add bash as default cmd + * test: Try to skip postconf variable test on broken postfix configs + altogether + * Revert "travis: Don't build local docker images, use vskytta/bash- + completion ones" + * test: Add "postconf -" test case + * test: Work around broken centos/fedora postfix config in non-IPv6 + setup + * travis: Don't build local docker images, use vskytta/bash- + completion ones + * pycodestyle: New completion + * flake8: Various option arg completion improvements + * perltidy: New completion + * lowriter,localc etc: Use corresponding oo* completions + * cryptsetup: Update option lists + * pv: New completion + * getconf: New completion + * nproc: New completion + * _known_hosts_real: Document -a better + * ssh: Add -J/ProxyJump completion + * ssh: Declare $prefix closer to use + * test: Ignore duplicates in find_unique_completion_pair list + * test: dpkg,ls,_tilde: Skip gracefully if no uniq user for + completion is found + * xdg-mime: New completion + * ssh-keygen: Add -E arg completion + * reportbug: Don't hardcode option lists, split option args at = + * reportbug: Add -A/--attach arg completion + * apt-get: Complete *.deb on install if argument contains a slash + * ri: Fix integrated ri 1.8 class completion + * test: Add files to test older ri with + * Whitespace + * test: Remove things moved to library.exp from bashrc + * test: Add some comments regarding bash init in library.exp + * xdg-settings: New completion + * tox: Remove spurious executable bits + * tox: Include ALL in -e completions + * tox: Avoid stderr spewage when -e invoked without tox.ini + * pylint: Invoke python3 to search for modules if command contains 3 + * pylint: Install for pylint-2 and pylint-3 too + * test suite: Add bunch of man and MANPATH test cases + * test suite: Make man test subject names less generic + * test suite: man cleanup + * rfkill: Rename to _rfkill to avoid conflict with util-linux >= + 2.31 + * test: Use prebuilt docker hub bash-completion images + * README.md: Whitespace cleanup + * iptables: Use invoked command instead of hardcoded "iptables" + * iptables: Avoid stderr trashing when invoked as non-root + * iptables: Parse options from --help output + * vpnc: Add some option argument (non)completions + * vpnc: Improve config completions + * test suite: Drop no longer needed fedoradev /usr/bin/which + workaround + * test suite: Skip fedoradev GPG checks at least for now + * lspci: New completion + * lsusb: New completion + * oggdec: New completion + * alias: Fix completion followed by = (#146) + * *: Protect shopt reset from non-default $IFS + * test suite: Limit amount of info and pinfo test output + * test suite: Add info and pinfo option test cases + * test suite: Add basic hid2hci and munin-node-configure test cases + * aptitude: Add keep to commands list (Debian: #867587) + * *: Protect _known_hosts_real from user input treated as options + * curl: Fix -x etc option argument hostname completion + * groupdel: Parse and handle long options + * aptitude-curses: Use aptitude completion + * test suite: Install aptitude in ubuntu14 container + * test suite: Enable wine in ubuntu14 + * xm: Don't leak args and commands environment variables + * uscan: Don't leak cword and words environment variables + * test suite: Add bunch of missing basic test cases + * ktutil: Don't leak i and command environment variables + * test suite: Limit amount of output from process name completion + * test suite: Limit number of screen -T completion matches + + [ j^ ] + * xine etc, ogg123, mplayer -audiofile: Associate with *.oga + + -- Ville SkyttƤ <ville.skytta@iki.fi> Sat, 17 Mar 2018 10:30:07 +0200 + bash-completion (2.7) [ Eli Young ] @@ -31,7 +31,7 @@ make install # as root ``` These commands install the completions and helpers, as well as a -`profile.d` script that loads `bash_completion` where appropriate. +`profile.d` script that loads `bash_completion` where appropriate. If your system does not use the `profile.d` directory (usually below `/etc`) mechanismāi.e. does not automatically source shell scripts in @@ -40,12 +40,12 @@ script in `/etc/bashrc` or `~/.bashrc`. The `profile.d` script provides a configuration file hook that can be used to prevent loading `bash_completion` on per user basis when it's -installed system wide. To do this: +installed system wide. To do this: -1. Turn off programmable completion with `shopt -u progcomp` in - `$XDG_CONFIG_HOME/bash_completion` (or `~/.config/bash_completion` +1. Turn off programmable completion with `shopt -u progcomp` in + `$XDG_CONFIG_HOME/bash_completion` (or `~/.config/bash_completion` if `$XDG_CONFIG_HOME` is not set) -2. Turn it back on (for example in `~/.bashrc`) if you want to use +2. Turn it back on (for example in `~/.bashrc`) if you want to use programmable completion for other purposes. ### macOS (OS X) @@ -89,8 +89,8 @@ tracing on in it before doing anything else there. mileage may vary. 3. If you are seeing 'unbound variable' warnings from bash when - hitting <kbd><Tab></kbd>, this is because you have either `set -u` - or `set -o nounset` somewhere in your start-up files. This causes bash + hitting <kbd><Tab></kbd>, this is because you have either `set -u` + or `set -o nounset` somewhere in your start-up files. This causes bash to flag the use of any uninitialised shell variables as an error. Whilst we try to avoid references to uninitialised variables in the @@ -127,15 +127,15 @@ A. Put them in `~/.bash_completion`, which is parsed at the end of the A. Install it in one of the directories pointed to by bash-completion's `pkgconfig` file variables. There are two - alternatives: - + alternatives: + - The recommended directory is `completionsdir`, which you can get with `pkg-config --variable=completionsdir bash-completion`. From this directory, completions are loaded on-demand based on invoked commands' names, so be sure to name your completion file accordingly, and to include (for example) symbolic links in case the file provides completions - for more than one command. - - The other directory (which only present for backwards compatibility) + for more than one command. + - The other directory (which only present for backwards compatibility) is `compatdir` (get it with `pkg-config --variable=compatdir bash-completion`) from which files are loaded when `bash_completion` is loaded. @@ -227,7 +227,7 @@ A. It's a choice we had to make. bash's programmable completion is `bash_completion`. **Q. When completing on a symlink to a directory, bash does not append - the trailing `/` and I have to hit <kbd><Tab></kbd> again. + the trailing `/` and I have to hit <kbd><Tab></kbd> again. I don't like this.** A. This has nothing to do with `bash_completion`. It's the default for @@ -295,7 +295,7 @@ A. Probably because the database is being queried every time and this uses a A. If your `command_not_found_handler` function is not intended to address (possibly missing) commands invoked during bash programmable completion functions, you can account for this - by, for example, testing if the `$COMP_`\* variables are set and + by, for example, testing if the `$COMP_`\* variables are set and taking appropriate bypass or other action. **Q. Can tab completion be made even easier?** diff --git a/bash_completion b/bash_completion index d16b10a5..ca84b01d 100644 --- a/bash_completion +++ b/bash_completion @@ -3,7 +3,7 @@ # bash_completion - programmable completion functions for bash 4.1+ # # Copyright Ā© 2006-2008, Ian Macdonald <ian@caliban.org> -# Ā© 2009-2017, Bash Completion Maintainers +# Ā© 2009-2018, Bash Completion Maintainers # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ # # https://github.com/scop/bash-completion -BASH_COMPLETION_VERSINFO=(2 7) +BASH_COMPLETION_VERSINFO=(2 8) if [[ $- == *v* ]]; then BASH_COMPLETION_ORIGINAL_V_VALUE="-v" @@ -938,18 +938,19 @@ _kernel_versions() # _available_interfaces() { - local cmd PATH=$PATH:/sbin - - if [[ ${1:-} == -w ]]; then - cmd="iwconfig" - elif [[ ${1:-} == -a ]]; then - cmd="{ ifconfig || ip link show up; }" - else - cmd="{ ifconfig -a || ip link show; }" - fi + local PATH=$PATH:/sbin - COMPREPLY=( $( eval $cmd 2>/dev/null | awk \ + COMPREPLY=( $( { + if [[ ${1:-} == -w ]]; then + iwconfig + elif [[ ${1:-} == -a ]]; then + ifconfig || ip link show up + else + ifconfig -a || ip link show + fi + } 2>/dev/null | awk \ '/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }' ) ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" ) ) } @@ -1004,21 +1005,8 @@ _tilde() # @param $1 Name of variable (not the value of the variable) to expand __expand_tilde_by_ref() { - # Does $1 start with tilde (~)? if [[ ${!1} == \~* ]]; then - # Does $1 contain slash (/)? - if [[ ${!1} == */* ]]; then - # Yes, $1 contains slash; - # 1: Remove * including and after first slash (/), i.e. "~a/b" - # becomes "~a". Double quotes allow eval. - # 2: Remove * before the first slash (/), i.e. "~a/b" - # becomes "b". Single quotes prevent eval. - # +-----1----+ +---2----+ - eval $1="${!1/%\/*}"/'${!1#*/}' - else - # No, $1 doesn't contain slash - eval $1="${!1}" - fi + eval $1=$(printf ~%q "${!1#\~}") fi } # __expand_tilde_by_ref() @@ -1027,19 +1015,14 @@ __expand_tilde_by_ref() # _expand() { - # FIXME: Why was this here? - #[ "$cur" != "${cur%\\}" ] && cur+="\\" - # Expand ~username type directory specifications. We want to expand # ~foo/... to /home/foo/... to avoid problems when $cur starting with # a tilde is fed to commands and ending up quoted instead of expanded. if [[ "$cur" == \~*/* ]]; then - eval cur=$cur 2>/dev/null + __expand_tilde_by_ref cur elif [[ "$cur" == \~* ]]; then - cur=${cur#\~} - COMPREPLY=( $( compgen -P '~' -u -- "$cur" ) ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && eval COMPREPLY[0]=${COMPREPLY[0]} + _tilde "$cur" || eval COMPREPLY[0]=$(printf ~%q "${COMPREPLY[0]#\~}") return ${#COMPREPLY[@]} fi } @@ -1137,9 +1120,9 @@ _xinetd_services() { local xinetddir=/etc/xinetd.d if [[ -d $xinetddir ]]; then - local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob + local IFS=$' \t\n' reset=$(shopt -p nullglob); shopt -s nullglob local -a svcs=( $( printf '%s\n' $xinetddir/!($_backup_glob) ) ) - $restore_nullglob + $reset COMPREPLY+=( $( compgen -W '${svcs[@]#$xinetddir/}' -- "$cur" ) ) fi } @@ -1151,10 +1134,10 @@ _services() local sysvdirs _sysvdirs - local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob + local IFS=$' \t\n' reset=$(shopt -p nullglob); shopt -s nullglob COMPREPLY=( \ $( printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions|README) ) ) - $restore_nullglob + $reset COMPREPLY+=( $( systemctl list-units --full --all 2>/dev/null | \ awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }' ) ) @@ -1490,24 +1473,30 @@ _included_ssh_config_files() # HOSTFILE (compgen -A hostname) are added, unless # COMP_KNOWN_HOSTS_WITH_HOSTFILE is set to an empty value. # Usage: _known_hosts_real [OPTIONS] CWORD -# Options: -a Use aliases +# Options: -a Use aliases from ssh config files # -c Use `:' suffix # -F configfile Use `configfile' for configuration settings # -p PREFIX Use PREFIX +# -4 Filter IPv6 addresses from results +# -6 Filter IPv4 addresses from results # Return: Completions, starting with CWORD, are added to COMPREPLY[] _known_hosts_real() { local configfile flag prefix - local cur curd awkcur user suffix aliases i host + local cur curd awkcur user suffix aliases i host ipv4 ipv6 local -a kh khd config + # TODO remove trailing %foo from entries + local OPTIND=1 - while getopts "acF:p:" flag "$@"; do + while getopts "ac46F:p:" flag "$@"; do case $flag in a) aliases='yes' ;; c) suffix=':' ;; F) configfile=$OPTARG ;; p) prefix=$OPTARG ;; + 4) ipv4=1 ;; + 6) ipv6=1 ;; esac done [[ $# -lt $OPTIND ]] && echo "error: $FUNCNAME: missing mandatory argument CWORD" @@ -1622,7 +1611,7 @@ _known_hosts_real() done fi - # append any available aliases from config files + # append any available aliases from ssh config files if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then local hosts=$( command sed -ne 's/^[[:blank:]]*[Hh][Oo][Ss][Tt][[:blank:]]\{1,\}\([^#*?%]*\)\(#.*\)\{0,1\}$/\1/p' "${config[@]}" ) COMPREPLY+=( $( compgen -P "$prefix$user" \ @@ -1654,6 +1643,18 @@ _known_hosts_real() $( compgen -A hostname -P "$prefix$user" -S "$suffix" -- "$cur" ) ) fi + if [[ $ipv4 ]]; then + COMPREPLY=( "${COMPREPLY[@]/*:*$suffix/}" ) + fi + if [[ $ipv6 ]]; then + COMPREPLY=( "${COMPREPLY[@]/+([0-9]).+([0-9]).+([0-9]).+([0-9])$suffix/}" ) + fi + if [[ $ipv4 || $ipv6 ]]; then + for i in ${!COMPREPLY[@]}; do + [[ ${COMPREPLY[i]} ]] || unset -v COMPREPLY[i] + done + fi + __ltrim_colon_completions "$prefix$user$cur" } # _known_hosts_real() @@ -1874,9 +1875,10 @@ _longopt() command sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}=\{0,1\}\).*/\1/p' | sort -u )" \ -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace - elif [[ "$1" == @(@(mk|rm)dir|chroot) ]]; then + elif [[ "$1" == @(rmdir|chroot) ]]; then _filedir -d else + [[ "$1" == mkdir ]] && compopt -o nospace _filedir fi } @@ -1938,11 +1940,10 @@ _install_xspec() for cmd in $@; do _xspecs[$cmd]=$xspec done - complete -F _filedir_xspec $@ } # bzcmp, bzdiff, bz*grep, bzless, bzmore intentionally not here, see Debian: #455510 _install_xspec '!*.?(t)bz?(2)' bunzip2 bzcat pbunzip2 pbzcat lbunzip2 lbzcat -_install_xspec '!*.@(zip|[ejsw]ar|exe|pk3|wsz|zargo|xpi|s[tx][cdiw]|sx[gm]|o[dt][tspgfc]|od[bm]|oxt|epub|apk|ipa|do[ct][xm]|p[op]t[mx]|xl[st][xm]|pyz)' unzip zipinfo +_install_xspec '!*.@(zip|[egjsw]ar|exe|pk3|wsz|zargo|xpi|s[tx][cdiw]|sx[gm]|o[dt][tspgfc]|od[bm]|oxt|epub|apk|ipa|do[ct][xm]|p[op]t[mx]|xl[st][xm]|pyz)' unzip zipinfo _install_xspec '*.Z' compress znew # zcmp, zdiff, z*grep, zless, zmore intentionally not here, see Debian: #455510 _install_xspec '!*.@(Z|[gGd]z|t[ag]z)' gunzip zcat @@ -1967,12 +1968,12 @@ _install_xspec '!*.@(?(e)ps|pdf)' ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 ps2pdfwr _install_xspec '!*.texi*' makeinfo texi2html _install_xspec '!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi xetex xelatex luatex lualatex _install_xspec '!*.mp3' mpg123 mpg321 madplay -_install_xspec '!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|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|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[gmv]|OG[GMV]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|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))?(.part)' xine aaxine fbxine -_install_xspec '!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|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|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[gmv]|OG[GMV]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|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|iso|ISO)|+([0-9]).@(vdr|VDR))?(.part)' kaffeine dragon +_install_xspec '!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|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|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmv]|OG[AGMV]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|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))?(.part)' xine aaxine fbxine +_install_xspec '!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|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|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmv]|OG[AGMV]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|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|iso|ISO)|+([0-9]).@(vdr|VDR))?(.part)' kaffeine dragon _install_xspec '!*.@(avi|asf|wmv)' aviplay _install_xspec '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay _install_xspec '!*.@(mpg|mpeg|avi|mov|qt)' xanim -_install_xspec '!*.@(ogg|m3u|flac|spx)' ogg123 +_install_xspec '!*.@(og[ag]|m3u|flac|spx)' ogg123 _install_xspec '!*.@(mp3|ogg|pls|m3u)' gqmpeg freeamp _install_xspec '!*.fig' xfig _install_xspec '!*.@(mid?(i)|cmf)' playmidi @@ -1983,12 +1984,12 @@ _install_xspec '!*.@(zip|z|gz|tgz)' bzme # konqueror not here on purpose, it's more than a web/html browser _install_xspec '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx galeon dillo elinks amaya epiphany _install_xspec '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL])|[pP][dD][fF])' firefox mozilla-firefox iceweasel google-chrome chromium-browser -_install_xspec '!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|?(f)odt|ott|odm|pdf)' oowriter -_install_xspec '!*.@(sxi|sti|pps?(x)|ppt?([mx])|pot?([mx])|?(f)odp|otp)' ooimpress -_install_xspec '!*.@(sxc|stc|xls?([bmx])|xlw|xlt?([mx])|[ct]sv|?(f)ods|ots)' oocalc -_install_xspec '!*.@(sxd|std|sda|sdd|?(f)odg|otg)' oodraw -_install_xspec '!*.@(sxm|smf|mml|odf)' oomath -_install_xspec '!*.odb' oobase +_install_xspec '!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|?(f)odt|ott|odm|pdf)' oowriter lowriter +_install_xspec '!*.@(sxi|sti|pps?(x)|ppt?([mx])|pot?([mx])|?(f)odp|otp)' ooimpress loimpress +_install_xspec '!*.@(sxc|stc|xls?([bmx])|xlw|xlt?([mx])|[ct]sv|?(f)ods|ots)' oocalc localc +_install_xspec '!*.@(sxd|std|sda|sdd|?(f)odg|otg)' oodraw lodraw +_install_xspec '!*.@(sxm|smf|mml|odf)' oomath lomath +_install_xspec '!*.odb' oobase lobase _install_xspec '!*.[rs]pm' rpm2cpio _install_xspec '!*.aux' bibtex _install_xspec '!*.po' poedit gtranslator kbabel lokalize @@ -2016,7 +2017,7 @@ complete -F _minimal '' __load_completion() { local -a dirs=( ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions ) - local OIFS=$IFS IFS=: dir cmd="$1" compfile + local OIFS=$IFS IFS=: dir cmd="${1##*/}" compfile for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}; do dirs+=( $dir/bash-completion/completions ) done @@ -2029,13 +2030,16 @@ __load_completion() fi for dir in "${dirs[@]}"; do - for compfile in "${cmd##*/}" "${cmd##*/}".bash _"${cmd##*/}"; do + for compfile in "$cmd" "$cmd.bash" "_$cmd"; do compfile="$dir/$compfile" # Avoid trying to source dirs; https://bugzilla.redhat.com/903540 [[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 0 done done + # Look up simple "xspec" completions + [[ "${_xspecs[$cmd]}" ]] && complete -F _filedir_xspec "$cmd" && return 0 + return 1 } diff --git a/completions/.gitignore b/completions/.gitignore index 60a2d949..c0b4c044 100644 --- a/completions/.gitignore +++ b/completions/.gitignore @@ -4,6 +4,7 @@ alpine alternatives animate apropos +aptitude-curses arm-koji asciidoc.py autoheader @@ -50,6 +51,7 @@ g4 g77 g95 gcj +geoiplookup6 gfortran gkrellm2 gmake @@ -137,6 +139,7 @@ pvscan pxz py.test-[23] pydoc3 +pylint-[23] python2 python3 pypy diff --git a/completions/Makefile.am b/completions/Makefile.am index f04d7c36..e442a9e6 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -37,6 +37,7 @@ bashcomp_DATA = 2to3 \ cancel \ cardctl \ ccache \ + ccze \ cfagent \ cfrun \ chage \ @@ -85,6 +86,7 @@ bashcomp_DATA = 2to3 \ dumpe2fs \ e2freefrag \ e2label \ + ebtables \ _eject \ eog \ ether-wake \ @@ -113,6 +115,8 @@ bashcomp_DATA = 2to3 \ genaliases \ gendiff \ genisoimage \ + geoiplookup \ + getconf \ getent \ gkrellm \ gm \ @@ -198,6 +202,8 @@ bashcomp_DATA = 2to3 \ lpr \ lrzip \ lsof \ + lsscsi \ + lsusb \ lua \ luac \ luseradd \ @@ -251,8 +257,10 @@ bashcomp_DATA = 2to3 \ ngrep \ nmap \ _nmcli \ + nproc \ nslookup \ ntpdate \ + oggdec \ openssl \ opera \ optipng \ @@ -262,6 +270,7 @@ bashcomp_DATA = 2to3 \ patch \ pdftotext \ perl \ + perltidy \ pgrep \ pidof \ pine \ @@ -291,11 +300,13 @@ bashcomp_DATA = 2to3 \ protoc \ psql \ puppet \ + pv \ pwck \ pwd \ pwdx \ pwgen \ py.test \ + pycodestyle \ pydoc \ pyflakes \ pylint \ @@ -306,6 +317,7 @@ bashcomp_DATA = 2to3 \ qrunner \ querybts \ quota \ + radvdump \ rcs \ rdesktop \ remove_members \ @@ -315,7 +327,7 @@ bashcomp_DATA = 2to3 \ reportbug \ _reptyr \ resolvconf \ - rfkill \ + _rfkill \ ri \ rmlist \ rmmod \ @@ -367,6 +379,7 @@ bashcomp_DATA = 2to3 \ tcpnice \ timeout \ tipc \ + tox \ tracepath \ tshark \ tune2fs \ @@ -400,6 +413,8 @@ bashcomp_DATA = 2to3 \ wsimport \ wtf \ wvdial \ + xdg-mime \ + xdg-settings \ xfreerdp \ xgamma \ xhost \ @@ -434,6 +449,7 @@ CLEANFILES = \ alternatives \ animate \ apropos \ + aptitude-curses \ arm-koji \ asciidoc.py \ autoheader \ @@ -485,6 +501,7 @@ CLEANFILES = \ g77 \ g95 \ gcj \ + geoiplookup6 \ gfortran \ gkrellm2 \ gmake \ @@ -573,6 +590,8 @@ CLEANFILES = \ py.test-2 \ py.test-3 \ pydoc3 \ + pylint-2 \ + pylint-3 \ pypy \ pypy3 \ python2 \ @@ -655,6 +674,10 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) ant $(targetdir)/$$file ; \ done + for file in aptitude-curses ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) aptitude $(targetdir)/$$file ; \ + done for file in asciidoc.py ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) asciidoc $(targetdir)/$$file ; \ @@ -733,6 +756,10 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) genisoimage $(targetdir)/$$file ; \ done + for file in geoiplookup6 ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) geoiplookup $(targetdir)/$$file ; \ + done for file in gkrellm2 ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) gkrellm $(targetdir)/$$file ; \ @@ -881,6 +908,10 @@ symlinks: $(targetdir) $(DATA) rm -f $(targetdir)/$$file && \ $(LN_S) pydoc $(targetdir)/$$file ; \ done + for file in pylint-2 pylint-3 ; do \ + rm -f $(targetdir)/$$file && \ + $(LN_S) pylint $(targetdir)/$$file ; \ + done for file in pypy pypy3 python2 python3 micropython ; do \ rm -f $(targetdir)/$$file && \ $(LN_S) python $(targetdir)/$$file ; \ diff --git a/completions/rfkill b/completions/_rfkill index a3741d22..e807d976 100644 --- a/completions/rfkill +++ b/completions/_rfkill @@ -1,5 +1,8 @@ # bash completion for rfkill -*- shell-script -*- +# Use of this file is deprecated on systems with util-linux >= 2.31, which +# ships completion for the rfkill included with it. + _rfkill() { local cur prev words cword diff --git a/completions/alias b/completions/alias index de2a57e8..e90dff60 100644 --- a/completions/alias +++ b/completions/alias @@ -3,7 +3,7 @@ _alias() { local cur prev words cword - _init_completion || return + _init_completion -n = || return case ${words[@]} in *[^=]) diff --git a/completions/apt-get b/completions/apt-get index ce951050..32c4bcf8 100644 --- a/completions/apt-get +++ b/completions/apt-get @@ -30,8 +30,12 @@ _apt_get() command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) ) ;; *) - COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ - 2> /dev/null ) ) + if [[ $special == install && $cur == */* ]]; then + _filedir deb + else + COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ + 2>/dev/null ) ) + fi ;; esac return diff --git a/completions/aptitude b/completions/aptitude index 32c1dacf..a8b88737 100644 --- a/completions/aptitude +++ b/completions/aptitude @@ -77,11 +77,11 @@ _aptitude() COMPREPLY=( $( compgen -W 'update upgrade safe-upgrade forget-new clean autoclean install reinstall remove hold unhold purge markauto unmarkauto why why-not dist-upgrade full-upgrade download search - show forbid-version changelog keep-all build-dep add-user-tag + show forbid-version changelog keep keep-all build-dep add-user-tag remove-user-tag versions' -- "$cur" ) ) fi } && -complete -F _aptitude -o default aptitude +complete -F _aptitude -o default aptitude aptitude-curses # ex: filetype=sh diff --git a/completions/arping b/completions/arping index a719e916..2f544353 100644 --- a/completions/arping +++ b/completions/arping @@ -24,7 +24,7 @@ _arping() return fi - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" } && complete -F _arping arping diff --git a/completions/arpspoof b/completions/arpspoof index 7b515edb..e31288fc 100644 --- a/completions/arpspoof +++ b/completions/arpspoof @@ -11,7 +11,7 @@ _arpspoof() return ;; -t) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; esac @@ -19,7 +19,7 @@ _arpspoof() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) else - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" fi } && diff --git a/completions/bzip2 b/completions/bzip2 index 8362a595..f45e29f2 100644 --- a/completions/bzip2 +++ b/completions/bzip2 @@ -32,7 +32,7 @@ _bzip2() [[ "$prev" == -*z* ]] && xspec= fi - _expand || return + _tilde "$cur" || return compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ diff --git a/completions/ccze b/completions/ccze new file mode 100644 index 00000000..c803408b --- /dev/null +++ b/completions/ccze @@ -0,0 +1,43 @@ +# ccze(1) completion -*- shell-script -*- + +_ccze() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -'?'|--help|--usage|-V|--version) + return + ;; + -a|--argument|-c|--color) + # TODO? + return + ;; + -F|--rcfile) + _filedir + return + ;; + -m|--mode) + COMPREPLY=( $( compgen -W "curses ansi html" -- "$cur" ) ) + return + ;; + -o|--option) + local -a opts=(scroll wordcolor lookups transparent cssfile) + COMPREPLY=( $( compgen -W '${opts[@]} ${opts[@]/#/no}' -- "$cur" ) ) + return + ;; + -p|--plugin) + COMPREPLY=( $( compgen -W '$( "$1" --list-plugins | + sed -ne "s/^\([a-z0-9]\{1,\}\)[[:space:]]\{1,\}|.*/\1/p" )' \ + -- "$cur" ) ) + return + esac + + $split && return + + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace +} && +complete -F _ccze ccze + +# ex: filetype=sh diff --git a/completions/chronyc b/completions/chronyc index ede6bb09..fae9d2e4 100644 --- a/completions/chronyc +++ b/completions/chronyc @@ -5,7 +5,7 @@ _chronyc_command_args() local -a args=( $( compgen -W "$( $1 help 2>/dev/null | \ awk '/^'$prev'\s[^ []/ { gsub("\\|", " ", $2); print $2 }' )" ) ) case $args in - \<address\>) _known_hosts_real "$cur" ;; + \<address\>) _known_hosts_real -- "$cur" ;; \<*) ;; *) COMPREPLY+=( $( compgen -W '${args[@]}' -- "$cur" ) ) ;; esac @@ -21,7 +21,7 @@ _chronyc() return ;; -h) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; esac @@ -50,7 +50,7 @@ _chronyc() fi ;; 2) - [[ $prev == @(peer|server) ]] && _known_hosts_real "$cur" + [[ $prev == @(peer|server) ]] && _known_hosts_real -- "$cur" ;; esac } && diff --git a/completions/cryptsetup b/completions/cryptsetup index 9411ad7a..570b27ef 100644 --- a/completions/cryptsetup +++ b/completions/cryptsetup @@ -33,26 +33,27 @@ _cryptsetup() COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace else - COMPREPLY=( $( compgen -W 'create remove status resize luksFormat - luksOpen luksClose luksSuspend luksResume luksAddKey - luksRemoveKey luksKillSlot luksDelKey luksUUID isLuks - luksDump luksHeaderBackup luksHeaderRestore' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'open close resize status benchmark + repair erase luksFormat luksAddKey luksRemoveKey luksChangeKey + luksKillSlot luksUUID isLuks luksDump tcryptDump luksSuspend + luksResume luksHeaderBackup luksHeaderRestore' -- "$cur" ) ) fi else local args _count_args case $arg in - create) + open|create|luksOpen|loopaesOpen|tcryptOpen) case $args in 2) - _cryptsetup_name + _cryptsetup_device ;; 3) - _cryptsetup_device + _cryptsetup_name ;; esac ;; - remove|status|resize|luksClose|luksSuspend|luksResume) + close|remove|luksClose|loopaesClose|tcryptClose|status|resize|\ + luksSuspend|luksResume) case $args in 2) _cryptsetup_name @@ -69,16 +70,6 @@ _cryptsetup() ;; esac ;; - luksOpen) - case $args in - 2) - _cryptsetup_device - ;; - 3) - _cryptsetup_name - ;; - esac - ;; luksKillSlot|luksDelKey|luksUUID|isLuks|luksDump) case $args in 2) diff --git a/completions/curl b/completions/curl index 8251674c..c28a8ccd 100644 --- a/completions/curl +++ b/completions/curl @@ -68,7 +68,7 @@ _curl() return ;; -x|--proxy|--socks4|--socks4a|--socks5|--socks5-hostname) - _known_hosts_real + _known_hosts_real -- "$cur" return ;; --pubkey) diff --git a/completions/dd b/completions/dd index daaebbe1..b2647bca 100644 --- a/completions/dd +++ b/completions/dd @@ -32,12 +32,11 @@ _dd() ;; esac - _expand || return - COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) \ $( compgen -W 'bs cbs conv count ibs if iflag obs of oflag seek skip status' -S '=' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace } && -complete -F _dd -o nospace dd +complete -F _dd dd # ex: filetype=sh diff --git a/completions/dhclient b/completions/dhclient index 8b44f6c3..24270c7e 100644 --- a/completions/dhclient +++ b/completions/dhclient @@ -11,7 +11,7 @@ _dhclient() return ;; -s) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; esac diff --git a/completions/dpkg b/completions/dpkg index 725542a7..76dd5b01 100644 --- a/completions/dpkg +++ b/completions/dpkg @@ -32,7 +32,7 @@ _comp_dpkg_purgeable_packages() } } -# Debian dpkg(8) completion +# Debian dpkg(1) completion # _dpkg() { @@ -50,9 +50,9 @@ _dpkg() fi case $prev in - -c|-i|-A|-I|-f|-e|-x|-X|-W|--install|--unpack|--record-avail| \ + -c|-i|-A|-I|-f|-e|-x|-W|--install|--unpack|--record-avail| \ --contents|--info|--fsys-tarfile|--field|--control|--extract| \ - --show) + --vextract) _filedir '?(u|d)deb' return ;; @@ -60,7 +60,7 @@ _dpkg() _filedir -d return ;; - -s|-p|-l|--status|--print-avail|--list) + -s|-p|-l|-W|--status|--print-avail|--list|--show) COMPREPLY=( $( apt-cache pkgnames "$cur" 2>/dev/null ) ) return ;; @@ -68,7 +68,7 @@ _dpkg() _filedir return ;; - -r|--remove) + -r|-V|--remove|--verify) COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) ) return ;; diff --git a/completions/ebtables b/completions/ebtables new file mode 100644 index 00000000..05af7e39 --- /dev/null +++ b/completions/ebtables @@ -0,0 +1,83 @@ +# bash completion for ebtables -*- shell-script -*- + +_ebtables() +{ + local cur prev words cword split + _init_completion -s || return + + local table chain='s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \ + targets='ACCEPT DROP CONTINUE RETURN' + + if [[ ${words[@]} == *-t\ *filter* ]]; then + table="-t filter" + elif [[ ${words[@]} == *-t\ *nat* ]]; then + table="-t nat" + elif [[ ${words[@]} == *-t\ *mangle* ]]; then + table="-t mangle" + fi + + case $prev in + -*[AIDPFXLZ]) + COMPREPLY=( $( compgen -W '`"$1" $table -L 2>/dev/null | \ + command sed -ne "$chain"`' -- "$cur" ) ) + ;; + -*t) + COMPREPLY=( $( compgen -W 'nat filter broute' -- "$cur" ) ) + ;; + -j) + if [[ "$table" == "-t filter" || -z "$table" ]]; then + COMPREPLY=( $( compgen -W '$targets + $("$1" $table -L 2>/dev/null | \ + command sed -n -e "s/INPUT\|OUTPUT\|FORWARD//" \ + -e "$chain")' \ + -- "$cur" ) ) + elif [[ $table == "-t nat" ]]; then + COMPREPLY=( $( compgen -W '$targets + $("$1" $table -L 2>/dev/null | \ + command sed -n -e "s/OUTPUT|PREROUTING|POSTROUTING//" \ + -e "$chain")' \ + -- "$cur" ) ) + elif [[ $table == "-t broute" ]]; then + COMPREPLY=( $( compgen -W 'ACCEPT DROP + $("$1" $table -L 2>/dev/null | \ + command sed -n -e "s/BROUTING//" -e "$chain")' \ + -- "$cur" ) ) + fi + ;; + *) + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--802_3-sap --802_3-type --among-dst + --among-dst-file --among-src --among-src-file --append + --arp-gratuitous --arp-htype --arp-ip-dst --arp-ip-src + --arp-mac-dst --arp-mac-src --arp-opcode --arp-ptype --arpreply-mac + --arpreply-target --atomic-commit --atomic-file --atomic-init + --atomic-save --change-counters --concurrent --delete + --delete-chain --destination --dnat-target --dst --flush --help + --in-if --in-interface --init-table --insert --ip6-destination + --ip6-destination-port --ip6-dport --ip6-dst --ip6-icmp-type + --ip6-prococol --ip6-proto --ip6-protocol --ip6-source + --ip6-source-port --ip6-sport --ip6-src --ip6-tclass + --ip-destination --ip-destination-port --ip-dport --ip-dst + --ip-proto --ip-protocol --ip-source --ip-source-port --ip-sport + --ip-src --ip-tos --jump --Lc --limit --limit-burst --list --Lmac2 + --Ln --log --log-arp --logical-in --logical-out --log-ip --log-ip6 + --log-level --log-prefix --Lx --mark --mark-and --mark-or + --mark-set --mark-target --mark-xor --modprobe --new-chain --nflog + --nflog-group --nflog-prefix --nflog-range --nflog-threshold + --out-if --out-interface --pkttype-type --policy --proto --protocol + --redirect-target --rename-chain --set-counter --snat-arp + --snat-target --source --src --stp-flags --stp-forward-delay + --stp-hello-time --stp-max-age --stp-msg-age --stp-port + --stp-root-addr --stp-root-cost --stp-root-prio --stp-sender-addr + --stp-sender-prio --stp-type --table --to-destination --to-dst + --to-source --to-src --ulog --ulog-cprange --ulog-nlgroup + --ulog-prefix --ulog-qthreshold --version --vlan-encap --vlan-id + --vlan-prio --zero' -- "$cur" ) ) + fi + ;; + esac + +} && +complete -F _ebtables ebtables + +# ex: filetype=sh diff --git a/completions/file-roller b/completions/file-roller index 3c627585..efa73bb1 100644 --- a/completions/file-roller +++ b/completions/file-roller @@ -5,7 +5,7 @@ _file_roller() local cur prev words cword split _init_completion -s || return - local exts='@(7z|ace|alz|ar|arj|[bglx]z|bz2|tb?(z)2|cab|cb[rz]|iso?(9660)|Z|t[abglx]z|cpio|deb|rar|?(g)tar|gem|lh[az]|lzh|?(t)lrz|lzma|lzo|wim|swm|rpm|sit|zoo)' + local exts='@(7z|ace|alz|ar|arj|[bglx]z|bz2|tb?(z)2|cab|cb[rz]|iso?(9660)|Z|t[abglx]z|cpio|deb|rar|?(g)tar|gem|lh[az]|lz[4h]|?(t)lrz|lzma|lzo|wim|swm|rpm|sit|zoo)' case $prev in -'?'|--help|--help-all|--help-gtk|--help-sm-client) diff --git a/completions/find b/completions/find index 39029345..4451d059 100644 --- a/completions/find +++ b/completions/find @@ -62,8 +62,6 @@ _find() ;; esac - _expand || return - local i exprfound=false # set exprfound to true if there is already an expression present for i in ${words[@]}; do diff --git a/completions/flake8 b/completions/flake8 index 60ad9e2b..6f0be12f 100644 --- a/completions/flake8 +++ b/completions/flake8 @@ -6,18 +6,25 @@ _flake8() _init_completion -s || return case $prev in - -h|--help|--version|--exclude|--filename|--select|--ignore|\ - --max-line-length|--max-complexity|--builtins) + -h|--help|--version) return ;; --format) COMPREPLY=( $( compgen -W 'default pylint' -- "$cur" ) ) return ;; - --config) + -j|--jobs) + COMPREPLY=( $( compgen -W "auto {1..$(_ncpus)}" -- "$cur" ) ) + return + ;; + --output-file|--append-config|--config) _filedir return ;; + --include-in-doctest|--exclude-from-doctest) + _filedir py + return + ;; esac $split && return diff --git a/completions/freeciv-gtk2 b/completions/freeciv-gtk2 index 246d4f20..953b829a 100644 --- a/completions/freeciv-gtk2 +++ b/completions/freeciv-gtk2 @@ -15,7 +15,7 @@ _civclient() return ;; -s|--server) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; esac diff --git a/completions/gcc b/completions/gcc index 174e0718..b93a33f2 100644 --- a/completions/gcc +++ b/completions/gcc @@ -13,8 +13,6 @@ _gcc() local cur prev words cword _init_completion || return - _expand || return - local cc backend case $1 in diff --git a/completions/geoiplookup b/completions/geoiplookup new file mode 100644 index 00000000..0c92548a --- /dev/null +++ b/completions/geoiplookup @@ -0,0 +1,33 @@ +# geoiplookup(1) completion -*- shell-script -*- + +_geoiplookup() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h|-'?'|-v) + return + ;; + -d) + _filedir -d + return + ;; + -f) + _filedir dat + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_usage "$1" -h )' -- "$cur" ) ) + return + fi + + local ipvx + [[ $1 == *6 ]] && ipvx=-6 || ipvx=-4 + _known_hosts_real $ipvx -- "$cur" +} && +complete -F _geoiplookup geoiplookup geoiplookup6 + +# ex: filetype=sh diff --git a/completions/getconf b/completions/getconf new file mode 100644 index 00000000..80be667c --- /dev/null +++ b/completions/getconf @@ -0,0 +1,30 @@ +# getconf(1) completion -*- shell-script -*- + +_getconf() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -a) + _filedir + return + ;; + -v) + COMPREPLY=( $( compgen -W \ + '$( "$1" -a 2>/dev/null | awk "{ print \$1 }" )' -- \ + "${cur:-POSIX_V}" ) ) + return + ;; + esac + + if [[ $prev == PATH_MAX ]]; then # TODO more path vars, better handling + _filedir + elif [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '-a -v' -- "$cur" ) ) + else + COMPREPLY=( $( compgen -W \ + '$( "$1" -a 2>/dev/null | awk "{ print \$1 }" )' -- "$cur" ) ) + fi +} && +complete -F _getconf getconf diff --git a/completions/gkrellm b/completions/gkrellm index cfe65429..52d2a651 100644 --- a/completions/gkrellm +++ b/completions/gkrellm @@ -15,7 +15,7 @@ _gkrellm() return ;; -s|--server) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -l|--logfile) diff --git a/completions/groupdel b/completions/groupdel index 91ba3583..867b1741 100644 --- a/completions/groupdel +++ b/completions/groupdel @@ -1,5 +1,27 @@ # groupdel(8) completion -*- shell-script -*- -complete -g groupdel +_groupdel() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h|--help) + return + ;; + -R|--root) + _filedir -d + return + ;; + esac + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + return + fi + + COMPREPLY=( $( compgen -g -- "$cur" ) ) +} && +complete -F _groupdel groupdel # ex: filetype=sh diff --git a/completions/gzip b/completions/gzip index 8093e41e..59818d92 100644 --- a/completions/gzip +++ b/completions/gzip @@ -33,7 +33,7 @@ _gzip() [[ "$prev" == -*f* ]] && xspec= fi - _expand || return + _tilde "$cur" || return compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ diff --git a/completions/hping2 b/completions/hping2 index 9d454622..6344ed73 100644 --- a/completions/hping2 +++ b/completions/hping2 @@ -11,7 +11,7 @@ _hping2() return ;; -a|--spoof) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -o|--tos) @@ -27,7 +27,7 @@ _hping2() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) else - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" fi } && complete -F _hping2 hping hping2 hping3 diff --git a/completions/info b/completions/info index f71cbf5b..ba2cf4cb 100644 --- a/completions/info +++ b/completions/info @@ -5,8 +5,6 @@ _info() local cur prev words cword split _init_completion -s || return - _expand || return - # default completion if parameter looks like a path if [[ "$cur" == @(*/|[.~])* ]]; then _filedir @@ -49,6 +47,8 @@ _info() infopath=$INFOPATH fi + _expand || return + infopath=$infopath: if [[ -n $cur ]]; then infopath="${infopath//://$cur* }" diff --git a/completions/iperf b/completions/iperf index 4652879c..712ab946 100644 --- a/completions/iperf +++ b/completions/iperf @@ -25,7 +25,7 @@ _iperf() return ;; -c|--client) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -x|--reportexclude) diff --git a/completions/ipmitool b/completions/ipmitool index 8e2637c7..5a660733 100644 --- a/completions/ipmitool +++ b/completions/ipmitool @@ -30,7 +30,7 @@ _ipmitool() return ;; -H) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -f|-S|-O) diff --git a/completions/iptables b/completions/iptables index 0ecb1ebd..5ef81037 100644 --- a/completions/iptables +++ b/completions/iptables @@ -17,7 +17,7 @@ _iptables() case $prev in -*[AIDRPFXLZ]) - COMPREPLY=( $( compgen -W '`iptables $table -nL | \ + COMPREPLY=( $( compgen -W '`"$1" $table -nL 2>/dev/null | \ command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur" ) ) ;; -*t) @@ -26,30 +26,26 @@ _iptables() -j) if [[ "$table" == "-t filter" || -z "$table" ]]; then COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT - `iptables $table -nL | command sed -ne "$chain" \ + `"$1" $table -nL 2>/dev/null | command sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ "$cur" ) ) elif [[ $table == "-t nat" ]]; then COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT MIRROR SNAT - DNAT MASQUERADE `iptables $table -nL | \ + DNAT MASQUERADE `"$1" $table -nL 2>/dev/null | \ command sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \ -- "$cur" ) ) elif [[ $table == "-t mangle" ]]; then COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT MARK TOS - `iptables $table -nL | command sed -ne "$chain" \ + `"$1" $table -nL 2>/dev/null | command sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ "$cur" ) ) fi ;; *) if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--in-interface --out-interface --source - --destination --protocol --fragment --match --append --delete - --insert --replace --list --flush --zero --new --delete-chain - --policy --rename-chain --proto --source --destination - --in-interface --jump --match --numeric --out-interface --table - --verbose --line-numbers --exact --fragment --modprobe - --set-counters --version' -- "$cur" ) ) + COMPREPLY=( $( compgen -W '$( "$1" --help 2>&1 | + command sed -e "s/^\[\!\]//" | _parse_help - )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace fi ;; esac diff --git a/completions/java b/completions/java index 7d1cf1fe..e8d81fb4 100644 --- a/completions/java +++ b/completions/java @@ -217,7 +217,7 @@ _java() else if [[ "$prev" == -jar ]]; then # jar file completion - _filedir jar + _filedir '[jw]ar' else # classes completion _java_classes diff --git a/completions/jps b/completions/jps index 42f8d1a5..e46c9f16 100644 --- a/completions/jps +++ b/completions/jps @@ -17,7 +17,7 @@ _jps() COMPREPLY=( $( compgen -W "-q -m -l -v -V -J -help" -- "$cur" ) ) [[ $COMPREPLY == -J* ]] && compopt -o nospace else - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" fi } && complete -F _jps jps diff --git a/completions/kcov b/completions/kcov index 7e9aa1e0..5d067778 100644 --- a/completions/kcov +++ b/completions/kcov @@ -33,9 +33,12 @@ _kcov() if [[ "$cur" == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" - COMPREPLY=( $( compgen -P "$prev," -W "{0..100}" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "{0..100}" -- "$cur" ) ) + [[ ${#COMPREPLY[@]} -eq 1 ]] && \ + COMPREPLY=( ${COMPREPLY/#/$prev,} ) else COMPREPLY=( $( compgen -W "{0..100}" -- "$cur" ) ) + [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/%/,} ) compopt -o nospace fi return diff --git a/completions/kldunload b/completions/kldunload index 82770189..52634c1e 100644 --- a/completions/kldunload +++ b/completions/kldunload @@ -7,8 +7,8 @@ _kldunload() local cur prev words cword _init_completion || return - COMPREPLY=( $( kldstat | command sed -ne \ - "s/^.*[[:blank:]]\{1,\}\($cur[a-z_]\{1,\}\).ko$/\1/p" ) ) + COMPREPLY=( $( compgen -W '$(kldstat)' -X 'kernel' -X '!*.ko' -- "$cur" ) ) + COMPREPLY=( ${COMPREPLY[@]%.ko} ) } && complete -F _kldunload kldunload diff --git a/completions/ktutil b/completions/ktutil index 384db329..2baa1c6c 100644 --- a/completions/ktutil +++ b/completions/ktutil @@ -24,7 +24,7 @@ _ktutil() local cur prev words cword split _init_completion -s || return - local command options + local command commands i options case $prev in -p|--principal) @@ -36,7 +36,7 @@ _ktutil() return ;; -a|--admin-server) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -r|--realm) diff --git a/completions/ldapsearch b/completions/ldapsearch index 282760f7..9a6f25db 100644 --- a/completions/ldapsearch +++ b/completions/ldapsearch @@ -17,7 +17,7 @@ _ldapsearch() case $prev in -h) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -H) @@ -60,7 +60,7 @@ _ldapaddmodify() case $prev in -h) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -H) @@ -90,7 +90,7 @@ _ldapdelete() case $prev in -h) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -H) @@ -120,7 +120,7 @@ _ldapcompare() case $prev in -h) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -H) @@ -150,7 +150,7 @@ _ldapmodrdn() case $prev in -h) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -H) @@ -180,7 +180,7 @@ _ldapwhoami() case $prev in -h) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -H) @@ -210,7 +210,7 @@ _ldappasswd() case $prev in -h) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -H) diff --git a/completions/ldapvi b/completions/ldapvi index e3c1f103..7d3fcf66 100644 --- a/completions/ldapvi +++ b/completions/ldapvi @@ -7,7 +7,7 @@ _ldapvi() case $prev in -h|--host) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -Y|--sasl-mech) diff --git a/completions/lftp b/completions/lftp index edb363b2..3eb07399 100644 --- a/completions/lftp +++ b/completions/lftp @@ -21,8 +21,8 @@ _lftp() fi COMPREPLY=( $( compgen -W \ - '$( cut -f 1 -s ~/.lftp/bookmarks 2>/dev/null )' -- "$cur" ) ) - _known_hosts_real "$cur" + '$( cut -f 1 -s ~/.lftp/bookmarks ${XDG_DATA_HOME:-$HOME/.local/share}/lftp/bookmarks 2>/dev/null )' -- "$cur" ) ) + _known_hosts_real -- "$cur" } && complete -F _lftp lftp diff --git a/completions/lrzip b/completions/lrzip index f8e2cf1c..5338bd87 100644 --- a/completions/lrzip +++ b/completions/lrzip @@ -36,13 +36,13 @@ _lrzip() ;; esac - _expand || return - if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) return fi + _tilde "$cur" || return + local IFS=$'\n' compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ diff --git a/completions/lspci b/completions/lspci new file mode 100644 index 00000000..70abc3c4 --- /dev/null +++ b/completions/lspci @@ -0,0 +1,41 @@ +# lspci(8) completion -*- shell-script -*- + +_lspci() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -s|-D|-O) + return + ;; + -i) + _filedir ids + return + ;; + -p) + _filedir pcimap + return + ;; + -A) + COMPREPLY+=( $( compgen -W '$( $1 -A help | command grep -vF : )' \ + -- "$cur") ) + return + ;; + -H) + COMPREPLY+=( $( compgen -W "1 2" -- "$cur" ) ) + return + ;; + -F) + _filedir + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + fi +} && +complete -F _lspci lspci + +# ex: filetype=sh diff --git a/completions/lsscsi b/completions/lsscsi new file mode 100644 index 00000000..b64c5927 --- /dev/null +++ b/completions/lsscsi @@ -0,0 +1,27 @@ +# lsscsi(8) completion -*- shell-script -*- + +_lsscsi() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -h|--help|-V|--version) + return + ;; + -y|--sysfsroot) + _filedir -d + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + fi +} && +complete -F _lsscsi lsscsi + +# ex: filetype=sh diff --git a/completions/lsusb b/completions/lsusb new file mode 100644 index 00000000..d6700beb --- /dev/null +++ b/completions/lsusb @@ -0,0 +1,20 @@ +# lsusb(8) completion -*- shell-script -*- + +_lsusb() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h|--help|-V|--version|-s|-D) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + fi +} && +complete -F _lsusb lsusb + +# ex: filetype=sh diff --git a/completions/lz4 b/completions/lz4 index 56602ca2..365fef9d 100644 --- a/completions/lz4 +++ b/completions/lz4 @@ -42,7 +42,8 @@ _lz4() esac done - _expand || return + _tilde "$cur" || return + local IFS=$'\n' compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ diff --git a/completions/lzma b/completions/lzma index 74dac25c..0a5ab355 100644 --- a/completions/lzma +++ b/completions/lzma @@ -24,7 +24,7 @@ _lzma() [[ "$prev" == -*z* ]] && xspec= fi - _expand || return + _tilde "$cur" || return compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ diff --git a/completions/lzop b/completions/lzop index f6753529..900a36ad 100644 --- a/completions/lzop +++ b/completions/lzop @@ -48,7 +48,7 @@ _lzop() ;; esac - _expand || return + _tilde "$cur" || return local IFS=$'\n' compopt -o filenames diff --git a/completions/make b/completions/make index 1075b37a..45d51168 100644 --- a/completions/make +++ b/completions/make @@ -152,12 +152,11 @@ _make() mode=-d # display-only mode fi - local reset=$( shopt -po posix ); set +o posix # <(...) + local IFS=$' \t\n' script=$( _make_target_extract_script $mode "$cur" ) COMPREPLY=( $( LC_ALL=C \ $1 -npq __BASH_MAKE_COMPLETION__=1 \ "${makef[@]}" "${makef_dir[@]}" .DEFAULT 2>/dev/null | \ - command sed -nf <(_make_target_extract_script $mode "$cur") ) ) - $reset + command sed -ne "$script" ) ) if [[ $mode != -d ]]; then # Completion will occur if there is only one suggestion diff --git a/completions/man b/completions/man index a00ac7a0..0668b8ee 100644 --- a/completions/man +++ b/completions/man @@ -45,23 +45,21 @@ _man() return fi - _expand || return - # file based completion if parameter looks like a path if [[ "$cur" == @(*/|[.~])* ]]; then _filedir "$manext" return fi - local manpath="$MANPATH" - [[ -z $manpath ]] && \ - manpath=$( manpath 2>/dev/null || command man -w 2>/dev/null ) + local manpath=$( manpath 2>/dev/null || command man -w 2>/dev/null ) [[ -z $manpath ]] && manpath="/usr/share/man:/usr/local/share/man" # determine manual section to search local sect [[ "$prev" == $mansect ]] && sect=$prev || sect='*' + _expand || return + manpath=$manpath: if [[ -n $cur ]]; then manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }" diff --git a/completions/medusa b/completions/medusa index 697cafea..017d163d 100644 --- a/completions/medusa +++ b/completions/medusa @@ -7,7 +7,7 @@ _medusa() case $prev in -h) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -H|-U|-P|-C|-O) diff --git a/completions/mplayer b/completions/mplayer index ab08b9a9..e43e6c08 100644 --- a/completions/mplayer +++ b/completions/mplayer @@ -3,7 +3,7 @@ _mplayer_options_list() { cur=${cur%\\} - COMPREPLY=( $( compgen -W "$( $1 -nomsgcolor -nomsgmodule $2 help 2>/dev/null | \ + COMPREPLY=( $( compgen -W "$( $1 -noconfig all $2 help 2>/dev/null | \ command sed -e '/^Available/,/^$/!d' -e '/^Available/d' | awk '{print $1}' | \ command sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' )" -- "$cur" ) ) } @@ -26,7 +26,7 @@ _mplayer() return ;; -audiofile|-audio-file) - _filedir '@(mp3|mpg|ogg|w?(a)v|mid|flac|mka|ac3|ape)' + _filedir '@(mp3|mpg|og[ag]|w?(a)v|mid|flac|mka|ac3|ape)' return ;; -font|-subfont) @@ -262,7 +262,7 @@ _mplayer() -*) # Assume arg is required for everything else except options # for which -list-options says Type is Flag or Print. - $cmd -nomsgcolor -nomsgmodule -list-options 2>/dev/null \ + $cmd -noconfig all -list-options 2>/dev/null \ | while read -r i j k; do if [[ $i == ${prev#-} ]]; then [[ ${j,,} != @(flag|print) ]] && return 1 @@ -274,7 +274,7 @@ _mplayer() case $cur in -*) - COMPREPLY=( $( compgen -W '$( $cmd -nomsgcolor -nomsgmodule -list-options 2>/dev/null | \ + COMPREPLY=( $( compgen -W '$( $cmd -noconfig all -list-options 2>/dev/null | \ command sed -ne '1,/^[[:space:]]*Name/d' \ -e "s/^[[:space:]]*/-/" -e "s/[[:space:]:].*//" \ -e "/^-\(Total\|.*\*\)\{0,1\}$/!p" )' -- "$cur" ) ) diff --git a/completions/munin-node-configure b/completions/munin-node-configure index 82815a6e..a2021727 100644 --- a/completions/munin-node-configure +++ b/completions/munin-node-configure @@ -15,7 +15,7 @@ _munin_node_configure() return ;; --snmp) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; --snmpversion) diff --git a/completions/munin-update b/completions/munin-update index 8889a94d..ef8bf5b5 100644 --- a/completions/munin-update +++ b/completions/munin-update @@ -11,7 +11,7 @@ _munin_update() return ;; --host) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; esac diff --git a/completions/mussh b/completions/mussh index 2e9842b6..185f9d30 100644 --- a/completions/mussh +++ b/completions/mussh @@ -34,7 +34,7 @@ _mussh() return ;; -p|-h) - [[ $cur == *@* ]] && _user_at_host || _known_hosts_real -a "$cur" + [[ $cur == *@* ]] && _user_at_host || _known_hosts_real -a -- "$cur" return ;; -c) diff --git a/completions/mysql b/completions/mysql index ddc94e68..48fe0e39 100644 --- a/completions/mysql +++ b/completions/mysql @@ -16,11 +16,11 @@ _mysql() ;; -h|--host) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; --default-character-set) - local reset=$( shopt -p failglob ); shopt -u failglob + local IFS=$' \t\n' reset=$( shopt -p failglob ); shopt -u failglob local -a charsets=( /usr/share/m{ariadb,ysql}/charsets/*.xml ) $reset charsets=( "${charsets[@]##*/}" ) diff --git a/completions/mysqladmin b/completions/mysqladmin index 13799052..bb7ba869 100644 --- a/completions/mysqladmin +++ b/completions/mysqladmin @@ -11,7 +11,7 @@ _mysqladmin() return ;; -h|--host) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; --character-sets-dir|--ssl-capath) diff --git a/completions/nc b/completions/nc index 61bf5b52..63cb9d14 100644 --- a/completions/nc +++ b/completions/nc @@ -23,7 +23,7 @@ _nc() return ;; -x) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; esac @@ -39,7 +39,7 @@ _nc() [[ ${words[i]} != -* && ${words[i-1]} != -[IiOPpsTVwXx] ]] && return done - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" } && complete -F _nc nc diff --git a/completions/nmap b/completions/nmap index 7de8ed42..c56c7210 100644 --- a/completions/nmap +++ b/completions/nmap @@ -19,7 +19,7 @@ _nmap() return ;; -b|--dns-servers) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; esac @@ -42,7 +42,7 @@ _nmap() -A --datadir --send-eth --send-ip --privilege--unprivileged -V -h' -- "$cur" ) ) else - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" fi } && complete -F _nmap nmap diff --git a/completions/nproc b/completions/nproc new file mode 100644 index 00000000..8903940e --- /dev/null +++ b/completions/nproc @@ -0,0 +1,21 @@ +# nproc(1) completion -*- shell-script -*- + +_nproc() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|--version|--ignore) + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + fi +} && +complete -F _nproc nproc diff --git a/completions/nslookup b/completions/nslookup index f137b0a1..65770629 100644 --- a/completions/nslookup +++ b/completions/nslookup @@ -45,7 +45,7 @@ _nslookup() local args _count_args = if [[ $args -le 2 ]]; then - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" [[ $args -eq 1 && $cur == @(|-) ]] && COMPREPLY+=( - ) fi } && @@ -79,7 +79,7 @@ _host() return fi - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" } && complete -F _host host diff --git a/completions/ntpdate b/completions/ntpdate index ade95a69..ff0c9f00 100644 --- a/completions/ntpdate +++ b/completions/ntpdate @@ -27,7 +27,7 @@ _ntpdate() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) else - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" fi } && complete -F _ntpdate ntpdate diff --git a/completions/oggdec b/completions/oggdec new file mode 100644 index 00000000..0493087d --- /dev/null +++ b/completions/oggdec @@ -0,0 +1,38 @@ +# bash completion for oggdec(1) -*- shell-script -*- + +_oggdec() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --help|-h|--version|-V) + return + ;; + --bits|-b) + COMPREPLY=( $( compgen -W "8 16" -- "$cur" ) ) + return + ;; + --endianness|-e|--sign|-s) + COMPREPLY=( $( compgen -W "0 1" -- "$cur" ) ) + return + ;; + --output|-o) + _filedir wav + return + ;; + esac + + $split && return + + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir ogg +} && +complete -F _oggdec oggdec + +# ex: filetype=sh diff --git a/completions/openssl b/completions/openssl index 57476848..73e56a44 100644 --- a/completions/openssl +++ b/completions/openssl @@ -50,7 +50,7 @@ _openssl() des des-cbc des-cfb des-ecb des-ede des-ede-cbc des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 rc4-40 - sha224 sha256 sha384 sha512' + sha224 sha256 sha384 sha512 genpkey pkey pkeyparam pkeyutl' if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) @@ -59,9 +59,9 @@ _openssl() case $prev in -CA|-CAfile|-CAkey|-CAserial|-cert|-certfile|-config|-content| \ -dcert|-dkey|-dhparam|-extfile|-in|-inkey|-kfile|-key|-keyout| \ - -out|-oid|-prvrify|-rand|-recip|-revoke|-sess_in|-sess_out| \ - -spkac|-sign|-signkey|-signer|-signature|-ss_cert|-untrusted| \ - -verify) + -out|-oid|-paramfile|-peerkey|-prvrify|-rand|-recip|-revoke| \ + -sess_in|-sess_out|-spkac|-sigfile|-sign|-signkey|-signer| \ + -signature|-ss_cert|-untrusted|-verify) _filedir return ;; @@ -74,7 +74,7 @@ _openssl() return ;; -inform|-outform|-keyform|-certform|-CAform|-CAkeyform|-dkeyform|\ - -dcertform) + -dcertform|-peerform) formats='DER PEM' case $command in x509) @@ -83,12 +83,15 @@ _openssl() smime) formats+=" SMIME" ;; + pkeyutl) + formats+=" ENGINE" + ;; esac COMPREPLY=( $( compgen -W "$formats" -- "$cur" ) ) return ;; -connect) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -starttls) @@ -100,6 +103,10 @@ _openssl() -- "$cur" ) ) return ;; + -kdf) + COMPREPLY=( $( compgen -W 'TLS1-PRF HKDF' -- "$cur" ) ) + return + ;; esac if [[ "$cur" == -* ]]; then @@ -151,6 +158,10 @@ _openssl() gendsa) options='-out -des -des3 -idea -rand' ;; + genpkey) + options='-out -outform -pass -cipher -engine -paramfile + -algorithm -pkeyopt -genparam -text' + ;; genrsa) options='-out -passout -des -des3 -idea -f4 -3 -rand' ;; @@ -158,6 +169,20 @@ _openssl() options='-inform -outform -in -out -print_certs -text -noout' ;; + pkey) + options='-inform -outform -in -passin -out -passout + -traditional -cipher -text -text_pub -noout -pubin + -pubout -engine' + ;; + pkeyparam) + options='-in -out -text -noout -engine' + ;; + pkeyutl) + options='-in -out -sigfile -inkey -keyform -passin -peerkey + -peerform -pubin -certin -rev -sign -verify + -verifyrecover -encrypt -decrypt -derive -kdf -kdflen + -pkeyopt -hexdump -asn1parse -engine -engine_impl' + ;; rand) options='-out -rand -base64' ;; diff --git a/completions/perltidy b/completions/perltidy new file mode 100644 index 00000000..10c49cab --- /dev/null +++ b/completions/perltidy @@ -0,0 +1,53 @@ +# perltidy(1) completion -*- shell-script -*- + +_perltidy() +{ + local cur prev words cword + _init_completion -n = || return + + case $prev in + -h|--help) + return + ;; + -o) + _filedir + return + ;; + esac + + case $cur in + -pro=*) + cur="${cur#*=}" + _filedir + return + ;; + -ole=*) + COMPREPLY=( $( compgen -W 'dos win mac unix' -- "${cur#*=}" ) ) + return + ;; + -bt=*|-pt=*|-sbt=*|-bvt=*|-pvt=*|-sbvt=*|-bvtc=*|-pvtc=*|-sbvtc=*|\ + -cti=*|-kbl=*|-vt=*) + COMPREPLY=( $( compgen -W '0 1 2' -- "${cur#*=}" ) ) + return + ;; + -vtc=*) + COMPREPLY=( $( compgen -W '0 1' -- "${cur#*=}" ) ) + return + ;; + -cab=*) + COMPREPLY=( $( compgen -W '0 1 2 3' -- "${cur#*=}" ) ) + return + ;; + -*=) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + else + _filedir 'p[lm]' + fi +} && +complete -F _perltidy perltidy diff --git a/completions/ping b/completions/ping index 221fdd51..cc1bca7a 100644 --- a/completions/ping +++ b/completions/ping @@ -5,6 +5,8 @@ _ping() local cur prev words cword _init_completion -n = || return + local ipvx + case $prev in -c|-F|-G|-g|-h|-i|-l|-m|-P|-p|-s|-t|-V|-W|-w|-z) return @@ -47,6 +49,9 @@ _ping() COMPREPLY=( $( compgen -W 'tsonly tsandaddr' -- "$cur" ) ) return ;; + -4|-6) + ipvx=$prev + ;; esac if [[ $cur == -* ]]; then @@ -54,7 +59,8 @@ _ping() return fi - _known_hosts_real "$cur" + [[ $1 == *6 ]] && ipvx=-6 + _known_hosts_real $ipvx -- "$cur" } && complete -F _ping ping ping6 diff --git a/completions/psql b/completions/psql index 668bb9ef..86a66030 100644 --- a/completions/psql +++ b/completions/psql @@ -25,7 +25,7 @@ _createdb() case $prev in -h|--host) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -U|--username|-O|--owner) @@ -65,7 +65,7 @@ _createuser() return ;; -h|--host) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -U|--username) @@ -92,7 +92,7 @@ _dropdb() case $prev in -h|--host) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -U|--username) @@ -128,7 +128,7 @@ _dropuser() return ;; -h|--host) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -U|--username) @@ -157,7 +157,7 @@ _psql() case $prev in -h|--host) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -U|--username) diff --git a/completions/puppet b/completions/puppet index b36b0341..59a477ed 100644 --- a/completions/puppet +++ b/completions/puppet @@ -115,7 +115,7 @@ _puppet() agent) case $prev in --certname) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; --digest) @@ -123,7 +123,7 @@ _puppet() return ;; --fqdn) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -l|--logdest) @@ -185,7 +185,7 @@ _puppet() return ;; generate|--generate) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; clean|print|revoke|--clean|--print|--revoke) @@ -237,7 +237,7 @@ _puppet() filebucket) case $prev in -s|--server) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -b|--bucket) @@ -261,7 +261,7 @@ _puppet() return ;; --host) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -t|--tag) @@ -271,7 +271,7 @@ _puppet() if [[ "$cur" == -* ]]; then _puppet_subcmd_opts "$1" $subcommand else - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" fi return esac diff --git a/completions/pv b/completions/pv new file mode 100644 index 00000000..28514e7c --- /dev/null +++ b/completions/pv @@ -0,0 +1,30 @@ +# pv(1) completion -*- shell-script -*- + +_pv() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h|--help|-V|--version|-A|--last-written|-F|--format|-D|--delay-start|\ + -i|--interval|-w|--width|-H|--height|-N|--name|-L|--rate-limit|\ + -B|--buffer-size) + return + ;; + -R|--remote) + _pids + return + ;; + -P|--pidfile|-d|--watchfd) + _filedir pid + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + else + _filedir + fi +} && +complete -F _pv pv diff --git a/completions/pycodestyle b/completions/pycodestyle new file mode 100644 index 00000000..7a62ac07 --- /dev/null +++ b/completions/pycodestyle @@ -0,0 +1,34 @@ +# pycodestyle completion -*- shell-script -*- + +_pycodestyle() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -h|--help|--version) + return + ;; + --format) + COMPREPLY=( $( compgen -W 'default pylint' -- "$cur" ) ) + return + ;; + --config) + _filedir + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir py +} && +complete -F _pycodestyle pycodestyle + +# ex: filetype=sh diff --git a/completions/pylint b/completions/pylint index 0383c7e2..b1d80918 100644 --- a/completions/pylint +++ b/completions/pylint @@ -5,6 +5,8 @@ _pylint() local cur prev words cword split _init_completion -s || return + local python=python; [[ $1 == *3* ]] && python=python3 + case $prev in --version|-h|--help|--long-help|--help-msg|--init-hook|--ignore|-e|\ --enable|-d|--disable|--evaluation|--max-line-length|\ @@ -34,8 +36,8 @@ _pylint() --load-plugins|--deprecated-modules) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," cur="${cur##*,}" - _xfunc python _python_modules - COMPREPLY=( ${COMPREPLY[@]/#/$prefix} ) + _xfunc python _python_modules $python + [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) return ;; -f|--format) @@ -58,9 +60,9 @@ _pylint() return fi - _xfunc python _python_modules + _xfunc python _python_modules $python _filedir py } && -complete -F _pylint pylint +complete -F _pylint pylint pylint-2 pylint-3 # ex: filetype=sh diff --git a/completions/python b/completions/python index 758b44ef..f8ef6d0c 100644 --- a/completions/python +++ b/completions/python @@ -3,8 +3,8 @@ _python_modules() { COMPREPLY+=( $( compgen -W \ - "$( ${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python 2>/dev/null )" \ - -- "$cur" ) ) + "$( ${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python $cur \ + 2>/dev/null )" -- "$cur" ) ) } _python() diff --git a/completions/radvdump b/completions/radvdump new file mode 100644 index 00000000..7280a7a1 --- /dev/null +++ b/completions/radvdump @@ -0,0 +1,22 @@ +# radvdump(8) completion -*- shell-script -*- + +_radvdump() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h|--help|-v|--version) + return + ;; + -d|--debug) + COMPREPLY=( $( compgen -W '{1..4}' -- "$cur" ) ) + return + ;; + esac + + COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) +} && +complete -F _radvdump radvdump + +# ex: filetype=sh diff --git a/completions/rdesktop b/completions/rdesktop index acc43098..1ad6978d 100644 --- a/completions/rdesktop +++ b/completions/rdesktop @@ -48,7 +48,7 @@ _rdesktop() local opts=( $( _parse_help "$1" ) ) COMPREPLY=( $( compgen -W '${opts[@]%:}' -- "$cur" ) ) else - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" fi } && diff --git a/completions/reportbug b/completions/reportbug index 1049d194..c13cc627 100644 --- a/completions/reportbug +++ b/completions/reportbug @@ -2,11 +2,11 @@ _reportbug() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s || return case $prev in - -f|--filename|-i|--include|--mta|-o|--output) + -f|--filename|-i|--include|--mta|-o|--output|-A|--attach) _filedir return ;; @@ -55,26 +55,21 @@ _reportbug() ;; esac - 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 press project qa.debian.org release-notes - security.debian.org tech-ctte upgrade-reports www.debian.org' \ - -- "$cur" ) $( apt-cache pkgnames -- "$cur" 2> /dev/null ) ) - _filedir + $split && return + + COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) + wnpp boot-floppies kernel bugs.debian.org + cdimage.debian.org general installation-reports + listarchives lists.debian.org mirrors nm.debian.org + press project qa.debian.org release-notes + security.debian.org tech-ctte upgrade-reports + www.debian.org' -- "$cur" ) + $( apt-cache pkgnames -- "$cur" 2>/dev/null ) ) + if [[ $COMPREPLY == -*= ]]; then + compopt -o nospace + else + _filedir + fi } && complete -F _reportbug reportbug diff --git a/completions/ri b/completions/ri index 16e44664..ba4dbe51 100644 --- a/completions/ri +++ b/completions/ri @@ -90,7 +90,7 @@ _ri() if [[ $ri_version == integrated ]]; then # integrated ri from Ruby 1.9 classes=( $( ri -c 2>/dev/null | ruby -ne 'if /^\s*$/..$stdin.eof then \ - if /, [A-Z]+/ then print; end; end' 2>/dev/null ) ) + if /^ +[A-Z]/ then print; end; end' 2>/dev/null ) ) elif [[ $ri_major && $ri_major -ge 3 ]]; then classes=( $( ri -l 2>/dev/null ) ) elif [[ $ri_version == "ri 1.8a" ]]; then diff --git a/completions/rsync b/completions/rsync index d72f6324..22593577 100644 --- a/completions/rsync +++ b/completions/rsync @@ -5,8 +5,6 @@ _rsync() local cur prev words cword split _init_completion -s -n : || return - _expand || return - case $prev in --config|--password-file|--include-from|--exclude-from|--files-from|\ --log-file|--write-batch|--only-write-batch|--read-batch) @@ -34,6 +32,8 @@ _rsync() $split && return + _expand || return + case $cur in -*) COMPREPLY=( $( compgen -W '--verbose --quiet --no-motd --checksum @@ -76,7 +76,7 @@ _rsync() [[ $shell == ssh ]] && _xfunc ssh _scp_remote_files ;; *) - _known_hosts_real -c -a "$cur" + _known_hosts_real -c -a -- "$cur" _xfunc ssh _scp_local_files ;; esac diff --git a/completions/ss b/completions/ss index 63e6a458..b240c5e0 100644 --- a/completions/ss +++ b/completions/ss @@ -16,9 +16,10 @@ _ss() ;; -A|--query) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $( compgen -P "$prefix" -W '$( "$1" --help | \ + COMPREPLY=( $( compgen -W '$( "$1" --help | \ command sed -e "s/|/ /g" -ne "s/.*QUERY := {\([^}]*\)}.*/\1/p" )' \ -- "${cur##*,}" ) ) + [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) return ;; -D|--diag|-F|--filter) diff --git a/completions/ssh b/completions/ssh index ecd50e57..ba3d4b45 100644 --- a/completions/ssh +++ b/completions/ssh @@ -43,7 +43,7 @@ _ssh_options() HostbasedAuthentication HostKeyAlgorithms HostKeyAlias HostName IdentityFile IdentitiesOnly IPQoS KbdInteractiveDevices KexAlgorithms LocalCommand LocalForward LogLevel MACs - NoHostAuthenticationForLocalhost NumberOfPasswordPrompts + NoHostAuthenticationForLocalhost NumberOfPasswordPrompts ProxyJump PasswordAuthentication PermitLocalCommand PKCS11Provider Port PreferredAuthentications Protocol ProxyCommand PubkeyAuthentication RekeyLimit RemoteForward RequestTTY RhostsRSAAuthentication @@ -86,6 +86,9 @@ _ssh_suboption() Cipher) COMPREPLY=( $( compgen -W 'blowfish des 3des' -- "$cur" ) ) ;; + ProxyJump) + _known_hosts_real -a -F "$configfile" -- "$cur" + ;; IPQoS) COMPREPLY=( $( compgen -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3} cs{0..7} ef lowdelay throughput reliability' -- "$cur" ) ) @@ -159,17 +162,30 @@ _ssh() local -a config + local configfile + _ssh_configfile + _ssh_suboption_check "$1" && return + local ipvx + case $prev in -F|-i|-S) _filedir return ;; + -I) + _filedir so + return + ;; -c) _ssh_ciphers "$1" return ;; + -J) + _known_hosts_real -a -F "$configfile" -- "$cur" + return + ;; -m) _ssh_macs "$1" return @@ -198,9 +214,12 @@ _ssh() _ip_addresses return ;; - -D|-e|-I|-L|-p|-R|-W) + -D|-e|-L|-p|-R|-W) return ;; + -4|-6) + ipvx=$prev + ;; esac if [[ "$cur" == -F* ]]; then @@ -212,9 +231,7 @@ _ssh() elif [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) else - local configfile - _ssh_configfile - _known_hosts_real -a -F "$configfile" "$cur" + _known_hosts_real $ipvx -a -F "$configfile" -- "$cur" local args _count_args @@ -233,8 +250,13 @@ _sftp() local cur prev words cword _init_completion || return + local configfile + _ssh_configfile + _ssh_suboption_check && return + local ipvx + case $prev in -b|-F|-i) _filedir @@ -255,6 +277,9 @@ _sftp() -B|-D|-l|-P|-R|-s) return ;; + -4|-6) + ipvx=$prev + ;; esac if [[ "$cur" == -F* ]]; then @@ -266,9 +291,7 @@ _sftp() elif [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) else - local configfile - _ssh_configfile - _known_hosts_real -a -F "$configfile" "$cur" + _known_hosts_real $ipvx -a -F "$configfile" -- "$cur" fi } && shopt -u hostcomplete && complete -F _sftp sftp @@ -344,13 +367,16 @@ _scp() local cur prev words cword _init_completion -n : || return - local prefix + local configfile + _ssh_configfile _ssh_suboption_check && { COMPREPLY=( "${COMPREPLY[@]/%/ }" ) return } + local ipvx + case $prev in -l|-P) return @@ -374,6 +400,9 @@ _scp() compopt +o nospace return ;; + -4|-6) + ipvx=$prev + ;; esac _expand || return @@ -383,6 +412,8 @@ _scp() *:*) _scp_remote_files ; return ;; esac + local prefix + if [[ "$cur" == -F* ]]; then cur=${cur#-F} prefix=-F @@ -398,9 +429,7 @@ _scp() # not a known host, pass through ;; *) - local configfile - _ssh_configfile - _known_hosts_real -c -a -F "$configfile" "$cur" + _known_hosts_real $ipvx -c -a -F "$configfile" -- "$cur" ;; esac fi diff --git a/completions/ssh-add b/completions/ssh-add index 1885c37a..4d47c0d0 100644 --- a/completions/ssh-add +++ b/completions/ssh-add @@ -6,7 +6,11 @@ _ssh_add() _init_completion || return case $prev in - -t|-s|-e) + -t) + return + ;; + -s|-e) + _filedir so return ;; esac diff --git a/completions/ssh-copy-id b/completions/ssh-copy-id index bd8c8fe0..1e81172c 100644 --- a/completions/ssh-copy-id +++ b/completions/ssh-copy-id @@ -15,7 +15,7 @@ _ssh_copy_id() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else - _known_hosts_real -a "$cur" + _known_hosts_real -a -- "$cur" fi } && complete -F _ssh_copy_id ssh-copy-id diff --git a/completions/ssh-keygen b/completions/ssh-keygen index f72b9aa2..d1eafa9e 100644 --- a/completions/ssh-keygen +++ b/completions/ssh-keygen @@ -6,12 +6,20 @@ _ssh_keygen() _init_completion -n = || return case $prev in - -a|-b|-C|-D|-I|-J|-j|-M|-N|-n|-r|-P|-S|-V|-W|-z) + -a|-b|-C|-I|-J|-j|-M|-N|-n|-r|-P|-S|-V|-W|-z) + return + ;; + -E) + COMPREPLY=( $( compgen -W 'md5 sha256' -- "$cur" ) ) return ;; -F|-R) # TODO: trim this down to actual entries in known hosts files - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" + return + ;; + -D) + _filedir so return ;; -f|-G|-K|-s|-T) diff --git a/completions/sshfs b/completions/sshfs index 4f6d1a1b..4afcc994 100644 --- a/completions/sshfs +++ b/completions/sshfs @@ -16,7 +16,7 @@ _sshfs() return fi - [[ "$cur" == @(*/|[.~])* ]] || _known_hosts_real -c -a "$cur" + [[ "$cur" == @(*/|[.~])* ]] || _known_hosts_real -c -a -- "$cur" _xfunc ssh _scp_local_files -d } && diff --git a/completions/sshmitm b/completions/sshmitm index f7332201..192835c0 100644 --- a/completions/sshmitm +++ b/completions/sshmitm @@ -8,7 +8,7 @@ _sshmitm() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) else - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" fi } && diff --git a/completions/tar b/completions/tar index 5a854edd..2886f745 100644 --- a/completions/tar +++ b/completions/tar @@ -433,9 +433,9 @@ __tar_cleanup_prev() __tar_detect_ext() { - local tars='@(@(tar|gem|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma)))|t@([abglx]z|b?(z)2))' + local tars='@(@(tar|gem|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma|o)))|t@([abglx]z|b?(z)2))' ext="$tars" - regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[bgx]z\|bz2\|lz\(ma\)\?\)\)\?\|t\([abglx]z\|bz\?2\)\)' + regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[bgx]z\|bz2\|lz\(ma\|o\)\?\)\)\?\|t\([abglx]z\|bz\?2\)\)' case "$tar_mode_arg" in --*) @@ -453,7 +453,7 @@ __tar_detect_ext() ;; +([^ZzJjy])f) ext="$tars" - regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[bgx]z\|bz2\|lz\(ma\)\?\)\)\?\|t\([abglx]z\|bz\?2\)\)' + regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[bgx]z\|bz2\|lz\(ma\|o\)\?\)\)\?\|t\([abglx]z\|bz\?2\)\)' ;; *[Zz]*f) ext='@(@(t?(ar.)|gem.|spkg.)@(gz|Z)|taz)' diff --git a/completions/tox b/completions/tox new file mode 100644 index 00000000..5812fcbf --- /dev/null +++ b/completions/tox @@ -0,0 +1,34 @@ +# tox completion -*- shell-script -*- + +_tox() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h|--help|--version|-n|--num|-i|--index-url|--hashseed|--force-dep) + return + ;; + -c) + _filedir ini + return + ;; + --installpkg|--result-json|--workdir) + _filedir + return + ;; + -e) + local envs=$( "$1" --listenvs-all 2>/dev/null ) + local prefix=""; [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=( $( compgen -W "$envs ALL" -- "${cur##*,}" ) ) + [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + return + fi +} && +complete -F _tox tox diff --git a/completions/tracepath b/completions/tracepath index 06455cb5..bd2f3ea3 100644 --- a/completions/tracepath +++ b/completions/tracepath @@ -16,7 +16,9 @@ _tracepath() return fi - _known_hosts_real "$cur" + local ipvx + [[ $1 == *6 ]] && ipvx=-6 + _known_hosts_real $ipvx -- "$cur" } && complete -F _tracepath tracepath tracepath6 diff --git a/completions/tshark b/completions/tshark index 34d93a0d..bd795c24 100644 --- a/completions/tshark +++ b/completions/tshark @@ -51,9 +51,9 @@ _tshark() ;; -O) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $( compgen -P "$prefix" -W \ - "$( "$1" -G protocols 2>&1 | cut -f 3 )" \ + COMPREPLY=( $( compgen -W "$( "$1" -G protocols 2>&1 | cut -f 3 )" \ -- "${cur##*,}" ) ) + [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) return ;; -T) diff --git a/completions/uscan b/completions/uscan index fc05d2e8..aafc1dfd 100644 --- a/completions/uscan +++ b/completions/uscan @@ -2,7 +2,7 @@ _uscan() { - local cur prev split + local cur prev words cword split _init_completion -s || return case $prev in diff --git a/completions/useradd b/completions/useradd index 9ed2f9f6..fa8e58cc 100644 --- a/completions/useradd +++ b/completions/useradd @@ -25,7 +25,8 @@ _useradd() ;; -G|--groups) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $( compgen -P "$prefix" -g -- "${cur##*,}" ) ) + COMPREPLY=( $( compgen -g -- "${cur##*,}" ) ) + [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) return ;; -s|--shell) diff --git a/completions/usermod b/completions/usermod index 03cc89fe..9d478c3a 100644 --- a/completions/usermod +++ b/completions/usermod @@ -21,7 +21,8 @@ _usermod() ;; -G|--groups) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $( compgen -P "$prefix" -g -- "${cur##*,}" ) ) + COMPREPLY=( $( compgen -g -- "${cur##*,}" ) ) + [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) return ;; -R|--root) diff --git a/completions/vncviewer b/completions/vncviewer index 4a3f2abd..9b307331 100644 --- a/completions/vncviewer +++ b/completions/vncviewer @@ -32,7 +32,7 @@ _tightvncviewer() return ;; -via) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; esac @@ -44,7 +44,7 @@ _tightvncviewer() -owncmap -truecolour -truecolor -depth -compresslevel -quality -nojpeg -nocursorshape -x11cursor' -- "$cur" ) ) else - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" fi } && complete -F _tightvncviewer tightvncviewer @@ -72,7 +72,7 @@ _xvnc4viewer() ;; # -via -[vV][iI][aA]) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; esac @@ -87,13 +87,14 @@ _xvnc4viewer() WMDecorationWidth ZlibLevel ) [[ "$cur" == --* ]] && dash=-- || dash=- - local option reset=$( shopt -p nocasematch ); shopt -s nocasematch + local IFS=$' \t\n' reset=$( shopt -p nocasematch ); shopt -s nocasematch + local option COMPREPLY=( $( for option in "${options[@]}"; do [[ $dash$option == "$cur"* ]] && printf '%s\n' $dash$option done ) ) $reset else - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" fi } && complete -F _xvnc4viewer xvnc4viewer diff --git a/completions/vpnc b/completions/vpnc index 4e1fa81e..b7b8c14a 100644 --- a/completions/vpnc +++ b/completions/vpnc @@ -8,11 +8,11 @@ _vpnc() case $prev in --help|--long-help|--version|--id|--username|--domain|--ifname|\ --application-version|--local-addr|--local-port|--udp-port|--dpd-idle|\ - --target-network) + --target-network|--ifmtu) return ;; --gateway) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; --vendor) @@ -36,6 +36,10 @@ _vpnc() COMPREPLY=( $( compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur" ) ) return ;; + --ifmode) + COMPREPLY=( $( compgen -W 'tun tap' -- "$cur" ) ) + return + ;; --debug) COMPREPLY=( $( compgen -W '0 1 2 3 99' -- "$cur" ) ) return @@ -48,13 +52,29 @@ _vpnc() _filedir -d return ;; + --password-helper) + compopt -o filenames + COMPREPLY=( $( compgen -c -- "$cur" ) ) + return + ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help )' \ -- "$cur" ) ) + elif [[ "$cur" == */* ]]; then + # explicit filename + _filedir conf else - COMPREPLY=( $( compgen -W '$( command ls /etc/vpnc )' -- "$cur" ) ) + # config name, /etc/vpnc/<name>.conf + local IFS=$' \t\n' reset=$(shopt -p nullglob); shopt -s nullglob + local -a configs=( /etc/vpnc/*.conf ) + configs=( "${configs[@]##*/}" ) + configs=( "${configs[@]%.conf}" ) + $reset + IFS=$'\n' + compopt -o filenames + COMPREPLY=( $( compgen -W '${configs[@]}' -- "$cur" ) ) fi } && complete -F _vpnc vpnc diff --git a/completions/webmitm b/completions/webmitm index a8484ca1..308f2281 100644 --- a/completions/webmitm +++ b/completions/webmitm @@ -8,7 +8,7 @@ _webmitm() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) else - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" fi } && diff --git a/completions/wget b/completions/wget index b1878fdb..95011bef 100644 --- a/completions/wget +++ b/completions/wget @@ -18,7 +18,7 @@ _wget() return ;; -D|--domains|--exclude-domains) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; --restrict-file-names) diff --git a/completions/wol b/completions/wol index 50653385..1ce25b05 100644 --- a/completions/wol +++ b/completions/wol @@ -16,7 +16,7 @@ _wol() command sed -ne 's/.*[[:space:]]Bcast:\([^[:space:]]*\).*/\1/p' -ne \ 's/.*inet.*[[:space:]]brd[[:space:]]\([^[:space:]]*\).*/\1/p' -ne \ 's/.*[[:space:]]broadcast[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' ) ) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" return ;; -f|--file) diff --git a/completions/wsimport b/completions/wsimport index d53a17fb..a7f591e7 100644 --- a/completions/wsimport +++ b/completions/wsimport @@ -32,7 +32,7 @@ _wsimport() esac if [[ $cur == -httpproxy:* ]]; then - _known_hosts_real "${cur#-httpproxy:}" + _known_hosts_real -- "${cur#-httpproxy:}" return elif [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' \ diff --git a/completions/xdg-mime b/completions/xdg-mime new file mode 100644 index 00000000..92d5b838 --- /dev/null +++ b/completions/xdg-mime @@ -0,0 +1,71 @@ +# xdg-mime(1) completion -*- shell-script -*- + +_xdg_mime_mimetype() +{ + COMPREPLY+=( $( compgen -S / -W 'application audio font image message model + multipart text video' -- "$cur" ) ) + [[ $COMPREPLY == */ ]] && compopt -o nospace +} + +_xdg_mime() +{ + local cur prev words cword + _init_completion || return + + local args + _count_args + + if [[ $args -eq 1 ]]; then + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '--help --manual --version' -- "$cur" ) ) + return + fi + COMPREPLY=( $( compgen -W \ + 'query default install uninstall' -- "$cur" ) ) + return + fi + + case ${words[1]} in + query) + if [[ $args -eq 2 ]]; then + COMPREPLY=( $( compgen -W 'filetype default' -- "$cur" ) ) + return + fi + case ${words[2]} in # TODO and $args -eq 3 (takes only one arg!) + filetype) _filedir ;; + default) _xdg_mime_mimetype ;; + esac + ;; + default) + if [[ $args -eq 2 ]]; then + local IFS=$' \t\n' reset=$(shopt -p nullglob); shopt -s nullglob + local -a desktops=( /usr/share/applications/*.desktop ) + desktops=( "${desktops[@]##*/}" ) + $reset + IFS=$'\n' + COMPREPLY=( $( compgen -W '${desktops[@]}' -- "$cur" ) ) + else + _xdg_mime_mimetype + fi + ;; + install) + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '--mode --novendor' -- "$cur" ) ) + elif [[ $prev == --mode ]]; then + COMPREPLY=( $( compgen -W 'user system' -- "$cur" ) ) + else + _filedir xml + fi + ;; + uninstall) + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '--mode' -- "$cur" ) ) + elif [[ $prev == --mode ]]; then + COMPREPLY=( $( compgen -W 'user system' -- "$cur" ) ) + else + _filedir xml + fi + ;; + esac +} && +complete -F _xdg_mime xdg-mime diff --git a/completions/xdg-settings b/completions/xdg-settings new file mode 100644 index 00000000..15f040d4 --- /dev/null +++ b/completions/xdg-settings @@ -0,0 +1,29 @@ +# xdg-settings completion -*- shell-script -*- + +_xdg_settings() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help|--list|--manual|--version) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( "$1" --help | + command sed -e "s/[{|]/\n/g" | _parse_help - )' -- "$cur" ) ) + return + fi + + local args + _count_args + if [[ $args -eq 1 ]]; then + COMPREPLY=( $( compgen -W "get check set" -- "$cur" ) ) + elif [[ $args -eq 2 ]]; then + COMPREPLY=( $( compgen -W \ + '$( "$1" --list | awk "!/^Known/ { print \$1 }" )' -- "$cur" ) ) + fi +} && +complete -F _xdg_settings xdg-settings diff --git a/completions/xgamma b/completions/xgamma index eda46d62..7b9d43cc 100644 --- a/completions/xgamma +++ b/completions/xgamma @@ -37,7 +37,7 @@ _xgamma() "${cur##*.}" ) ) elif [[ "$cur" != *:* ]]; then # complete hostnames - _known_hosts_real -c "$cur" + _known_hosts_real -c -- "$cur" if [[ ! $cur ]]; then COMPREPLY+=( : ) fi diff --git a/completions/xhost b/completions/xhost index 8f605a90..53b3695b 100644 --- a/completions/xhost +++ b/completions/xhost @@ -6,9 +6,9 @@ _xhost () _init_completion || return case $cur in - +*) _known_hosts_real -p+ "${cur:1}" ;; - -*) _known_hosts_real -p- "${cur:1}" ;; - *) _known_hosts_real "$cur" ;; + +*) _known_hosts_real -p+ -- "${cur:1}" ;; + -*) _known_hosts_real -p- -- "${cur:1}" ;; + *) _known_hosts_real -- "$cur" ;; esac } && complete -F _xhost xhost diff --git a/completions/xm b/completions/xm index 93852f61..c720fae1 100644 --- a/completions/xm +++ b/completions/xm @@ -19,7 +19,7 @@ _xm() # TODO: _split_longopt - local command options + local args command commands options commands='console vncviewer create new delete destroy domid domname dump-core list mem-max mem-set migrate pause reboot rename reset @@ -94,7 +94,7 @@ _xm() _xen_domain_names ;; 3) - _known_hosts_real "$cur" + _known_hosts_real -- "$cur" ;; esac ;; diff --git a/completions/xz b/completions/xz index 53e6b398..7499ffb5 100644 --- a/completions/xz +++ b/completions/xz @@ -40,8 +40,6 @@ _xz() $split && return - _expand || return - if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help ) {-1..-9}' \ -- "$cur" ) ) @@ -49,6 +47,8 @@ _xz() return fi + _tilde "$cur" || return + local IFS=$'\n' compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ diff --git a/completions/zopfli b/completions/zopfli index 23da6dbf..ee2c890c 100644 --- a/completions/zopfli +++ b/completions/zopfli @@ -18,10 +18,9 @@ _zopfli() return fi - local IFS=$'\n' xspec="*.@(gz|t[ag]z)" - - _expand || return + _tilde "$cur" || return + local IFS=$'\n' xspec="*.@(gz|t[ag]z)" compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ $( compgen -d -- "$cur" ) ) diff --git a/configure.ac b/configure.ac index 3ea55598..3be96fdf 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.60]) -AC_INIT([bash-completion], [2.7]) +AC_INIT([bash-completion], [2.8]) AM_INIT_AUTOMAKE([foreign dist-xz no-dist-gzip -Wall -Werror]) AC_PROG_LN_S AC_PROG_MKDIR_P diff --git a/doc/testing.txt b/doc/testing.txt index 0e7d3d31..2ce7f373 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -57,10 +57,10 @@ The tests are grouped into different areas, called _tool_ in DejaGnu: *completion*:: Functional tests per completion. -*install*:: +*install*:: Functional tests for installation and caching of the main bash-completion package. -*unit*:: +*unit*:: Unit tests for bash-completion helper functions. Each tool has a slightly different way of loading the test fixtures, see @@ -184,7 +184,6 @@ test-run fails. set -e # Exit if simple command fails set -u # Error if variable is undefined -CRON=running LOG=/tmp/bash-completion.log~ # Retrieve latest sources @@ -282,7 +281,7 @@ looking for): UNRESOLVED: Tab should complete ssh known-hosts at prompt --------------------------------------------------------- -From there, search up for the first line saying: +From there, search up for the first line saying: ------------------------------------------------- expect: does "..." match regular expression "..." @@ -418,7 +417,7 @@ in `dbg.log` to find out what's going wrong. Open `dbg.log` and search for FAIL: Environment should stay clean ----------------------------------- -From there, search up for the first line saying: +From there, search up for the first line saying: ------------------------------------------------- expect: does "..." match regular expression "..." @@ -495,8 +494,8 @@ When the completions are tested, invoking DejaGnu will result in a call to | ,--+-+ "Actual completion tests" | V / +------------------------------+ +----------+-----------+ +-----------------------+ - | completion/*.exp +<---| lib/completions/*.exp | - +----------+-----------+ +-----------------------+ + | completion/*.exp +<---| lib/completions/*.exp | + +----------+-----------+ +-----------------------+ | \ ,+--------------------------------+ | `----------------------+-+ "Completion invocation tests" | V +----------------------------------+ diff --git a/extra/make-changelog.py b/extra/make-changelog.py index 184a1d2e..bb589775 100755 --- a/extra/make-changelog.py +++ b/extra/make-changelog.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- encoding: utf-8 -*- from collections import defaultdict diff --git a/helpers/python b/helpers/python index 23c14bde..b6c4d5ed 100644 --- a/helpers/python +++ b/helpers/python @@ -1,6 +1,14 @@ # -*- python -*- import pkgutil +import sys -for mod in pkgutil.iter_modules(): +# walk_packages() is much slower than iter_modules(), use it only when +# completing something with a dot in it. +if len(sys.argv) > 1 and "." in sys.argv[1]: + walker = pkgutil.walk_packages +else: + walker = pkgutil.iter_modules + +for mod in walker(): print(mod[1]) diff --git a/test/completion/acroread.exp b/test/completion/acroread.exp index 95704601..e23e98dd 100644 --- a/test/completion/acroread.exp +++ b/test/completion/acroread.exp @@ -1,3 +1 @@ -assert_xspec_completion_installed acroread - -source "$::srcdir/lib/completions/acroread.exp" +assert_source_completions acroread diff --git a/test/completion/ccze.exp b/test/completion/ccze.exp new file mode 100644 index 00000000..4ec83394 --- /dev/null +++ b/test/completion/ccze.exp @@ -0,0 +1 @@ +assert_source_completions ccze diff --git a/test/completion/cfrun.exp b/test/completion/cfrun.exp new file mode 100644 index 00000000..f261c3ba --- /dev/null +++ b/test/completion/cfrun.exp @@ -0,0 +1 @@ +assert_source_completions cfrun diff --git a/test/completion/chfn.exp b/test/completion/chfn.exp new file mode 100644 index 00000000..c67743c2 --- /dev/null +++ b/test/completion/chfn.exp @@ -0,0 +1 @@ +assert_source_completions chfn diff --git a/test/completion/complete.exp b/test/completion/complete.exp new file mode 100644 index 00000000..3872244f --- /dev/null +++ b/test/completion/complete.exp @@ -0,0 +1 @@ +assert_source_completions complete diff --git a/test/completion/cpan2dist.exp b/test/completion/cpan2dist.exp new file mode 100644 index 00000000..c9913b3b --- /dev/null +++ b/test/completion/cpan2dist.exp @@ -0,0 +1 @@ +assert_source_completions cpan2dist diff --git a/test/completion/ebtables.exp b/test/completion/ebtables.exp new file mode 100644 index 00000000..34399189 --- /dev/null +++ b/test/completion/ebtables.exp @@ -0,0 +1 @@ +assert_source_completions ebtables diff --git a/test/completion/freeciv-gtk2.exp b/test/completion/freeciv-gtk2.exp new file mode 100644 index 00000000..4f96469d --- /dev/null +++ b/test/completion/freeciv-gtk2.exp @@ -0,0 +1 @@ +assert_source_completions freeciv-gtk2 diff --git a/test/completion/freeciv-server.exp b/test/completion/freeciv-server.exp new file mode 100644 index 00000000..92b25ed0 --- /dev/null +++ b/test/completion/freeciv-server.exp @@ -0,0 +1 @@ +assert_source_completions freeciv-server diff --git a/test/completion/geoiplookup.exp b/test/completion/geoiplookup.exp new file mode 100644 index 00000000..b2f6bcec --- /dev/null +++ b/test/completion/geoiplookup.exp @@ -0,0 +1 @@ +assert_source_completions geoiplookup diff --git a/test/completion/getconf.exp b/test/completion/getconf.exp new file mode 100644 index 00000000..f1b010bd --- /dev/null +++ b/test/completion/getconf.exp @@ -0,0 +1 @@ +assert_source_completions getconf diff --git a/test/completion/gpg2.exp b/test/completion/gpg2.exp new file mode 100644 index 00000000..4c44ed41 --- /dev/null +++ b/test/completion/gpg2.exp @@ -0,0 +1 @@ +assert_source_completions gpg2 diff --git a/test/completion/groupadd.exp b/test/completion/groupadd.exp new file mode 100644 index 00000000..7cc8e386 --- /dev/null +++ b/test/completion/groupadd.exp @@ -0,0 +1 @@ +assert_source_completions groupadd diff --git a/test/completion/groupdel.exp b/test/completion/groupdel.exp new file mode 100644 index 00000000..337a8310 --- /dev/null +++ b/test/completion/groupdel.exp @@ -0,0 +1 @@ +assert_source_completions groupdel diff --git a/test/completion/groupmems.exp b/test/completion/groupmems.exp new file mode 100644 index 00000000..6a34f902 --- /dev/null +++ b/test/completion/groupmems.exp @@ -0,0 +1 @@ +assert_source_completions groupmems diff --git a/test/completion/groupmod.exp b/test/completion/groupmod.exp new file mode 100644 index 00000000..74d92e6e --- /dev/null +++ b/test/completion/groupmod.exp @@ -0,0 +1 @@ +assert_source_completions groupmod diff --git a/test/completion/hid2hci.exp b/test/completion/hid2hci.exp new file mode 100644 index 00000000..de78db2b --- /dev/null +++ b/test/completion/hid2hci.exp @@ -0,0 +1,3 @@ +assert_bash_exec {OLDPATH="$PATH"; PATH="$PATH:/lib/udev"} +assert_source_completions hid2hci +assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH} diff --git a/test/completion/iptables.exp b/test/completion/iptables.exp new file mode 100644 index 00000000..3c3bbc39 --- /dev/null +++ b/test/completion/iptables.exp @@ -0,0 +1 @@ +assert_source_completions iptables diff --git a/test/completion/kdvi.exp b/test/completion/kdvi.exp index 78bd4a94..9f6aa664 100644 --- a/test/completion/kdvi.exp +++ b/test/completion/kdvi.exp @@ -1,3 +1 @@ -assert_xspec_completion_installed kdvi - -source "$::srcdir/lib/completions/kdvi.exp" +assert_source_completions kdvi diff --git a/test/completion/kpdf.exp b/test/completion/kpdf.exp index 53417c32..d0a17749 100644 --- a/test/completion/kpdf.exp +++ b/test/completion/kpdf.exp @@ -1,3 +1 @@ -assert_xspec_completion_installed kpdf - -source "$::srcdir/lib/completions/kpdf.exp" +assert_source_completions kpdf diff --git a/test/completion/ktutil.exp b/test/completion/ktutil.exp new file mode 100644 index 00000000..430316f3 --- /dev/null +++ b/test/completion/ktutil.exp @@ -0,0 +1 @@ +assert_source_completions ktutil diff --git a/test/completion/lintian-info.exp b/test/completion/lintian-info.exp new file mode 100644 index 00000000..9dcb3fce --- /dev/null +++ b/test/completion/lintian-info.exp @@ -0,0 +1 @@ +assert_source_completions lintian-info diff --git a/test/completion/lintian.exp b/test/completion/lintian.exp new file mode 100644 index 00000000..3662b0de --- /dev/null +++ b/test/completion/lintian.exp @@ -0,0 +1 @@ +assert_source_completions lintian diff --git a/test/completion/lspci.exp b/test/completion/lspci.exp new file mode 100644 index 00000000..7b287827 --- /dev/null +++ b/test/completion/lspci.exp @@ -0,0 +1 @@ +assert_source_completions lspci diff --git a/test/completion/lsscsi.exp b/test/completion/lsscsi.exp new file mode 100644 index 00000000..4b19b1fd --- /dev/null +++ b/test/completion/lsscsi.exp @@ -0,0 +1 @@ +assert_source_completions lsscsi diff --git a/test/completion/lsusb.exp b/test/completion/lsusb.exp new file mode 100644 index 00000000..0a75f462 --- /dev/null +++ b/test/completion/lsusb.exp @@ -0,0 +1 @@ +assert_source_completions lsusb diff --git a/test/completion/munin-node-configure.exp b/test/completion/munin-node-configure.exp new file mode 100644 index 00000000..34318e83 --- /dev/null +++ b/test/completion/munin-node-configure.exp @@ -0,0 +1 @@ +assert_source_completions munin-node-configure diff --git a/test/completion/munin-run.exp b/test/completion/munin-run.exp new file mode 100644 index 00000000..2a7d6c72 --- /dev/null +++ b/test/completion/munin-run.exp @@ -0,0 +1 @@ +assert_source_completions munin-run diff --git a/test/completion/munindoc.exp b/test/completion/munindoc.exp new file mode 100644 index 00000000..ea4d0fa2 --- /dev/null +++ b/test/completion/munindoc.exp @@ -0,0 +1 @@ +assert_source_completions munindoc diff --git a/test/completion/nmap.exp b/test/completion/nmap.exp new file mode 100644 index 00000000..441d1377 --- /dev/null +++ b/test/completion/nmap.exp @@ -0,0 +1 @@ +assert_source_completions nmap diff --git a/test/completion/nproc.exp b/test/completion/nproc.exp new file mode 100644 index 00000000..f2378bfa --- /dev/null +++ b/test/completion/nproc.exp @@ -0,0 +1 @@ +assert_source_completions nproc diff --git a/test/completion/oggdec.exp b/test/completion/oggdec.exp new file mode 100644 index 00000000..b18643d5 --- /dev/null +++ b/test/completion/oggdec.exp @@ -0,0 +1 @@ +assert_source_completions oggdec diff --git a/test/completion/perltidy.exp b/test/completion/perltidy.exp new file mode 100644 index 00000000..c4b577dd --- /dev/null +++ b/test/completion/perltidy.exp @@ -0,0 +1 @@ +assert_source_completions perltidy diff --git a/test/completion/pm-hibernate.exp b/test/completion/pm-hibernate.exp new file mode 100644 index 00000000..b0a6360c --- /dev/null +++ b/test/completion/pm-hibernate.exp @@ -0,0 +1 @@ +assert_source_completions pm-hibernate diff --git a/test/completion/pm-is-supported.exp b/test/completion/pm-is-supported.exp new file mode 100644 index 00000000..62d1f2ff --- /dev/null +++ b/test/completion/pm-is-supported.exp @@ -0,0 +1 @@ +assert_source_completions pm-is-supported diff --git a/test/completion/pm-powersave.exp b/test/completion/pm-powersave.exp new file mode 100644 index 00000000..deb061c6 --- /dev/null +++ b/test/completion/pm-powersave.exp @@ -0,0 +1 @@ +assert_source_completions pm-powersave diff --git a/test/completion/pv.exp b/test/completion/pv.exp new file mode 100644 index 00000000..2dffce6e --- /dev/null +++ b/test/completion/pv.exp @@ -0,0 +1 @@ +assert_source_completions pv diff --git a/test/completion/pycodestyle.exp b/test/completion/pycodestyle.exp new file mode 100644 index 00000000..50a3c496 --- /dev/null +++ b/test/completion/pycodestyle.exp @@ -0,0 +1 @@ +assert_source_completions pycodestyle diff --git a/test/completion/radvdump.exp b/test/completion/radvdump.exp new file mode 100644 index 00000000..e4efa171 --- /dev/null +++ b/test/completion/radvdump.exp @@ -0,0 +1 @@ +assert_source_completions radvdump diff --git a/test/completion/resolvconf.exp b/test/completion/resolvconf.exp new file mode 100644 index 00000000..d4651336 --- /dev/null +++ b/test/completion/resolvconf.exp @@ -0,0 +1 @@ +assert_source_completions resolvconf diff --git a/test/completion/rfkill.exp b/test/completion/rfkill.exp new file mode 100644 index 00000000..74201043 --- /dev/null +++ b/test/completion/rfkill.exp @@ -0,0 +1 @@ +assert_source_completions rfkill diff --git a/test/completion/rrdtool.exp b/test/completion/rrdtool.exp new file mode 100644 index 00000000..72016859 --- /dev/null +++ b/test/completion/rrdtool.exp @@ -0,0 +1 @@ +assert_source_completions rrdtool diff --git a/test/completion/runuser.exp b/test/completion/runuser.exp new file mode 100644 index 00000000..ed0abdcf --- /dev/null +++ b/test/completion/runuser.exp @@ -0,0 +1 @@ +assert_source_completions runuser diff --git a/test/completion/sshfs.exp b/test/completion/sshfs.exp new file mode 100644 index 00000000..e5deaddd --- /dev/null +++ b/test/completion/sshfs.exp @@ -0,0 +1 @@ +assert_source_completions sshfs diff --git a/test/completion/tox.exp b/test/completion/tox.exp new file mode 100644 index 00000000..f383b569 --- /dev/null +++ b/test/completion/tox.exp @@ -0,0 +1 @@ +assert_source_completions tox diff --git a/test/completion/uscan.exp b/test/completion/uscan.exp new file mode 100644 index 00000000..e524e39e --- /dev/null +++ b/test/completion/uscan.exp @@ -0,0 +1 @@ +assert_source_completions uscan diff --git a/test/completion/useradd.exp b/test/completion/useradd.exp new file mode 100644 index 00000000..f91bddae --- /dev/null +++ b/test/completion/useradd.exp @@ -0,0 +1 @@ +assert_source_completions useradd diff --git a/test/completion/userdel.exp b/test/completion/userdel.exp new file mode 100644 index 00000000..e4ba42ce --- /dev/null +++ b/test/completion/userdel.exp @@ -0,0 +1 @@ +assert_source_completions userdel diff --git a/test/completion/usermod.exp b/test/completion/usermod.exp new file mode 100644 index 00000000..e3861f52 --- /dev/null +++ b/test/completion/usermod.exp @@ -0,0 +1 @@ +assert_source_completions usermod diff --git a/test/completion/vi.exp b/test/completion/vi.exp index 675ea06a..b0191404 100644 --- a/test/completion/vi.exp +++ b/test/completion/vi.exp @@ -1,3 +1 @@ -assert_xspec_completion_installed vi - -source "$::srcdir/lib/completions/vi.exp" +assert_source_completions vi diff --git a/test/completion/wodim.exp b/test/completion/wodim.exp new file mode 100644 index 00000000..51b407ba --- /dev/null +++ b/test/completion/wodim.exp @@ -0,0 +1 @@ +assert_source_completions wodim diff --git a/test/completion/write.exp b/test/completion/write.exp new file mode 100644 index 00000000..d454b62f --- /dev/null +++ b/test/completion/write.exp @@ -0,0 +1 @@ +assert_source_completions write diff --git a/test/completion/xdg-mime.exp b/test/completion/xdg-mime.exp new file mode 100644 index 00000000..01f24d41 --- /dev/null +++ b/test/completion/xdg-mime.exp @@ -0,0 +1 @@ +assert_source_completions xdg-mime diff --git a/test/completion/xdg-settings.exp b/test/completion/xdg-settings.exp new file mode 100644 index 00000000..8fb8a53e --- /dev/null +++ b/test/completion/xdg-settings.exp @@ -0,0 +1 @@ +assert_source_completions xdg-settings diff --git a/test/completion/xm.exp b/test/completion/xm.exp new file mode 100644 index 00000000..fa0cddf6 --- /dev/null +++ b/test/completion/xm.exp @@ -0,0 +1 @@ +assert_source_completions xm diff --git a/test/config/bashrc b/test/config/bashrc index d16c9033..69098e14 100644 --- a/test/config/bashrc +++ b/test/config/bashrc @@ -1,5 +1,8 @@ # bashrc file for DejaGnu testsuite +# Note that we do some initialization that would be too late to do here in +# library.exp's start_bash(). + # Use emacs key bindings set -o emacs # Use bash strict mode @@ -7,17 +10,8 @@ set -o posix # Unset `command_not_found_handle' as defined on Debian/Ubuntu, because this # troubles and slows down testing unset -f command_not_found_handle - # Set fixed prompt `/@' TESTDIR=$(pwd) -export PS1='/@' export PS2='> ' - # Configure readline -export INPUTRC=$SRCDIR/config/inputrc - # When not running via cron, avoid escape junk at beginning of line from - # readline, see e.g. http://bugs.gentoo.org/246091 -[ "$CRON" ] || export TERM=dumb - # Ensure enough columns so expect doesn't have to care about line breaks -stty columns 150 # Also test completions of system administrator commands, which are # installed via the same PATH expansion in `bash_completion.have()' export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin diff --git a/test/docker/Dockerfile-centos6 b/test/docker/Dockerfile-centos6 index 8686fde4..6f886ffa 100644 --- a/test/docker/Dockerfile-centos6 +++ b/test/docker/Dockerfile-centos6 @@ -1,18 +1,11 @@ -FROM centos:6 +FROM vskytta/bash-completion:centos6 -# TODO: more coverage -# /usr/bin/which: https://bugzilla.redhat.com/show_bug.cgi?id=1443357 -RUN sed -i -e /tsflags=nodocs/d /etc/yum.conf \ - && \ - yum -y install \ - https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm \ - && \ - yum -y install \ - autoconf \ - automake \ - dejagnu \ - tcllib \ - /usr/bin/xvfb-run /usr/bin/which +# When adding new completions, install packages desired for their testing here +# in case they're not in the base image, and remove later when the base image +# has caught up. +#RUN yum -y install \ +# some-package -WORKDIR /usr/src/bash-completion +WORKDIR /work COPY . . +CMD ["bash"] diff --git a/test/docker/Dockerfile-fedoradev b/test/docker/Dockerfile-fedoradev index 423f836b..8c4f86d7 100644 --- a/test/docker/Dockerfile-fedoradev +++ b/test/docker/Dockerfile-fedoradev @@ -1,41 +1,11 @@ -FROM fedora:rawhide +FROM vskytta/bash-completion:fedoradev -# TODO: more coverage -# /usr/bin/which: https://bugzilla.redhat.com/show_bug.cgi?id=1443357 -RUN dnf --refresh -y install \ - autoconf \ - automake \ - dejagnu \ - tcllib \ - /usr/bin/xvfb-run /usr/bin/which \ - && \ - dnf -y install \ - /usr/bin/checksec \ - /usr/bin/compare \ - /usr/bin/dcop \ - /usr/sbin/ether-wake \ - /usr/bin/g77 \ - /usr/sbin/hping2 \ - /usr/bin/koji \ - /usr/bin/lua \ - /usr/bin/luac \ - /usr/sbin/mii-diag \ - /usr/bin/mock \ - /usr/bin/msynctool \ - /usr/bin/mutt \ - /usr/bin/ncftp \ - /usr/bin/phing \ - /usr/bin/plague-client \ - /usr/bin/pngfix \ - /usr/bin/pyvenv \ - /usr/bin/snownews \ - /usr/bin/stream \ - /usr/bin/svk \ - /usr/sbin/tipc \ - /usr/bin/wine \ - /usr/bin/wol \ - /usr/bin/xmms \ - /usr/bin/zopflipng +# When adding new completions, install packages desired for their testing here +# in case they're not in the base image, and remove later when the base image +# has caught up. +#RUN dnf --nogpgcheck --refresh -y install \ +# some-package -WORKDIR /usr/src/bash-completion +WORKDIR /work COPY . . +CMD ["bash"] diff --git a/test/docker/Dockerfile-ubuntu14 b/test/docker/Dockerfile-ubuntu14 index 8db91503..a1086add 100644 --- a/test/docker/Dockerfile-ubuntu14 +++ b/test/docker/Dockerfile-ubuntu14 @@ -1,197 +1,13 @@ -FROM ubuntu:14.04 +FROM vskytta/bash-completion:ubuntu14 -# TODO: more coverage -# TODO: wine needs dpkg --add-architecture i386 before apt-get update, but -# that results in apt-get update errors (some index files not found) -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - autoconf \ - automake \ - dejagnu \ - tcllib \ - xvfb \ - software-properties-common && \ - apt-add-repository multiverse && \ - apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - a2ps \ - abook \ - acpi \ - alpine \ - android-tools-adb \ - ant \ - apache2 \ - apache2-utils \ - apt-build \ - asciidoc \ - aspell \ - autoconf \ - automake \ - bc \ - bind9-host \ - bison \ - bluez \ - bridge-utils \ - bsdgames \ - ccache \ - cfengine2 \ - chrony \ - chrpath \ - cksfv \ - clisp \ - cowsay \ - cppcheck \ - cryptsetup-bin \ - cups-bsd \ - cups-client \ - curl \ - cvs \ - cvsps \ - deja-dup \ - desktop-file-utils \ - dict \ - dnsutils \ - dselect \ - dsniff \ - enscript \ - eog \ - evince \ - expat \ - fbi \ - feh \ - file-roller \ - finger \ - freerdp-x11 \ - fuse \ - gcj-jdk \ - gcl \ - gdb \ - genisoimage \ - gkrellm \ - gnat-4.6 \ - gnokii-cli \ - gnome-mplayer \ - gperf \ - gphoto2 \ - graphicsmagick \ - graphicsmagick-imagemagick-compat \ - graphviz \ - growisofs \ - grub \ - hddtemp \ - hping3 \ - htop \ - icedtea-netx \ - idn \ - iftop \ - info \ - iperf \ - ipmitool \ - iputils-arping \ - iputils-ping \ - iputils-tracepath \ - ipv6calc \ - isc-dhcp-client \ - jpegoptim \ - k3b \ - kcov \ - kplayer \ - ldap-utils \ - ldapvi \ - lftp \ - liblz4-tool \ - libuser \ - lilo \ - links \ - lrzip \ - lsof \ - lvm2 \ - lzip \ - lzop \ - mailman \ - man \ - mariadb-client-5.5 \ - mc \ - mcrypt \ - mdadm \ - medusa \ - mencoder \ - minicom \ - monodevelop \ - mplayer-gui \ - mr \ - mtx \ - mussh \ - net-tools \ - nethogs \ - network-manager \ - nfs-common \ - ngrep \ - nis \ - nodejs-legacy \ - npm \ - ntpdate \ - open-iscsi-utils \ - openjdk-7-jdk \ - openswan \ - optipng \ - p7zip-full \ - patchutils \ - perl-doc \ - pinfo \ - poppler-utils \ - postgresql-client-9.3 \ - postfix \ - prelink \ - protobuf-compiler \ - puppet-common \ - pwgen \ - pyflakes \ - pylint \ - python-flake8 \ - python-pytest \ - python3 \ - quota \ - rcs \ - rdesktop \ - reportbug \ - reptyr \ - ri \ - rpm \ - rsync \ - samba-common-bin \ - sbcl \ - screen \ - sharutils \ - sitecopy \ - smartmontools \ - smbclient \ - sqlite3 \ - strace \ - subversion \ - sysbench \ - tcpdump \ - texinfo \ - tshark \ - unace \ - unrar \ - units \ - unixodbc \ - valgrind \ - vpnc \ - wget \ - wireless-tools \ - wodim \ - wvdial \ - x11-xserver-utils \ - xserver-xorg-input-synaptics \ - xsltproc \ - xvnc4viewer \ - xzdec \ - yum \ - yum-utils \ - zopfli && \ - npm install -g jshint +# When adding new completions, install packages desired for their testing here +# in case they're not in the base image, and remove later when the base image +# has caught up. +#RUN apt-get update \ +# && \ +# DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +# some-package -WORKDIR /usr/src/bash-completion +WORKDIR /work COPY . . +CMD ["bash"] diff --git a/test/fixtures/_known_hosts_real/localhost_config b/test/fixtures/_known_hosts_real/localhost_config new file mode 100644 index 00000000..1e751338 --- /dev/null +++ b/test/fixtures/_known_hosts_real/localhost_config @@ -0,0 +1 @@ +UserKnownHostsFile fixtures/_known_hosts_real/localhost_hosts diff --git a/test/fixtures/_known_hosts_real/localhost_hosts b/test/fixtures/_known_hosts_real/localhost_hosts new file mode 100644 index 00000000..ff752c26 --- /dev/null +++ b/test/fixtures/_known_hosts_real/localhost_hosts @@ -0,0 +1,3 @@ +localhost +127.0.0.1 +::1 diff --git a/test/fixtures/man/man1/bar.1.bz2 b/test/fixtures/dpkg/bash-completion-test-subject.deb index e69de29b..e69de29b 100644 --- a/test/fixtures/man/man1/bar.1.bz2 +++ b/test/fixtures/dpkg/bash-completion-test-subject.deb diff --git a/test/fixtures/info/bash-completion.info b/test/fixtures/info/bash-completion.info new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fixtures/info/bash-completion.info diff --git a/test/fixtures/java/bashcomp.war b/test/fixtures/java/bashcomp.war new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fixtures/java/bashcomp.war diff --git a/test/fixtures/man/man1/bash-completion-testcase.1.bz2 b/test/fixtures/man/man1/bash-completion-testcase.1.bz2 new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fixtures/man/man1/bash-completion-testcase.1.bz2 diff --git a/test/fixtures/mplayer/.mplayer/config b/test/fixtures/mplayer/.mplayer/config new file mode 100644 index 00000000..8af74eed --- /dev/null +++ b/test/fixtures/mplayer/.mplayer/config @@ -0,0 +1,2 @@ +# https://github.com/scop/bash-completion/issues/182 +msglevel=all=3 diff --git a/test/fixtures/mplayer/.mplayer/mencoder.conf b/test/fixtures/mplayer/.mplayer/mencoder.conf new file mode 100644 index 00000000..9f5aa0f2 --- /dev/null +++ b/test/fixtures/mplayer/.mplayer/mencoder.conf @@ -0,0 +1 @@ +# mencoder test config file diff --git a/test/fixtures/ri/BashCompletion/cdesc-BashCompletion.yaml b/test/fixtures/ri/BashCompletion/cdesc-BashCompletion.yaml new file mode 100644 index 00000000..bc064a82 --- /dev/null +++ b/test/fixtures/ri/BashCompletion/cdesc-BashCompletion.yaml @@ -0,0 +1,15 @@ +--- !ruby/object:RI::ClassDescription +attributes: [] + +class_methods: [] + +comment: +constants: [] + +full_name: BashCompletion +includes: [] + +instance_methods: [] + +name: BashCompletion +superclass: diff --git a/test/fixtures/ri/bashcompletion.rb b/test/fixtures/ri/bashcompletion.rb new file mode 100644 index 00000000..0e075d26 --- /dev/null +++ b/test/fixtures/ri/bashcompletion.rb @@ -0,0 +1,2 @@ +module BashCompletion +end diff --git a/test/fixtures/ri/created.rid b/test/fixtures/ri/created.rid index ced9a4e0..1392d206 100644 --- a/test/fixtures/ri/created.rid +++ b/test/fixtures/ri/created.rid @@ -1 +1 @@ -Sat, 29 Apr 2017 07:21:09 +0000 +Mon, 09 Oct 2017 21:45:15 +0000 diff --git a/test/lib/completions/alias.exp b/test/lib/completions/alias.exp index 9dba4e62..2010df2d 100644 --- a/test/lib/completions/alias.exp +++ b/test/lib/completions/alias.exp @@ -19,8 +19,6 @@ set test "Tab should complete alias" # Try completion set cmd "alias " assert_complete {bar foo} $cmd $test - - sync_after_int @@ -35,9 +33,12 @@ expect { -re /@ { unresolved "$test" } default { unresolved "$test" } } +sync_after_int -sync_after_int +# FIXME: test case for "alias foo=<TAB>" -> "alias foo='bar'", this doesn't work +#assert_complete {foo='bar'} "alias foo=" "" -nospace +#sync_after_int teardown diff --git a/test/lib/completions/apt-get.exp b/test/lib/completions/apt-get.exp index 270d6fe8..8a5d3629 100644 --- a/test/lib/completions/apt-get.exp +++ b/test/lib/completions/apt-get.exp @@ -4,7 +4,7 @@ proc setup {} { proc teardown {} { - assert_env_unmodified + assert_env_unmodified {/OLDPWD=/d} } @@ -22,4 +22,8 @@ expect { sync_after_int +assert_complete_dir "./bash-completion-test-subject.deb" "apt-get install ./" "$::srcdir/fixtures/dpkg" +sync_after_int + + teardown diff --git a/test/lib/completions/bzip2.exp b/test/lib/completions/bzip2.exp index 2813dd0e..d806851a 100644 --- a/test/lib/completions/bzip2.exp +++ b/test/lib/completions/bzip2.exp @@ -17,4 +17,8 @@ assert_complete_any "bzip2 " sync_after_int +assert_complete_homedir "bzip" +sync_after_int + + teardown diff --git a/test/lib/completions/ccze.exp b/test/lib/completions/ccze.exp new file mode 100644 index 00000000..94b51b39 --- /dev/null +++ b/test/lib/completions/ccze.exp @@ -0,0 +1,27 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ccze " +sync_after_int + +assert_no_complete "ccze -? " +sync_after_int + +assert_complete_any "ccze -o " +sync_after_int + +assert_complete_any "ccze --plugin=" +sync_after_int + + +teardown diff --git a/test/lib/completions/cfrun.exp b/test/lib/completions/cfrun.exp new file mode 100644 index 00000000..2cf6a4cb --- /dev/null +++ b/test/lib/completions/cfrun.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "cfrun -" +sync_after_int + + +teardown diff --git a/test/lib/completions/chfn.exp b/test/lib/completions/chfn.exp new file mode 100644 index 00000000..ea977c76 --- /dev/null +++ b/test/lib/completions/chfn.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "chfn " +sync_after_int + + +teardown diff --git a/test/lib/completions/complete.exp b/test/lib/completions/complete.exp new file mode 100644 index 00000000..9d898c51 --- /dev/null +++ b/test/lib/completions/complete.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "complete -" +sync_after_int + + +teardown diff --git a/test/lib/completions/cpan2dist.exp b/test/lib/completions/cpan2dist.exp new file mode 100644 index 00000000..1c7836ad --- /dev/null +++ b/test/lib/completions/cpan2dist.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "cpan2dist -" +sync_after_int + + +teardown diff --git a/test/lib/completions/dpkg.exp b/test/lib/completions/dpkg.exp index 0ea6ded3..b69f79fd 100644 --- a/test/lib/completions/dpkg.exp +++ b/test/lib/completions/dpkg.exp @@ -22,13 +22,7 @@ if {[assert_exec {dpkg --get-selections | command grep \[\[:space:\]\]install$ | sync_after_int -set test "dpkg -i ~part should complete to ~full/ if home dir exists" -# https://bugs.debian.org/864691 -# Create list of users, having existing home dir -assert_bash_exec {for u in $(compgen -u); do \ - eval test -d ~$u && echo $u; unset u; done} {} /@ users -find_unique_completion_pair $users part full -assert_complete "~$full/" "dpkg -i ~$part" $test -nospace +assert_complete_homedir "dpkg -i" sync_after_int diff --git a/test/lib/completions/ebtables.exp b/test/lib/completions/ebtables.exp new file mode 100644 index 00000000..e8feea55 --- /dev/null +++ b/test/lib/completions/ebtables.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ebtables -" +sync_after_int + + +teardown diff --git a/test/lib/completions/flake8.exp b/test/lib/completions/flake8.exp index 469f96ed..146ff04d 100644 --- a/test/lib/completions/flake8.exp +++ b/test/lib/completions/flake8.exp @@ -14,5 +14,11 @@ setup assert_complete_any "flake8 " sync_after_int +assert_complete_any "flake8 -" +sync_after_int + +assert_no_complete "flake8 --doesnt-exist=" +sync_after_int + teardown diff --git a/test/lib/completions/freeciv-gtk2.exp b/test/lib/completions/freeciv-gtk2.exp new file mode 100644 index 00000000..1c0ec474 --- /dev/null +++ b/test/lib/completions/freeciv-gtk2.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "freeciv-gtk2 -" +sync_after_int + + +teardown diff --git a/test/lib/completions/freeciv-server.exp b/test/lib/completions/freeciv-server.exp new file mode 100644 index 00000000..a9431848 --- /dev/null +++ b/test/lib/completions/freeciv-server.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "freeciv-server -" +sync_after_int + + +teardown diff --git a/test/lib/completions/geoiplookup.exp b/test/lib/completions/geoiplookup.exp new file mode 100644 index 00000000..89166401 --- /dev/null +++ b/test/lib/completions/geoiplookup.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "geoiplookup -" +sync_after_int + + +teardown diff --git a/test/lib/completions/getconf.exp b/test/lib/completions/getconf.exp new file mode 100644 index 00000000..a599fed1 --- /dev/null +++ b/test/lib/completions/getconf.exp @@ -0,0 +1,30 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "getconf P" +sync_after_int + +assert_complete_any "getconf -" +sync_after_int + +assert_complete_any "getconf -a " +sync_after_int + +assert_complete_any "getconf -v " +sync_after_int + +assert_complete_any "getconf PATH_MAX " +sync_after_int + + +teardown diff --git a/test/lib/completions/gpg2.exp b/test/lib/completions/gpg2.exp new file mode 100644 index 00000000..3bc0e7a7 --- /dev/null +++ b/test/lib/completions/gpg2.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "gpg2 --h" +sync_after_int + + +teardown diff --git a/test/lib/completions/groupadd.exp b/test/lib/completions/groupadd.exp new file mode 100644 index 00000000..c9a4f067 --- /dev/null +++ b/test/lib/completions/groupadd.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_no_complete "groupadd " +sync_after_int + +assert_complete_any "groupadd -" +sync_after_int + + +teardown diff --git a/test/lib/completions/groupdel.exp b/test/lib/completions/groupdel.exp new file mode 100644 index 00000000..07c77638 --- /dev/null +++ b/test/lib/completions/groupdel.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "groupdel " +sync_after_int + + +teardown diff --git a/test/lib/completions/groupmems.exp b/test/lib/completions/groupmems.exp new file mode 100644 index 00000000..41c4b43e --- /dev/null +++ b/test/lib/completions/groupmems.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "groupmems -" +sync_after_int + + +teardown diff --git a/test/lib/completions/groupmod.exp b/test/lib/completions/groupmod.exp new file mode 100644 index 00000000..451456b3 --- /dev/null +++ b/test/lib/completions/groupmod.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "groupmod " +sync_after_int + +assert_complete_any "groupmod -" +sync_after_int + + +teardown diff --git a/test/lib/completions/gzip.exp b/test/lib/completions/gzip.exp index 32acf428..95f774c6 100644 --- a/test/lib/completions/gzip.exp +++ b/test/lib/completions/gzip.exp @@ -25,4 +25,8 @@ expect { sync_after_int +assert_complete_homedir "gzip" +sync_after_int + + teardown diff --git a/test/lib/completions/hid2hci.exp b/test/lib/completions/hid2hci.exp new file mode 100644 index 00000000..c090c2c9 --- /dev/null +++ b/test/lib/completions/hid2hci.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "hid2hci -" +sync_after_int + + +teardown diff --git a/test/lib/completions/info.exp b/test/lib/completions/info.exp index e7c79e6e..443a1305 100644 --- a/test/lib/completions/info.exp +++ b/test/lib/completions/info.exp @@ -1,19 +1,22 @@ proc setup {} { + assert_bash_exec {OLDINFOPATH=$INFOPATH; INFOPATH=$INFOPATH:$TESTDIR/fixtures/info:} save_env } proc teardown {} { assert_env_unmodified + assert_bash_exec {INFOPATH="$OLDINFOPATH"; unset -v OLDINFOPATH} } setup -assert_complete_any "info " - +assert_complete_any "info bash" +sync_after_int +assert_complete_any "info -" sync_after_int diff --git a/test/lib/completions/iptables.exp b/test/lib/completions/iptables.exp new file mode 100644 index 00000000..8ab42f56 --- /dev/null +++ b/test/lib/completions/iptables.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "iptables -" +sync_after_int + + +teardown diff --git a/test/lib/completions/java.exp b/test/lib/completions/java.exp index 864aabd6..62f6fd9d 100644 --- a/test/lib/completions/java.exp +++ b/test/lib/completions/java.exp @@ -44,7 +44,7 @@ assert_no_complete "java -cp \"\" " sync_after_int -assert_complete "a/ bashcomp.jar" "java -jar $::srcdir/fixtures/java/" +assert_complete "a/ bashcomp.jar bashcomp.war" "java -jar $::srcdir/fixtures/java/" sync_after_int diff --git a/test/lib/completions/kcov.exp b/test/lib/completions/kcov.exp index c39f53e7..c6c4a06d 100644 --- a/test/lib/completions/kcov.exp +++ b/test/lib/completions/kcov.exp @@ -12,15 +12,13 @@ setup assert_complete_any "kcov " - - sync_after_int - set test "--exclude-patter<TAB> should complete \"--exclude-pattern=\"" assert_complete "--exclude-pattern=" "kcov --exclude-patter" $test -nospace +sync_after_int - +assert_complete_any "kcov -l 42," sync_after_int diff --git a/test/lib/completions/killall.exp b/test/lib/completions/killall.exp index feec9337..a55ac591 100644 --- a/test/lib/completions/killall.exp +++ b/test/lib/completions/killall.exp @@ -11,15 +11,12 @@ proc teardown {} { setup -assert_complete_any "killall " - - +# "p": Assume that our process name completion runs ps +assert_complete_any "killall p" sync_after_int assert_complete [get_signals] "killall --signal " - - sync_after_int diff --git a/test/lib/completions/ktutil.exp b/test/lib/completions/ktutil.exp new file mode 100644 index 00000000..709a0850 --- /dev/null +++ b/test/lib/completions/ktutil.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ktutil " +sync_after_int + +assert_complete_any "ktutil -" +sync_after_int + + +teardown diff --git a/test/lib/completions/lintian-info.exp b/test/lib/completions/lintian-info.exp new file mode 100644 index 00000000..5bde97fd --- /dev/null +++ b/test/lib/completions/lintian-info.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lintian-info " +sync_after_int + +assert_complete_any "lintian-info --" +sync_after_int + + +teardown diff --git a/test/lib/completions/lintian.exp b/test/lib/completions/lintian.exp new file mode 100644 index 00000000..5b1e695c --- /dev/null +++ b/test/lib/completions/lintian.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lintian --" +sync_after_int + + +teardown diff --git a/test/lib/completions/lrzip.exp b/test/lib/completions/lrzip.exp index 97bc1235..2c4218ec 100644 --- a/test/lib/completions/lrzip.exp +++ b/test/lib/completions/lrzip.exp @@ -17,4 +17,8 @@ assert_complete_any "lrzip " sync_after_int +assert_complete_homedir "lrzip" +sync_after_int + + teardown diff --git a/test/lib/completions/ls.exp b/test/lib/completions/ls.exp index e176e13f..24fc46f8 100644 --- a/test/lib/completions/ls.exp +++ b/test/lib/completions/ls.exp @@ -17,12 +17,7 @@ if {[assert_exec {ls --help} "" "" "unsupported"]} { sync_after_int -set test "~part should complete to ~full/ if home dir exists" -# Create list of users, having existing home dir -assert_bash_exec {for u in $(compgen -u); do \ - eval test -d ~$u && echo $u; unset u; done} {} /@ users -find_unique_completion_pair $users part full -assert_complete "~$full/" "ls ~$part" $test -nospace +assert_complete_homedir "ls" sync_after_int @@ -30,8 +25,11 @@ set test "~part should complete to ~full<space> if home dir does not exist" # Create list of users, having non-existing home dir assert_bash_exec {for u in $(compgen -u); do \ eval test -d ~$u || echo $u; unset u; done} {} /@ users -find_unique_completion_pair $users part full -assert_complete "~$full " "ls ~$part" $test -nospace +if {![find_unique_completion_pair $users part full]} { + untested "Not running, no suitable test user found: $test" +} else { + assert_complete "~$full " "ls ~$part" $test -nospace +} sync_after_int diff --git a/test/lib/completions/lspci.exp b/test/lib/completions/lspci.exp new file mode 100644 index 00000000..ea9e859f --- /dev/null +++ b/test/lib/completions/lspci.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lspci -" +sync_after_int + +assert_complete_any "lspci -A " +sync_after_int + + +teardown diff --git a/test/lib/completions/lsscsi.exp b/test/lib/completions/lsscsi.exp new file mode 100644 index 00000000..66603142 --- /dev/null +++ b/test/lib/completions/lsscsi.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_no_complete "lsscsi " +sync_after_int + +assert_complete_any "lsscsi -" +sync_after_int + + +teardown diff --git a/test/lib/completions/lsusb.exp b/test/lib/completions/lsusb.exp new file mode 100644 index 00000000..dddb6352 --- /dev/null +++ b/test/lib/completions/lsusb.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lsusb -" +sync_after_int + + +teardown diff --git a/test/lib/completions/lz4.exp b/test/lib/completions/lz4.exp index df392939..dc41f919 100644 --- a/test/lib/completions/lz4.exp +++ b/test/lib/completions/lz4.exp @@ -14,5 +14,8 @@ setup assert_complete_any "lz4 " sync_after_int +assert_complete_homedir "lz4" +sync_after_int + teardown diff --git a/test/lib/completions/lzma.exp b/test/lib/completions/lzma.exp index ba57d10b..16b45d0b 100644 --- a/test/lib/completions/lzma.exp +++ b/test/lib/completions/lzma.exp @@ -23,4 +23,8 @@ assert_complete "a/ bashcomp.lzma bashcomp.tlz" "lzma -d $::srcdir/fixtures/xz/" sync_after_int +assert_complete_homedir "lzma" +sync_after_int + + teardown diff --git a/test/lib/completions/lzop.exp b/test/lib/completions/lzop.exp index a7d3da25..3084fd3e 100644 --- a/test/lib/completions/lzop.exp +++ b/test/lib/completions/lzop.exp @@ -17,4 +17,8 @@ assert_complete_any "lzop " sync_after_int +assert_complete_homedir "lzop" +sync_after_int + + teardown diff --git a/test/lib/completions/man.exp b/test/lib/completions/man.exp index 1a031ff1..d601c434 100644 --- a/test/lib/completions/man.exp +++ b/test/lib/completions/man.exp @@ -9,7 +9,10 @@ proc setup {} { proc teardown {} { - assert_env_unmodified {/OLDPWD/d} + assert_env_unmodified { + /OLDPWD/d + /OLDMANPATH/d + } if {! [is_cygwin]} { assert_bash_exec {(cd $TESTDIR/tmp && rm -r man || true)} @@ -20,26 +23,54 @@ proc teardown {} { setup -assert_complete "bar" "man b" - +# Something we assume a system installed man page present for +set assumed_present "man" +assert_complete "bash-completion-testcase" "man bash-completion-testcas" sync_after_int - assert_complete_dir oo.1 "man man1/f" $::srcdir/fixtures/man - - sync_after_int - if {! [is_cygwin]} { assert_complete "Bash::Completion" "man Bash::C" sync_after_int } - assert_complete_dir "man/quux.8" "man man/" $::srcdir/fixtures/man sync_after_int +set desc "man $assumed_present with MANPATH having no leading/trailing colon" +assert_no_complete "man $assumed_present" "$desc should not complete" +sync_after_int + +# Trailing colon in MANPATH: append system default search path +assert_bash_exec "OLDMANPATH=\$MANPATH; MANPATH=\$MANPATH:" +set desc "with trailing colon in MANPATH" + +set cmd "man $assumed_present" +assert_complete_any "$cmd" "$cmd $desc should complete" +sync_after_int + +set cmd "man bash-completion-testcas" +assert_complete "bash-completion-testcase" "$cmd" "$cmd $desc should complete" +sync_after_int + +assert_bash_exec "MANPATH=\$OLDMANPATH" + +# Leading colon in MANPATH: prepend system default search path +assert_bash_exec "OLDMANPATH=\$MANPATH; MANPATH=:\$MANPATH" +set desc "with leading colon in MANPATH" + +set cmd "man $assumed_present" +assert_complete_any "$cmd" "$cmd $desc should complete" +sync_after_int + +set cmd "man bash-completion-testcas" +assert_complete "bash-completion-testcase" "$cmd" "$cmd $desc should complete" +sync_after_int + +assert_bash_exec "MANPATH=\$OLDMANPATH" + teardown diff --git a/test/lib/completions/mencoder.exp b/test/lib/completions/mencoder.exp index db29f66a..cb0ba7c5 100644 --- a/test/lib/completions/mencoder.exp +++ b/test/lib/completions/mencoder.exp @@ -1,10 +1,14 @@ proc setup {} { save_env + assert_bash_exec {OLDHOME=$HOME ; HOME=$SRCDIR/fixtures/mplayer} } proc teardown {} { - assert_env_unmodified + assert_bash_exec {HOME=$OLDHOME} + assert_env_unmodified { + /OLDHOME=/d + } } @@ -12,8 +16,9 @@ setup assert_complete_any "mencoder " +sync_after_int - +assert_complete_any "mencoder -v" sync_after_int diff --git a/test/lib/completions/mkdir.exp b/test/lib/completions/mkdir.exp index 44e87cee..049212f0 100644 --- a/test/lib/completions/mkdir.exp +++ b/test/lib/completions/mkdir.exp @@ -17,14 +17,14 @@ assert_complete_any "mkdir " sync_after_int -assert_complete {"bar bar.d/" foo.d/} "mkdir $::srcdir/fixtures/shared/default/" +assert_complete {bar "bar bar.d/" foo foo.d/} "mkdir $::srcdir/fixtures/shared/default/" sync_after_int -# No subdirs in foo.d and should not complete files in it (_longopt()). -assert_no_complete "mkdir $::srcdir/fixtures/shared/default/foo.d/" +set test "mkdir should complete files with nospace" +assert_complete {foo} "mkdir $::srcdir/fixtures/shared/default/foo.d/" $test -nospace sync_after_int diff --git a/test/lib/completions/mplayer.exp b/test/lib/completions/mplayer.exp index 9230a86d..8c9de756 100644 --- a/test/lib/completions/mplayer.exp +++ b/test/lib/completions/mplayer.exp @@ -1,10 +1,14 @@ proc setup {} { save_env + assert_bash_exec {OLDHOME=$HOME ; HOME=$SRCDIR/fixtures/mplayer} } proc teardown {} { - assert_env_unmodified + assert_bash_exec {HOME=$OLDHOME} + assert_env_unmodified { + /OLDHOME=/d + } } @@ -12,8 +16,9 @@ setup assert_complete_any "mplayer " +sync_after_int - +assert_complete_any "mplayer -h" sync_after_int diff --git a/test/lib/completions/munin-node-configure.exp b/test/lib/completions/munin-node-configure.exp new file mode 100644 index 00000000..2e17f3eb --- /dev/null +++ b/test/lib/completions/munin-node-configure.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "munin-node-configure --libdir " +sync_after_int + + +teardown diff --git a/test/lib/completions/munin-run.exp b/test/lib/completions/munin-run.exp new file mode 100644 index 00000000..25a639bc --- /dev/null +++ b/test/lib/completions/munin-run.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "munin-run -" +sync_after_int + + +teardown diff --git a/test/lib/completions/munindoc.exp b/test/lib/completions/munindoc.exp new file mode 100644 index 00000000..62a4307c --- /dev/null +++ b/test/lib/completions/munindoc.exp @@ -0,0 +1,19 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +# Assume at least munin* available +assert_complete_any "munindoc m" +sync_after_int + + +teardown diff --git a/test/lib/completions/nmap.exp b/test/lib/completions/nmap.exp new file mode 100644 index 00000000..02aab991 --- /dev/null +++ b/test/lib/completions/nmap.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "nmap --v" +sync_after_int + + +teardown diff --git a/test/lib/completions/nproc.exp b/test/lib/completions/nproc.exp new file mode 100644 index 00000000..d6df0472 --- /dev/null +++ b/test/lib/completions/nproc.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_no_complete "nproc " +sync_after_int + +assert_complete_any "nproc -" +sync_after_int + + +teardown diff --git a/test/lib/completions/oggdec.exp b/test/lib/completions/oggdec.exp new file mode 100644 index 00000000..18b0f949 --- /dev/null +++ b/test/lib/completions/oggdec.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "oggdec " +sync_after_int + +assert_complete_any "oggdec --" +sync_after_int + + +teardown diff --git a/test/lib/completions/perltidy.exp b/test/lib/completions/perltidy.exp new file mode 100644 index 00000000..09fa2b14 --- /dev/null +++ b/test/lib/completions/perltidy.exp @@ -0,0 +1,27 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "perltidy " +sync_after_int + +assert_complete_any "perltidy -h" +sync_after_int + +assert_complete_any "perltidy -ole=" +sync_after_int + +assert_no_complete "perltidy -doesntexist=" +sync_after_int + + +teardown diff --git a/test/lib/completions/pgrep.exp b/test/lib/completions/pgrep.exp index c27c4f21..c6276f71 100644 --- a/test/lib/completions/pgrep.exp +++ b/test/lib/completions/pgrep.exp @@ -11,9 +11,8 @@ proc teardown {} { setup -assert_complete_any "pgrep " - - +# "p": Assume that our process name completion runs ps +assert_complete_any "pgrep p" sync_after_int diff --git a/test/lib/completions/pidof.exp b/test/lib/completions/pidof.exp index 8fdab978..d8ab9e8c 100644 --- a/test/lib/completions/pidof.exp +++ b/test/lib/completions/pidof.exp @@ -11,9 +11,8 @@ proc teardown {} { setup -assert_complete_any "pidof " - - +# "p": Assume that our process name completion runs ps +assert_complete_any "pidof p" sync_after_int diff --git a/test/lib/completions/pinfo.exp b/test/lib/completions/pinfo.exp index 3af44044..de241ff5 100644 --- a/test/lib/completions/pinfo.exp +++ b/test/lib/completions/pinfo.exp @@ -1,19 +1,22 @@ proc setup {} { + assert_bash_exec {OLDINFOPATH=$INFOPATH; INFOPATH=$INFOPATH:$TESTDIR/fixtures/info:} save_env } proc teardown {} { assert_env_unmodified + assert_bash_exec {INFOPATH="$OLDINFOPATH"; unset -v OLDINFOPATH} } setup -assert_complete_any "pinfo " - +assert_complete_any "pinfo bash" +sync_after_int +assert_complete_any "pinfo -" sync_after_int diff --git a/test/lib/completions/pm-hibernate.exp b/test/lib/completions/pm-hibernate.exp new file mode 100644 index 00000000..1a20603d --- /dev/null +++ b/test/lib/completions/pm-hibernate.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pm-hibernate -" +sync_after_int + + +teardown diff --git a/test/lib/completions/pm-is-supported.exp b/test/lib/completions/pm-is-supported.exp new file mode 100644 index 00000000..8bd136ff --- /dev/null +++ b/test/lib/completions/pm-is-supported.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pm-is-supported -" +sync_after_int + + +teardown diff --git a/test/lib/completions/pm-powersave.exp b/test/lib/completions/pm-powersave.exp new file mode 100644 index 00000000..dea37139 --- /dev/null +++ b/test/lib/completions/pm-powersave.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pm-powersave " +sync_after_int + + +teardown diff --git a/test/lib/completions/postconf.exp b/test/lib/completions/postconf.exp index 40349061..a7f26714 100644 --- a/test/lib/completions/postconf.exp +++ b/test/lib/completions/postconf.exp @@ -10,10 +10,19 @@ proc teardown {} { setup +# Broken configs may abort output of postconf halfway through, so use +# something from early output to not trigger false positives because of +# this. For example, inet_protocols=all but no IPv6 configured: +# postconf: fatal: parameter inet_interfaces: no local interface found for ::1 +# ...and output can be cut off somewhere near lmtp_tls_secur*. +# ...or be completely missing, so all we can do is to skip. +set test "\"postconf al\" should complete al* variables" +if {[assert_exec {postconf} "" "" "untested"]} { + assert_complete_any "postconf al" +} +sync_after_int -assert_complete_any "postconf p" - - +assert_complete_any "postconf -" sync_after_int diff --git a/test/lib/completions/pv.exp b/test/lib/completions/pv.exp new file mode 100644 index 00000000..64d685ae --- /dev/null +++ b/test/lib/completions/pv.exp @@ -0,0 +1,24 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pv " +sync_after_int + +assert_complete_any "pv -" +sync_after_int + +assert_complete_any "pv --pidfile " +sync_after_int + + +teardown diff --git a/test/lib/completions/pycodestyle.exp b/test/lib/completions/pycodestyle.exp new file mode 100644 index 00000000..a4d095e0 --- /dev/null +++ b/test/lib/completions/pycodestyle.exp @@ -0,0 +1,24 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pycodestyle " +sync_after_int + +assert_complete_any "pycodestyle -" +sync_after_int + +assert_no_complete "pycodestyle --doesnt-exist=" +sync_after_int + + +teardown diff --git a/test/lib/completions/python.exp b/test/lib/completions/python.exp index 29a10bf6..be0e8a2d 100644 --- a/test/lib/completions/python.exp +++ b/test/lib/completions/python.exp @@ -35,6 +35,9 @@ sync_after_int assert_complete_any "python -m sy" sync_after_int +assert_complete_any "python -m json." +sync_after_int + assert_complete_any "python -W " sync_after_int diff --git a/test/lib/completions/radvdump.exp b/test/lib/completions/radvdump.exp new file mode 100644 index 00000000..ad1363fd --- /dev/null +++ b/test/lib/completions/radvdump.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "radvdump -" +sync_after_int + + +teardown diff --git a/test/lib/completions/resolvconf.exp b/test/lib/completions/resolvconf.exp new file mode 100644 index 00000000..d1eaf246 --- /dev/null +++ b/test/lib/completions/resolvconf.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "resolvconf -" +sync_after_int + + +teardown diff --git a/test/lib/completions/rfkill.exp b/test/lib/completions/rfkill.exp new file mode 100644 index 00000000..ab0f1811 --- /dev/null +++ b/test/lib/completions/rfkill.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "rfkill " +sync_after_int + +assert_complete_any "rfkill -" +sync_after_int + + +teardown diff --git a/test/lib/completions/rrdtool.exp b/test/lib/completions/rrdtool.exp new file mode 100644 index 00000000..3fb392e4 --- /dev/null +++ b/test/lib/completions/rrdtool.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "rrdtool " +sync_after_int + + +teardown diff --git a/test/lib/completions/runuser.exp b/test/lib/completions/runuser.exp new file mode 100644 index 00000000..051abe1d --- /dev/null +++ b/test/lib/completions/runuser.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "runuser " +sync_after_int + + +teardown diff --git a/test/lib/completions/screen.exp b/test/lib/completions/screen.exp index f37d5f5f..a5b8c69f 100644 --- a/test/lib/completions/screen.exp +++ b/test/lib/completions/screen.exp @@ -24,7 +24,8 @@ assert_complete_any "screen cat" sync_after_int -assert_complete_any "screen -T " +# Limit number of matches, assume at least vt100 and friends are there +assert_complete_any "screen -T vt" sync_after_int diff --git a/test/lib/completions/ss.exp b/test/lib/completions/ss.exp index f6e711c6..e64e33d9 100644 --- a/test/lib/completions/ss.exp +++ b/test/lib/completions/ss.exp @@ -17,5 +17,8 @@ sync_after_int assert_complete_any "ss -A " sync_after_int +assert_complete_any "ss -A foo," +sync_after_int + teardown diff --git a/test/lib/completions/sshfs.exp b/test/lib/completions/sshfs.exp new file mode 100644 index 00000000..42adbd8b --- /dev/null +++ b/test/lib/completions/sshfs.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified { + /_scp_path_esc=/d + } +} + + +setup + + +assert_complete_any "sshfs ./" +sync_after_int + + +teardown diff --git a/test/lib/completions/tox.exp b/test/lib/completions/tox.exp new file mode 100644 index 00000000..55106326 --- /dev/null +++ b/test/lib/completions/tox.exp @@ -0,0 +1,24 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "tox -" +sync_after_int + +assert_complete "ALL" "tox -e " +sync_after_int + +assert_complete "ALL" "tox -e foo," +sync_after_int + + +teardown diff --git a/test/lib/completions/tshark.exp b/test/lib/completions/tshark.exp index f2419119..9e7d9d31 100644 --- a/test/lib/completions/tshark.exp +++ b/test/lib/completions/tshark.exp @@ -17,5 +17,8 @@ sync_after_int assert_complete_any "tshark -G " sync_after_int +assert_complete_any "tshark -O foo,htt" +sync_after_int + teardown diff --git a/test/lib/completions/uscan.exp b/test/lib/completions/uscan.exp new file mode 100644 index 00000000..f96ee971 --- /dev/null +++ b/test/lib/completions/uscan.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "uscan -" +sync_after_int + + +teardown diff --git a/test/lib/completions/useradd.exp b/test/lib/completions/useradd.exp new file mode 100644 index 00000000..c4f4957e --- /dev/null +++ b/test/lib/completions/useradd.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_no_complete "useradd " +sync_after_int + +assert_complete_any "useradd -" +sync_after_int + + +teardown diff --git a/test/lib/completions/userdel.exp b/test/lib/completions/userdel.exp new file mode 100644 index 00000000..2a46246c --- /dev/null +++ b/test/lib/completions/userdel.exp @@ -0,0 +1,22 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +# "r": root +assert_complete_any "userdel r" +sync_after_int + +assert_complete_any "userdel -" +sync_after_int + + +teardown diff --git a/test/lib/completions/usermod.exp b/test/lib/completions/usermod.exp new file mode 100644 index 00000000..d7daf992 --- /dev/null +++ b/test/lib/completions/usermod.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "usermod " +sync_after_int + +assert_complete_any "usermod -" +sync_after_int + + +teardown diff --git a/test/lib/completions/wodim.exp b/test/lib/completions/wodim.exp new file mode 100644 index 00000000..55f63c30 --- /dev/null +++ b/test/lib/completions/wodim.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "wodim " +sync_after_int + + +teardown diff --git a/test/lib/completions/write.exp b/test/lib/completions/write.exp new file mode 100644 index 00000000..4503f6cc --- /dev/null +++ b/test/lib/completions/write.exp @@ -0,0 +1,19 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +# "r": root +assert_complete_any "write r" +sync_after_int + + +teardown diff --git a/test/lib/completions/xdg-mime.exp b/test/lib/completions/xdg-mime.exp new file mode 100644 index 00000000..015c586e --- /dev/null +++ b/test/lib/completions/xdg-mime.exp @@ -0,0 +1,39 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "xdg-mime " +sync_after_int + +assert_complete_any "xdg-mime -" +sync_after_int + +assert_complete_any "xdg-mime query " +sync_after_int + +assert_complete_any "xdg-mime query filetype " +sync_after_int + +assert_complete_any "xdg-mime query default " +sync_after_int + +assert_complete_any "xdg-mime default foo.desktop " +sync_after_int + +assert_complete_any "xdg-mime install --mode " +sync_after_int + +assert_complete_any "xdg-mime uninstall " +sync_after_int + + +teardown diff --git a/test/lib/completions/xdg-settings.exp b/test/lib/completions/xdg-settings.exp new file mode 100644 index 00000000..99a5838d --- /dev/null +++ b/test/lib/completions/xdg-settings.exp @@ -0,0 +1,24 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "xdg-settings " +sync_after_int + +assert_complete_any "xdg-settings --" +sync_after_int + +assert_complete_any "xdg-settings get " +sync_after_int + + +teardown diff --git a/test/lib/completions/xm.exp b/test/lib/completions/xm.exp new file mode 100644 index 00000000..5a0c58e0 --- /dev/null +++ b/test/lib/completions/xm.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "xm " +sync_after_int + + +teardown diff --git a/test/lib/completions/xz.exp b/test/lib/completions/xz.exp index 6e6b29ca..ba9ccd3a 100644 --- a/test/lib/completions/xz.exp +++ b/test/lib/completions/xz.exp @@ -30,4 +30,8 @@ assert_complete_dir "a/ bashcomp.tar" "xz " $::srcdir/fixtures/xz sync_after_int +assert_complete_homedir "xz" +sync_after_int + + teardown diff --git a/test/lib/completions/zopfli.exp b/test/lib/completions/zopfli.exp index 15738ff0..8e17e92b 100644 --- a/test/lib/completions/zopfli.exp +++ b/test/lib/completions/zopfli.exp @@ -15,4 +15,8 @@ assert_complete_any "zopfli " sync_after_int +assert_complete_homedir "zopfli" +sync_after_int + + teardown diff --git a/test/lib/library.exp b/test/lib/library.exp index 1e2c7456..9321c5ca 100644 --- a/test/lib/library.exp +++ b/test/lib/library.exp @@ -584,6 +584,24 @@ proc assert_no_output {{cmd} {test ""} {prompt /@}} { } +# Check that ~part completes to ~full/ if home dir exists. +# @param string $cmd The command to attempt home dir completion for. +# @param string $test Optional parameter with test name. +# @param string $prompt (optional) Bash prompt. Default is "/@" +proc assert_complete_homedir {{cmd} {test ""} {prompt /@}} { + if {[string length $test] == 0} { + set test "$cmd should complete ~part to ~full/ if home dir exists" + } + assert_bash_exec {for u in $(compgen -u); do \ + eval test -d ~$u && echo $u; unset u; done} {} /@ users + if {![find_unique_completion_pair $users part full]} { + untested "Not running, no suitable test user found: $test" + } else { + assert_complete "~$full/" "$cmd ~$part" $test -nospace + } +} + + # Source/run file with additional tests if completion for the specified command # is installed in bash, and the command is available. # @param string $command Command to check completion availability for. @@ -602,21 +620,6 @@ proc assert_source_completions {command {file ""}} { } -# Assert that a _filedir_xspec completion is installed for specified command -# @param string $command Command to check completion installation for. -proc assert_xspec_completion_installed {command} { - set test "Completion via _filedir_xspec() should be installed" - set cmd "complete -p $command" - send "$cmd\r" - - set expected "^$cmd\r\ncomplete -F _filedir_xspec $command\r\n/@$" - expect { - -re $expected { pass "$test" } - -re /@ { fail "$test at prompt" } - } -} - - # Sort list. # `exec sort' is used instead of `lsort' to achieve exactly the # same sort order as in bash. @@ -929,7 +932,8 @@ proc find_unique_completion_pair {{list} {partName} {fullName}} { upvar $partName part upvar $fullName full set bestscore 0 - set list [lsort $list] + # Uniquify the list, that's what completion does too. + set list [lsort -unique $list] set n [llength $list] for {set i 0} {$i < $n} {incr i} { set cur [lindex $list $i] @@ -991,8 +995,23 @@ proc start_bash {} { if {! [info exists TOOL_EXECUTABLE]} {set TOOL_EXECUTABLE bash} set env(SRCDIR) $::srcdir set env(SRCDIRABS) $::srcdirabs - exp_spawn $TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc - assert_bash_exec {} "$TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc" + + # PS1, INPUTRC, TERM and stty columns must be initialized + # *before* starting bash to take proper effect. + + # Set fixed prompt `/@' + set env(PS1) "/@" + # Configure readline + set env(INPUTRC) "$::srcdir/config/inputrc" + # Avoid escape junk at beginning of line from readline, + # see e.g. http://bugs.gentoo.org/246091 + set env(TERM) "dumb" + # Ensure enough columns so expect doesn't have to care about line breaks + set stty_init "columns 150" + + exp_spawn $TOOL_EXECUTABLE --norc + assert_bash_exec {} "$TOOL_EXECUTABLE --norc" + assert_bash_exec "source $::srcdir/config/bashrc" } @@ -1023,6 +1042,11 @@ proc start_interactive_test {} { if {[info exists OPT_BASH_XTRACE]} { init_bash_xtrace } + global OPT_BUFFER_SIZE + if {[info exists OPT_BUFFER_SIZE]} { + verbose "Changing default expect match buffer size to $OPT_BUFFER_SIZE" + match_max $OPT_BUFFER_SIZE + } global OPT_TIMEOUT if {[info exists OPT_TIMEOUT]} { global timeout @@ -10,6 +10,7 @@ usage() { echo echo "Interesting options:" echo " --tool_exec= Test against a different bash executable." + echo " --buffer_size Change expect match buffer size from the default of 2000 bytes." echo " --debug Create a dbg.log in the test directory with detailed expect match information." echo " --timeout Change expect timeout from the default of 10 seconds." echo " --debug-xtrace Create an xtrace.log in the test directory with set -x output." @@ -39,6 +40,8 @@ args=() while [[ $# > 0 ]]; do case "$1" in --help|--usage) usage; exit 1;; + --buffer-size) shift; buffer_size=$1;; + --buffer-size=*) buffer_size=${1/--buffer-size=};; --debug-xtrace) args+=(OPT_BASH_XTRACE=1);; --timeout) shift; timeout=$1;; --timeout=*) timeout=${1/--timeout=};; @@ -54,6 +57,7 @@ while [[ $# > 0 ]]; do shift done +[[ -n $buffer_size ]] && args+=("OPT_BUFFER_SIZE=$buffer_size") [[ -n $timeout ]] && args+=("OPT_TIMEOUT=$timeout") [[ -z $tool ]] && { echo "Must specify tool somehow"; exit 1; } diff --git a/test/unit/__expand_tilde_by_ref.exp b/test/unit/__expand_tilde_by_ref.exp index 60aa7d52..bcb931e1 100644 --- a/test/unit/__expand_tilde_by_ref.exp +++ b/test/unit/__expand_tilde_by_ref.exp @@ -6,7 +6,7 @@ proc setup {home user} { save_env assert_bash_exec {echo "$HOME"} {} /@ _home set _home [string trim $_home] - assert_bash_exec {echo "$USER"} {} /@ _user + assert_bash_exec {id -un 2>/dev/null || echo "$USER"} {} /@ _user set _user [string trim $_user] } @@ -23,64 +23,51 @@ setup home user set test "function should run without errors" assert_bash_exec {__expand_tilde_by_ref > /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="~"; __expand_tilde_by_ref aa; }; foo; unset foo} $test - - sync_after_int - set test "~user should return $home" set cmd [format {var="~%s"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] assert_bash_list "$home" $cmd $test - - sync_after_int - set test "~/foo should return $home/foo" set cmd {var='~/foo'; __expand_tilde_by_ref var; printf "%s\n" "$var"} assert_bash_list "$home/foo" $cmd $test - - sync_after_int - set test "~user/bar should return $home/bar" set cmd [format {var="~%s/bar"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] assert_bash_list "$home/bar" $cmd $test - - sync_after_int - set test "~user/\$HOME should return $home/\$HOME" set cmd [format {var="~%s/\$HOME"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] assert_bash_list "$home/\$HOME" $cmd $test - - sync_after_int - set test "'~user/a b' should return '$home/a b'" set cmd [format {var="~%s/a b"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] assert_bash_list [list [format {%s/a b} $home]] $cmd $test - - sync_after_int - set test "~user/* should return $home/*" set cmd [format {var="~%s/*"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] assert_bash_list "$home/\*" $cmd $test +sync_after_int +set test "'~user;echo hello' should return '~user;echo hello' (not expanded)" +set cmd [format {var="~%s;echo hello"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] +assert_bash_list [format "~%s;echo hello" $user] $cmd $test +sync_after_int +set test "'~user/a;echo hello' should return '$home/a;echo hello'" +set cmd [format {var="~%s/a;echo hello"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user] +assert_bash_list "$home/a;echo hello" $cmd $test sync_after_int diff --git a/test/unit/_count_args.exp b/test/unit/_count_args.exp index b615cab8..b528846a 100644 --- a/test/unit/_count_args.exp +++ b/test/unit/_count_args.exp @@ -20,48 +20,31 @@ setup set test "_count_args should run without errors" assert_bash_exec {_count_args > /dev/null} $test - - sync_after_int - set test "a b| should set args to 1"; # | = cursor position set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3; _count_args; echo $args} assert_bash_list 1 $cmd $test - - sync_after_int - set test "a b|c should set args to 1"; # | = cursor position set cmd {COMP_WORDS=(a bc); COMP_CWORD=1; COMP_LINE='a bc'; COMP_POINT=3; _count_args; echo $args} assert_bash_list 1 $cmd $test - - sync_after_int - set test "a b c| should set args to 2"; # | = cursor position set cmd {COMP_WORDS=(a b c); COMP_CWORD=2; COMP_LINE='a b c'; COMP_POINT=4; _count_args; echo $args} assert_bash_list 2 $cmd $test - - sync_after_int - set test "a b| c should set args to 1"; # | = cursor position set cmd {COMP_WORDS=(a b c); COMP_CWORD=1; COMP_LINE='a b c'; COMP_POINT=3; _count_args; echo $args} assert_bash_list 1 $cmd $test - - sync_after_int - set test "a b -c| d should set args to 2"; # | = cursor position set cmd {COMP_WORDS=(a b -c d); COMP_CWORD=2; COMP_LINE='a b -c d'; COMP_POINT=6; _count_args; echo $args} assert_bash_list 2 $cmd $test - - sync_after_int diff --git a/test/unit/_expand.exp b/test/unit/_expand.exp new file mode 100644 index 00000000..50453868 --- /dev/null +++ b/test/unit/_expand.exp @@ -0,0 +1,42 @@ +proc setup {home user} { + upvar $home _home + upvar $user _user + save_env + assert_bash_exec {echo "$HOME"} {} /@ _home + set _home [string trim $_home] + assert_bash_exec {id -un 2>/dev/null || echo "$USER"} {} /@ _user + set _user [string trim $_user] +} + +proc teardown {} { + assert_env_unmodified { + /COMPREPLY=/d + /cur=/d + } +} + + +setup home user + + +set test "function should run without errors" +assert_bash_exec {_expand > /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() { _expand; }; foo; unset foo} $test +sync_after_int + +set test "~$user should set $home to COMPREPLY" +set cmd [format {cur="~%s" ; _expand ; printf "%%s\n" "$COMPREPLY"} $user] +assert_bash_list "$home" $cmd $test +sync_after_int + +set test "~$user/a should set $home/a to cur" +set cmd [format {cur="~%s/a" ; _expand ; printf "%%s\n" "$cur"} $user] +assert_bash_list "$home/a" $cmd $test +sync_after_int + + +teardown diff --git a/test/unit/_filedir.exp b/test/unit/_filedir.exp index fb29af5b..597e4acc 100644 --- a/test/unit/_filedir.exp +++ b/test/unit/_filedir.exp @@ -55,37 +55,25 @@ setup set test "_filedir should run without errors" assert_bash_exec {_filedir > /dev/null} $test - - sync_after_int - foreach name {f f2} { set test "completing $name ab/ should return e" set cmd "$name ab/" assert_complete_dir e $cmd "$::srcdir/fixtures/_filedir" $test - - sync_after_int - set test "completing $name a\\ b/ should return i" set cmd "$name a\\ b/" assert_complete_dir i $cmd "$::srcdir/fixtures/_filedir" $test - - sync_after_int - set test "completing $name a\\\'b/ should return c" set cmd "$name a\\\'b/" assert_complete_dir c $cmd "$::srcdir/fixtures/_filedir" $test - - sync_after_int - set test "completing $name a\\\$b/ should return h" if {[info exists ::env(CI)] && [info exists ::env(DIST)] && $::env(DIST) == "centos6"} { xfail $test @@ -95,7 +83,6 @@ foreach name {f f2} { sync_after_int } - if {! [is_cygwin]} { # Illegal characters in file/dir names set test "completing $name a\\\"b/ should return d"; #" set cmd "$name a\\\"b/"; #" @@ -108,44 +95,28 @@ foreach name {f f2} { sync_after_int } - set test "completing $name a\\&b/ should return f" set cmd "$name a\\&b/" assert_complete_dir f $cmd "$::srcdir/fixtures/_filedir" $test - - sync_after_int - set test "completing $name a\$ should return a\\\$b/" set cmd "$name a\$" assert_complete_dir "\b\\\\\$b/" $cmd "$::srcdir/fixtures/_filedir" $test -nospace - - sync_after_int - set cmd "$name 'ab/" assert_complete_dir {e'} $cmd "$::srcdir/fixtures/_filedir" - - sync_after_int - set cmd "$name 'a b/" assert_complete_dir {i'} $cmd "$::srcdir/fixtures/_filedir" - - sync_after_int - set cmd "$name 'a\$b/" assert_complete_dir {h'} $cmd "$::srcdir/fixtures/_filedir" - - sync_after_int - if {! [is_cygwin]} { # Illegal characters in file/dir names set cmd "$name 'a\"b/"; #" assert_complete_dir {d'} $cmd "$TESTDIR/tmp" @@ -156,42 +127,28 @@ foreach name {f f2} { sync_after_int } - set cmd "$name 'a&b/" assert_complete_dir {f'} $cmd "$::srcdir/fixtures/_filedir" - - sync_after_int - set cmd "$name \"ab/"; #" assert_complete_dir {e"} $cmd "$::srcdir/fixtures/_filedir"; #" - - sync_after_int - set cmd "$name \"a b/"; #" assert_complete_dir {i"} $cmd "$::srcdir/fixtures/_filedir"; #" - - sync_after_int - set cmd "$name \"a'b/"; #" assert_complete_dir {c"} $cmd "$::srcdir/fixtures/_filedir"; #" - - sync_after_int - if {! [is_cygwin]} { # Illegal characters in file/dir names set cmd "$name \"a\\\"b/"; #" assert_complete_dir {d"} $cmd "$TESTDIR/tmp"; #" sync_after_int } - if {[info exists ::env(CI)] && [info exists ::env(DIST)] && $::env(DIST) == "centos6"} { xfail "$name \"a\\\$b/ should show completions" } else { @@ -200,44 +157,28 @@ foreach name {f f2} { sync_after_int } - set cmd "$name \"a\\b/"; #" assert_complete_dir "\b\b\bb/e\\\"" $cmd "$::srcdir/fixtures/_filedir" - - sync_after_int - set cmd "$name \"a\\\\b/"; #" assert_complete_dir {g"} $cmd "$TESTDIR/tmp"; #" - - sync_after_int - set cmd "$name \"a&b/"; #" assert_complete_dir {f"} $cmd "$::srcdir/fixtures/_filedir"; #" - - sync_after_int - set cmd "$name \\\[x" assert_complete_dir {\[x\]} $cmd "$::srcdir/fixtures/_filedir/brackets" - - sync_after_int }; # foreach - set test "completing with filter '.e1' should show completions" assert_complete_dir {ee.e1 foo/ gg.e1 ii.E1} "g " "$::srcdir/fixtures/_filedir/ext" $test - - sync_after_int - set test "completing f aĆ© should return g" # Execute this test only with LC_CTYPE matching *UTF-8* # See also: http://www.mail-archive.com/bash-completion-devel\ @@ -252,16 +193,11 @@ if { } else { unsupported "$test" } - - sync_after_int - set test "completing fd a\\ should return a\\ b/" set cmd "fd a\\ " assert_complete_dir "a\\ b/" $cmd "$::srcdir/fixtures/_filedir" $test -nospace - - sync_after_int diff --git a/test/unit/_get_comp_words_by_ref.exp b/test/unit/_get_comp_words_by_ref.exp index c113f6df..2683d163 100644 --- a/test/unit/_get_comp_words_by_ref.exp +++ b/test/unit/_get_comp_words_by_ref.exp @@ -23,122 +23,79 @@ setup set test "_get_comp_words_by_ref should run without errors" assert_bash_exec {_get_comp_words_by_ref cur > /dev/null} $test - - sync_after_int - # See also ./lib/completions/alias.exp. Here `_get_cword' is actually tested # by moving the cursor left into the current word. - set test "a b|"; # | = cursor position set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"b a"} $cmd $test - - sync_after_int - set test "a |"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=1; COMP_LINE='a '; COMP_POINT=2; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {" a"} $cmd $test - - sync_after_int - set test "|a"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE='a'; COMP_POINT=0; \ unset cur prev; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {" "} $cmd $test - - sync_after_int - set test "|a \$"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE='a '; COMP_POINT=0; \ unset cur prev; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {" "} $cmd $test - - sync_after_int - set test " | a \$"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE=' a '; COMP_POINT=1; \ unset cur prev; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {" "} $cmd $test - - 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; echo "$cur $prev"} assert_bash_list {" b"} $cmd $test - - sync_after_int - set test "a b | with WORDBREAKS -= :"; # | = cursor position set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_comp_words_by_ref -n : cur; printf %s "$cur"} assert_bash_list {} $cmd $test - - sync_after_int - set test "a b|c"; # | = cursor position set cmd {COMP_WORDS=(a bc); COMP_CWORD=1; COMP_LINE='a bc'; COMP_POINT=3; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"b a"} $cmd $test - - sync_after_int - set test "a | b"; # | = cursor position set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=2; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {" a"} $cmd $test - - sync_after_int - set test {a b\ c| should return b\ c}; # | = cursor position set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=6; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"b\\ c a"} $cmd $test - - sync_after_int - set test {a\ b a\ b| should return a\ b}; # | = cursor position set cmd {COMP_WORDS=('a\ b' 'a\ b'); COMP_CWORD=1; COMP_LINE='a\ b a\ b'; COMP_POINT=9; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"a\\ b a\\ b"} $cmd $test - - sync_after_int - set test {a b\| c should return b\ }; # | = cursor position set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=4; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"b\\ a"} $cmd $test - - sync_after_int - -set test {a "b\|}; #"# | = cursor position +set test {a "b\|}; #"# | = cursor position set cmd {COMP_WORDS=(a '"b\'); COMP_CWORD=1; COMP_LINE='a "b\'; COMP_POINT=5; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"\"b\\ a"} $cmd $test - - sync_after_int - set test {a 'b c|}; # | = cursor position set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1} append cmd {; COMP_LINE="a 'b c"; COMP_POINT=6; _get_comp_words_by_ref cur prev; echo "$cur $prev"} @@ -148,11 +105,8 @@ expect { -ex "'b c a\r\n/@" { pass "$test" } -ex "c b\r\n/@" { fail "$test" } } - - sync_after_int - set test {a "b c|}; #"# | = cursor position set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1} append cmd {; COMP_LINE="a \"b c"; COMP_POINT=6} @@ -164,11 +118,8 @@ expect { -ex "\"b c a\r\n/@" { pass "$test" } -ex "c b\r\n/@" { fail "$test" } } - - sync_after_int - set test {a b:c| with WORDBREAKS += :}; # | = cursor position set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3} set expected {"c :"} @@ -177,65 +128,47 @@ append cmd {; COMP_LINE='a b:c'; COMP_POINT=5} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list $expected $cmd $test - - sync_after_int - set test {a b:c| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} 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"} assert_bash_list {"b:c a"} $cmd $test - - sync_after_int - set test {a b c:| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3} 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"} assert_bash_list {"c: b"} $cmd $test - - sync_after_int - set test {a b:c | with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b : c ''); COMP_CWORD=4} 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"} assert_bash_list {" b:c"} $cmd $test - - sync_after_int - set test {a :| with WORDBREAKS -= : should return :}; # | = cursor position set cmd {COMP_WORDS=(a :); COMP_CWORD=1; COMP_LINE='a :'; COMP_POINT=3} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"} assert_bash_list {": a"} $cmd $test - - sync_after_int - set test {a b::| with WORDBREAKS -= : should return b::}; # | = cursor position set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2} 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"} assert_bash_list {"b:: a"} $cmd $test - - sync_after_int - # This test makes sure `_get_cword' doesn't use `echo' to return it's value, # because -n might be interpreted by `echo' and thus will not be returned. set test "a -n| should return -n"; # | = cursor position @@ -243,21 +176,15 @@ set cmd {COMP_WORDS=(a -n); COMP_CWORD=1; COMP_LINE='a -n'; COMP_POINT=4} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref cur; printf "%s\n" $cur} assert_bash_list -n $cmd $test - - sync_after_int - set test {a b>c| should return c}; # | = cursor position set cmd {COMP_WORDS=(a b \> c); COMP_CWORD=3; COMP_LINE='a b>c'; COMP_POINT=5} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref cur prev; echo "$cur"} assert_bash_list c $cmd $test - - sync_after_int - set test {a b=c| should return c}; # | = cursor position set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3} set expected c @@ -265,21 +192,15 @@ 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"} assert_bash_list $expected $cmd $test - - sync_after_int - set test {a *| should return *}; # | = cursor position set cmd {COMP_WORDS=(a \*); COMP_CWORD=1; COMP_LINE='a *'; COMP_POINT=4} assert_bash_exec $cmd set cmd {_get_comp_words_by_ref cur; echo "$cur"} assert_bash_list * $cmd $test - - sync_after_int - set test {a $(b c| should return $(b c}; # | = cursor position set cmd {COMP_WORDS=(a '$(b c'); COMP_CWORD=1; COMP_LINE='a $(b c'; COMP_POINT=7} assert_bash_exec $cmd @@ -291,11 +212,8 @@ expect { # Expected failure on bash-4 -ex "c/@" { xfail "$test" } } - - sync_after_int - set test {a $(b c\ d| should return $(b c\ d}; # | = cursor position set cmd {COMP_WORDS=(a '$(b c\ d'); COMP_CWORD=1; COMP_LINE='a $(b c\ d'; COMP_POINT=10} assert_bash_exec $cmd @@ -308,11 +226,8 @@ expect { # Expected failure on bash-4 -ex "c\\ d/@" { xfail "$test" } } - - sync_after_int - set test {a 'b&c| should return 'b&c}; # | = cursor position set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1} append cmd {; COMP_LINE="a 'b&c"; COMP_POINT=6} @@ -324,19 +239,13 @@ expect { -ex "'b&c/@" { pass "$test" } -ex "c/@" { fail "$test" } } - - 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 @@ -344,11 +253,8 @@ 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 @@ -356,11 +262,8 @@ 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 @@ -368,51 +271,37 @@ 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 : c| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3; COMP_LINE='a b : c'; COMP_POINT=7} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"} assert_bash_list {"a b : c"} $cmd $test - - sync_after_int - set test {a b: c| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} append cmd {; COMP_LINE='a b: c'; COMP_POINT=6} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"} assert_bash_list {"a b: c"} $cmd $test - - sync_after_int - set test {a b :c| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} append cmd {; COMP_LINE='a b :c'; COMP_POINT=6} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"} assert_bash_list {"a b :c"} $cmd $test - - sync_after_int - set test {a b\ :c| with WORDBREAKS -= :}; # | = cursor position set cmd {COMP_WORDS=(a "b\\ " : c); COMP_CWORD=3} append cmd {; COMP_LINE='a b\ :c'; COMP_POINT=7} assert_bash_exec $cmd $test set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"} assert_bash_list {a "b\\ :c"} $cmd $test - - sync_after_int diff --git a/test/unit/_get_cword.exp b/test/unit/_get_cword.exp index 3fd3e20e..9708a870 100644 --- a/test/unit/_get_cword.exp +++ b/test/unit/_get_cword.exp @@ -21,82 +21,54 @@ setup set test "_get_cword should run without errors" assert_bash_exec {_get_cword > /dev/null} $test - - sync_after_int - # See also ./lib/completions/alias.exp. Here `_get_cword' is actually tested # by moving the cursor left into the current word. - set test "a b| should return b"; # | = cursor position set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3; _get_cword; echo} assert_bash_list b $cmd $test - - sync_after_int - set test "a | should return nothing"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=1; COMP_LINE='a '; COMP_POINT=2; _get_cword} send "$cmd\r" expect -ex "$cmd\r\n/@" {pass "$test"} - - sync_after_int - set test "a b | should return nothing"; # | = cursor position set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_cword} send "$cmd\r" expect -ex "$cmd\r\n/@" {pass "$test"} - - sync_after_int - set test "a b | with WORDBREAKS -= : should return nothing"; # | = cursor position set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_cword :} send "$cmd\r" expect -ex "$cmd\r\n/@" {pass "$test"} - - sync_after_int - set test "a b|c should return b"; # | = cursor position set cmd {COMP_WORDS=(a bc); COMP_CWORD=1; COMP_LINE='a bc'; COMP_POINT=3; _get_cword; echo} assert_bash_list b $cmd $test - - sync_after_int - set test {a b\ c| should return b\ c}; # | = cursor position set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=6; _get_cword; echo} assert_bash_list {"b\\ c"} $cmd $test - - sync_after_int - set test {a b\| c should return b\ }; # | = cursor position set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=4; _get_cword; echo} assert_bash_list {"b\\"} $cmd $test - - sync_after_int - set test {a "b\| should return "b\ }; # | = cursor position set cmd {COMP_WORDS=(a '"b\'); COMP_CWORD=1; COMP_LINE='a "b\'; COMP_POINT=5; _get_cword; echo} assert_bash_list {"\"b\\"} $cmd $test - - sync_after_int - set test {a 'b c| should return 'b c}; # | = cursor position set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1} append cmd {; COMP_LINE="a 'b c"; COMP_POINT=6; _get_cword} @@ -106,11 +78,8 @@ expect { -ex "'b c/@" { pass "$test" } -ex "c/@" { fail "$test" } } - - sync_after_int - set test {a "b c| should return "b c}; # | = cursor position set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1} append cmd {; COMP_LINE="a \"b c"; COMP_POINT=6; _get_cword}; @@ -120,92 +89,62 @@ expect { -ex "\"b c/@" { pass "$test" } -ex "c/@" { fail "$test" } } - - sync_after_int - set test {a b:c| with WORDBREAKS += : should return c}; # | = cursor position set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3} set expected c append cmd {; COMP_LINE='a b:c'; COMP_POINT=5; _get_cword; echo} assert_bash_list $expected $cmd $test - - sync_after_int - set test {a b:c| with WORDBREAKS -= : should return b:c}; # | = cursor position set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} append cmd {; COMP_LINE='a b:c'; COMP_POINT=5; _get_cword :; echo} assert_bash_list b:c $cmd $test - - sync_after_int - set test {a b c:| with WORDBREAKS -= : should return c:}; # | = cursor position set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3} append cmd {; COMP_LINE='a b c:'; COMP_POINT=6; _get_cword :; echo} assert_bash_list c: $cmd $test - - sync_after_int - set test {a :| with WORDBREAKS -= : should return :}; # | = cursor position set cmd {COMP_WORDS=(a :); COMP_CWORD=1; COMP_LINE='a :'; COMP_POINT=3; _get_cword :; echo} assert_bash_list : $cmd $test - - sync_after_int - set test {a b::| with WORDBREAKS -= : should return b::}; # | = cursor position set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2} append cmd {; COMP_LINE='a b::'; COMP_POINT=5; _get_cword :; echo} assert_bash_list b:: $cmd $test - - sync_after_int - # This test makes sure `_get_cword' doesn't use `echo' to return it's value, # because -n might be interpreted by `echo' and thus will not be returned. set test "a -n| should return -n"; # | = cursor position set cmd {COMP_WORDS=(a -n); COMP_CWORD=1; COMP_LINE='a -n'; COMP_POINT=4; _get_cword; echo} assert_bash_list -n $cmd $test - - sync_after_int - set test {a b>c| should return c}; # | = cursor position set cmd {COMP_WORDS=(a b \> c); COMP_CWORD=3; COMP_LINE='a b>c'; COMP_POINT=5; _get_cword; echo} assert_bash_list c $cmd $test - - sync_after_int - set test {a b=c| should return c}; # | = cursor position set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3} set expected c append cmd {; COMP_LINE='a b=c'; COMP_POINT=5; _get_cword; echo} assert_bash_list $expected $cmd $test - - sync_after_int - set test {a *| should return *}; # | = cursor position set cmd {COMP_WORDS=(a \*); COMP_CWORD=1; COMP_LINE='a *'; COMP_POINT=4; _get_cword; echo} assert_bash_list * $cmd $test - - sync_after_int - set test {a $(b c| should return $(b c}; # | = cursor position set cmd {COMP_WORDS=(a '$(b c'); COMP_CWORD=1; COMP_LINE='a $(b c'; COMP_POINT=7; _get_cword} #assert_bash_list {{$(b\ c}} $cmd $test @@ -216,11 +155,8 @@ expect { # Expected failure on bash-4 -ex "c/@" { xfail "$test" } } - - sync_after_int - set test {a $(b c\ d| should return $(b c\ d}; # | = cursor position set cmd {COMP_WORDS=(a '$(b c\ d'); COMP_CWORD=1; COMP_LINE='a $(b c\ d'; COMP_POINT=10; _get_cword} #assert_bash_list {{$(b\ c\\\ d}} $cmd $test @@ -231,11 +167,8 @@ expect { # Expected failure on bash-4 -ex "c\\ d/@" { xfail "$test" } } - - sync_after_int - set test {a 'b&c| should return 'b&c}; # | = cursor position set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1} append cmd {; COMP_LINE="a 'b&c"; COMP_POINT=6; _get_cword} @@ -245,11 +178,8 @@ expect { -ex "'b&c/@" { pass "$test" } -ex "c/@" { fail "$test" } } - - sync_after_int - set test "index shouldn't drop below 0" set dir $::srcdir/fixtures/_get_cword set cmd "scp" @@ -259,8 +189,6 @@ expect { -re /@ { pass "$test" } default { unresolved "$test" } } - - sync_after_int diff --git a/test/unit/_init_completion.exp b/test/unit/_init_completion.exp index 75c41255..9408f86f 100644 --- a/test/unit/_init_completion.exp +++ b/test/unit/_init_completion.exp @@ -19,16 +19,11 @@ setup 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 cur prev words cword; _init_completion; }; foo; unset foo} $test - - sync_after_int - set test "|a"; # | = cursor position set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE='a'; COMP_POINT=0; _init_completion; echo "$cur $prev"} assert_bash_list {" "} $cmd $test - - sync_after_int diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp index c065f766..01b09b6b 100644 --- a/test/unit/_known_hosts_real.exp +++ b/test/unit/_known_hosts_real.exp @@ -20,47 +20,47 @@ setup set test "Hosts should be put in COMPREPLY" set hosts [get_hosts -unsorted] - # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config - # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts +# Hosts `gee', `hus' and `jar' are defined in +# ./fixtures/_known_hosts_real/config +# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 +# test cases in ./fixtures/_known_hosts_real/known_hosts lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42 set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY} assert_bash_list $hosts $cmd $test -sort - - sync_after_int - set test "Hosts should have username prefix and colon suffix" set hosts [get_hosts -unsorted] - # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config - # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts +# Hosts `gee', `hus' and `jar' are defined in +# ./fixtures/_known_hosts_real/config +# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 +# test cases in ./fixtures/_known_hosts_real/known_hosts lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42 set hosts [lsort -ascii $hosts] set expected {} foreach host $hosts { lappend expected "user@$host:" } - # Call _known_hosts +# 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 -sort - - sync_after_int - set test "Files containing consecutive spaces should work" set hosts [get_hosts -unsorted] set hosts_orig $hosts - # Hosts `gee' and `hus' are defined in `./fixtures/_known_hosts_real/spaced conf' - # Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2 +# Hosts `gee' and `hus' are defined in +#`./fixtures/_known_hosts_real/spaced conf' +# Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2 lappend hosts gee hus two two2 two3 two4 set hosts_config $hosts - # Hosts `doo' and `ike' are defined in `./fixtures/_known_hosts_/spaced known_hosts' +# Hosts `doo' and `ike' are defined in +# `./fixtures/_known_hosts_/spaced known_hosts' lappend hosts doo ike set hosts [join [bash_sort $hosts ] "\\s+"] set hosts_orig [join [bash_sort $hosts_orig ] "\\s+"] set hosts_config [join [bash_sort $hosts_config] "\\s+"] - # Call _known_hosts +# Call _known_hosts set cmd {unset COMPREPLY; _known_hosts_real -aF 'fixtures/_known_hosts_real/spaced conf' ''; echo_array COMPREPLY} send "$cmd\r" expect -ex "$cmd\r\n" @@ -71,23 +71,20 @@ expect { -re /@ { unresolved "$test at prompt" } default { unresolved "$test" } } - - sync_after_int - set test "Files starting with tilde (~) should work" set hosts [get_hosts -unsorted] - # Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2 - # Host `three' is defined in ./fixtures/_known_hosts_real/known_hosts3 - # Host `four' is defined in ./fixtures/_known_hosts_real/known_hosts4 +# Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2 +# Host `three' is defined in ./fixtures/_known_hosts_real/known_hosts3 +# Host `four' is defined in ./fixtures/_known_hosts_real/known_hosts4 lappend hosts two two2 two3 two4 three four set hosts [join [bash_sort $hosts] "\\s+"] - # Setup environment +# Setup environment set cmd {OLDHOME=$HOME; HOME=$SRCDIRABS} send "$cmd\r" expect -ex "$cmd\r\n/@" - # Call _known_hosts +# Call _known_hosts set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config_tilde ''; echo_array COMPREPLY} send "$cmd\r" expect -ex "$cmd\r\n" @@ -95,43 +92,41 @@ expect { -re "^$hosts\r\n/@$" { pass "$test" } default { unresolved "$test" } } - # Teardown environment +# Teardown environment set cmd {HOME=$OLDHOME} send "$cmd\r" expect -ex "$cmd\r\n/@" - - sync_after_int - set test "Empty COMP_KNOWN_HOSTS_WITH_HOSTFILE should omit HOSTFILE" assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE=" set hosts [get_hosts_avahi] - # Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config - # doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts +# Hosts `gee', `hus' and `jar' are defined in +# ./fixtures/_known_hosts_real/config +# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 +# test cases in ./fixtures/_known_hosts_real/known_hosts lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42 - # Call _known_hosts +# Call _known_hosts set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY} assert_bash_list $hosts $cmd $test -sort sync_after_int assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE" - - sync_after_int - set test "Included config files should work" set hosts [get_hosts -unsorted] - # Host 'recursion' is defined in ./fixtures/_known_hosts_real/config_include_recursion - # Host 'relative_path' is defined in ./fixtures/_known_hosts_real/.ssh/config_relative_path +# Host 'recursion' is defined in +# ./fixtures/_known_hosts_real/config_include_recursion +# Host 'relative_path' is defined in +# ./fixtures/_known_hosts_real/.ssh/config_relative_path lappend hosts recursion relative_path set hosts [join [bash_sort $hosts] "\\s+"] - # Setup environment - # Redefined HOME to handle relative path inclusions on $HOME/.ssh +# Setup environment +# Redefined HOME to handle relative path inclusions on $HOME/.ssh set cmd {OLDHOME=$HOME; HOME="$SRCDIRABS/fixtures/_known_hosts_real"} send "$cmd\r" expect -ex "$cmd\r\n/@" - # Call _known_hosts +# Call _known_hosts set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config_include ''; echo_array COMPREPLY} send "$cmd\r" expect -ex "$cmd\r\n" @@ -139,12 +134,37 @@ expect { -re "^$hosts\r\n/@$" { pass "$test" } default { unresolved "$test" } } - # Teardown environment +# Teardown environment set cmd {HOME=$OLDHOME} send "$cmd\r" expect -ex "$cmd\r\n/@" +sync_after_int +set test "IPv6 filtering should work" +set hosts "127.0.0.1 localhost" +assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE=" +set cmd {unset COMPREPLY; _known_hosts_real -4F fixtures/_known_hosts_real/localhost_config ''; echo_array COMPREPLY} +assert_bash_list $hosts $cmd $test -sort +sync_after_int +assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE" +sync_after_int +set test "IPv4 filtering should work" +set hosts "::1 localhost" +assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE=" +set cmd {unset COMPREPLY; _known_hosts_real -6F fixtures/_known_hosts_real/localhost_config ''; echo_array COMPREPLY} +assert_bash_list $hosts $cmd $test -sort +sync_after_int +assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE" +sync_after_int + +set test "IPv4+IPv6 filtering should work" +set hosts "localhost" +assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE=" +set cmd {unset COMPREPLY; _known_hosts_real -46F fixtures/_known_hosts_real/localhost_config ''; echo_array COMPREPLY} +assert_bash_list $hosts $cmd $test -sort +sync_after_int +assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE" sync_after_int diff --git a/test/unit/_tilde.exp b/test/unit/_tilde.exp index 19f47241..e313dcae 100644 --- a/test/unit/_tilde.exp +++ b/test/unit/_tilde.exp @@ -1,15 +1,7 @@ -# @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 +proc setup {} { save_env } - proc teardown {} { assert_env_unmodified { /COMPREPLY=/d @@ -17,37 +9,41 @@ proc teardown {} { } -setup part full +setup 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 failed_find_unique_completion 0 +assert_bash_exec {compgen -u} {} /@ users +if {![find_unique_completion_pair $users part full]} { + set failed_find_unique_completion 1 +} set test "~full should complete to ~full unmodified" -set cmd [format {_tilde "~%s"; printf "%%s\n" "${COMPREPLY[@]}"} $full] -assert_bash_list "~$full" $cmd $test - - -sync_after_int - +if {$failed_find_unique_completion} { + untested "Not running, no suitable test user found: $test" +} else { + set cmd [format {_tilde "~%s"; printf "%%s\n" "${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\n" "${COMPREPLY[@]}"} $part] -assert_bash_list "~$full" $cmd $test -sync_after_int - +if {$failed_find_unique_completion} { + untested "Not running, no suitable test user found: $test" +} else { + set cmd [format {_tilde "~%s"; printf "%%s\n" "${COMPREPLY[@]}"} $part] + assert_bash_list "~$full" $cmd $test + sync_after_int +} # Debian #766163 assert_no_complete "_tilde ~-o" diff --git a/test/unit/find_unique_completion_pair.exp b/test/unit/find_unique_completion_pair.exp index ec7f040d..4a95c1bf 100644 --- a/test/unit/find_unique_completion_pair.exp +++ b/test/unit/find_unique_completion_pair.exp @@ -24,6 +24,7 @@ proc test_find_ucp {{list} {epart} {econt} {eret 1}} { test_find_ucp {a} 0 0 0 test_find_ucp {ab} a b +test_find_ucp {ab ab ab} a b test_find_ucp {a ab abcd abc} 0 0 0 test_find_ucp {a ab abcde abc} abcd e test_find_ucp {user1 user2} 0 0 0 diff --git a/test/unit/quote.exp b/test/unit/quote.exp index afe670a2..1764e6b0 100644 --- a/test/unit/quote.exp +++ b/test/unit/quote.exp @@ -21,7 +21,6 @@ expect { } sync_after_int - set cmd {quote "a b"} set test {quote "a b" should output 'a b'} send "$cmd\r" @@ -32,7 +31,6 @@ expect { } sync_after_int - set cmd {quote " a "} set test {quote " a " should output ' a '} send "$cmd\r" @@ -43,7 +41,6 @@ expect { } sync_after_int - set cmd {quote "a'b'c"} set test {quote "a'b'c" should output 'a'\''b'\''c'} send "$cmd\r" @@ -54,7 +51,6 @@ expect { } sync_after_int - set cmd {quote "a'"} set test {quote "a'" should output 'a'\'''} send "$cmd\r" |