diff options
Diffstat (limited to 'completions')
469 files changed, 7249 insertions, 6871 deletions
diff --git a/completions/.gitignore b/completions/.gitignore index 34167766..5edc1726 100644 --- a/completions/.gitignore +++ b/completions/.gitignore @@ -11,6 +11,7 @@ autoheader automake-1.1[0123456] autossh autoupdate +bmake bsdtar btdownloadcurses.py btdownloadgui.py @@ -163,7 +164,9 @@ pydoc3 pylint-[23] pytest-[23] python2 +python2.7 python3 +python3.[345678] pypy pypy3 pyvenv-3.[45678] diff --git a/completions/2to3 b/completions/2to3 index 049ba65b..7c5b3303 100644 --- a/completions/2to3 +++ b/completions/2to3 @@ -6,19 +6,19 @@ _2to3() _init_completion -s || return case $prev in - -h|--help|--add-suffix) + -h | --help | --add-suffix) return ;; - -f|--fix|-x|--nofix) - COMPREPLY=( $(compgen -W \ - "$($1 --list-fixes 2>/dev/null | command sed -e 1d)" -- "$cur") ) + -f | --fix | -x | --nofix) + COMPREPLY=($(compgen -W \ + "$($1 --list-fixes 2>/dev/null | command sed -e 1d)" -- "$cur")) return ;; - -j|--processes) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + -j | --processes) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; - -o|--output-dir) + -o | --output-dir) _filedir -d return ;; @@ -27,13 +27,13 @@ _2to3() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir py } && -complete -F _2to3 2to3 + complete -F _2to3 2to3 # ex: filetype=sh diff --git a/completions/7z b/completions/7z index 96a64f1f..a8acbc59 100644 --- a/completions/7z +++ b/completions/7z @@ -5,8 +5,8 @@ _7z() local cur prev words cword _init_completion -n = || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'a b d e l t u x' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'a b d e l t u x' -- "$cur")) return fi @@ -15,7 +15,7 @@ _7z() case $cur in -ao*) - COMPREPLY=( $(compgen -P${cur:0:3} -W 'a s t u' -- "${cur:3}") ) + COMPREPLY=($(compgen -P${cur:0:3} -W 'a s t u' -- "${cur:3}")) return ;; -?(a)[ix]*) @@ -26,74 +26,79 @@ _7z() opt=${cur:0:2} cur=${cur:2} fi if [[ $cur != *[@\!]* ]]; then - COMPREPLY=( $(compgen -P$opt -W '@ ! r@ r-@ r0@ r! r-! r0!' \ - -- "$cur") ) + COMPREPLY=($(compgen -P$opt -W '@ ! r@ r-@ r0@ r! r-! r0!' \ + -- "$cur")) elif [[ $cur == ?(r@(-|0|))@* ]]; then - local IFS=$' \t\n' reset=$(shopt -po noglob); set -o noglob - COMPREPLY=( $(compgen -P"${opt}${cur%%@*}@" -f -- "${cur#*@}") ) + local IFS=$' \t\n' reset=$(shopt -po noglob) + set -o noglob + COMPREPLY=($(compgen -P"${opt}${cur%%@*}@" -f -- "${cur#*@}")) $reset compopt -o filenames fi return ;; - -mhe=*|-mhc=*|-ms=*|-mt=*) - COMPREPLY=( $(compgen -W 'on off' -- "${cur#*=}") ) + -mhe=* | -mhc=* | -ms=* | -mt=*) + COMPREPLY=($(compgen -W 'on off' -- "${cur#*=}")) return ;; -mx=*) - COMPREPLY=( $(compgen -W '0 1 3 5 7 9' -- "${cur#*=}") ) + COMPREPLY=($(compgen -W '0 1 3 5 7 9' -- "${cur#*=}")) return ;; - -o*|-w?*) - local IFS=$' \t\n' reset=$(shopt -po noglob); set -o noglob - COMPREPLY=( $(compgen -P${cur:0:2} -S/ -d -- "${cur:2}") ) + -o* | -w?*) + local reset=$(shopt -po noglob) + set -o noglob + compopt -o filenames + local ifs=$IFS IFS=$'\n' + COMPREPLY=($(compgen -d -P${cur:0:2} -S/ -- "${cur:2}")) + IFS=$ifs $reset - compopt -o nospace -o filenames + compopt -o nospace return ;; -r?*) - COMPREPLY=( $(compgen -P${cur:0:2} -W '- 0' -- "${cur:2}") ) + COMPREPLY=($(compgen -P${cur:0:2} -W '- 0' -- "${cur:2}")) return ;; -scs*) - COMPREPLY=( $(compgen -P${cur:0:4} -W 'UTF-8 WIN DOS' \ - -- "${cur:4}") ) + COMPREPLY=($(compgen -P${cur:0:4} -W 'UTF-8 WIN DOS' \ + -- "${cur:4}")) return ;; -ssc?*) - COMPREPLY=( $(compgen -P${cur:0:4} -W '-' -- "${cur:4}") ) + COMPREPLY=($(compgen -P${cur:0:4} -W '-' -- "${cur:4}")) return ;; -t*) if [[ $mode == w ]]; then - COMPREPLY=( $(compgen -P${cur:0:2} -W '7z bzip2 gzip swfc - tar wim xz zip' -- "${cur:2}") ) + COMPREPLY=($(compgen -P${cur:0:2} -W '7z bzip2 gzip swfc + tar wim xz zip' -- "${cur:2}")) else - COMPREPLY=( $(compgen -P${cur:0:2} -W '7z apm arj bzip2 cab + COMPREPLY=($(compgen -P${cur:0:2} -W '7z apm arj bzip2 cab chm cpio cramfs deb dmg elf fat flv gzip hfs iso lzh lzma lzma86 macho mbr mslz mub nsis ntfs pe ppmd rar rpm squashfs swf swfc tar udf vhd wim xar xz z zip' \ - -- "${cur:2}") ) + -- "${cur:2}")) fi return ;; - -m*=*|-p*|-u*|-v*) + -m*=* | -p* | -u* | -v*) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-ai -an -ao -ax -bd -i -m{x,s,f,he,hc,mt}= + COMPREPLY=($(compgen -W '-ai -an -ao -ax -bd -i -m{x,s,f,he,hc,mt}= -o -p -r -scs -sfx -si -slp -slt -so -ssc -t -u -v -w -x -y' \ - -- "$cur") ) - [[ $COMPREPLY == -@(an|bd|sfx|si|slt|so|ssc|[rwy]) ]] || + -- "$cur")) + [[ ${COMPREPLY-} == -@(an|bd|sfx|si|slt|so|ssc|[rwy]) ]] || compopt -o nospace return fi local args _count_args = - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _filedir_xspec unzip # TODO: parsing 7z i output? # - how to figure out if the format is input or output? @@ -109,15 +114,15 @@ _7z() else if [[ ${words[1]} == d ]]; then local IFS=$'\n' - COMPREPLY=( $(compgen -W "$(printf '%s\n' $($1 l ${words[2]} \ + COMPREPLY=($(compgen -W "$(printf '%s\n' "$($1 l ${words[2]} \ -slt 2>/dev/null | command sed -n '/^Path =/s/^Path = \(.*\)$/\1/p' \ - 2>/dev/null | tail -n+2))" -- "$cur") ) + 2>/dev/null | tail -n+2)")" -- "$cur")) compopt -o filenames else _filedir fi fi } && -complete -F _7z 7z 7za + complete -F _7z 7z 7za # ex: filetype=sh diff --git a/completions/Makefile.am b/completions/Makefile.am index 8f276d66..723b42f0 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -173,6 +173,7 @@ bashcomp_DATA = 2to3 \ invoke-rc.d \ _ionice \ ip \ + ipcalc \ iperf \ ipmitool \ ipsec \ @@ -322,6 +323,7 @@ bashcomp_DATA = 2to3 \ postsuper \ povray \ prelink \ + printenv \ protoc \ psql \ puppet \ @@ -370,6 +372,7 @@ bashcomp_DATA = 2to3 \ sbopkg \ screen \ scrub \ + secret-tool \ sh \ shellcheck \ sitecopy \ @@ -410,6 +413,7 @@ bashcomp_DATA = 2to3 \ tox \ tracepath \ tshark \ + tsig-keygen \ tune2fs \ _udevadm \ ulimit \ @@ -493,6 +497,7 @@ CLEANFILES = \ automake-1.16 \ autossh \ autoupdate \ + bmake \ bsdtar \ btdownloadcurses.py \ btdownloadgui.py \ @@ -662,7 +667,14 @@ CLEANFILES = \ pytest-2 \ pytest-3 \ python2 \ + python2.7 \ python3 \ + python3.3 \ + python3.4 \ + python3.5 \ + python3.6 \ + python3.7 \ + python3.8 \ pyvenv-3.4 \ pyvenv-3.5 \ pyvenv-3.6 \ @@ -837,7 +849,7 @@ symlinks: $(DATA) $(ss) lzip \ clzip pdlzip plzip $(ss) make \ - colormake gmake gnumake pmake + bmake colormake gmake gnumake pmake $(ss) man \ apropos whatis $(ss) mcrypt \ @@ -878,7 +890,7 @@ symlinks: $(DATA) $(ss) pylint \ pylint-2 pylint-3 $(ss) python \ - micropython pypy pypy3 python2 python3 + micropython pypy pypy3 python2 python2.7 python3 python3.3 python3.4 python3.5 python3.6 python3.7 python3.8 $(ss) pyvenv \ pyvenv-3.4 pyvenv-3.5 pyvenv-3.6 pyvenv-3.7 pyvenv-3.8 $(ss) qdbus \ diff --git a/completions/_adb b/completions/_adb index 52b2cb96..e8ebab13 100644 --- a/completions/_adb +++ b/completions/_adb @@ -5,9 +5,9 @@ _adb_command_usage() { - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ '$("$1" help 2>&1 | command grep "^ *\(adb \)\? *$2 " \ - | command sed -e "s/[]|[]/\n/g" | _parse_help -)' -- "$cur") ) + | command sed -e "s/[]|[]/\n/g" | _parse_help -)' -- "$cur")) } _adb() @@ -16,7 +16,7 @@ _adb() _init_completion || return case $prev in - -s|-p|--algo|--key|--iv) + -s | -p | --algo | --key | --iv) return ;; -f) @@ -26,23 +26,23 @@ _adb() esac local cmd i - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" != -* && "${words[i-1]}" != -[sp] ]]; then + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} != -* && ${words[i - 1]} != -[sp] ]]; then cmd="${words[i]}" break fi done - if [[ ! "$cmd" ]]; then + if [[ ! -v cmd ]]; then local tmp=() if [[ ! $cur || $cur == -* ]]; then - tmp+=( $(compgen -W '$(_parse_help "$1" help)' -- "$cur") ) + tmp+=($(compgen -W '$(_parse_help "$1" help)' -- "$cur")) fi if [[ ! $cur || $cur != -* ]]; then - tmp+=( $($1 help 2>&1 | awk '$1 == "adb" { print $2 }') ) - tmp+=( devices connect disconnect sideload ) + tmp+=($($1 help 2>&1 | awk '$1 == "adb" { print $2 }')) + tmp+=(devices connect disconnect sideload) fi - COMPREPLY=( $(compgen -W '${tmp[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${tmp[@]}' -- "$cur")) return fi @@ -51,19 +51,19 @@ _adb() _adb_command_usage "$1" $cmd case $cmd in - push|restore|sideload) + push | restore | sideload) _filedir ;; forward) - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ '$("$1" help 2>&1 | command sed -ne "s/^ *adb *forward *-/-/p" | \ - _parse_help -)' -- "$cur") ) + _parse_help -)' -- "$cur")) ;; reboot) - COMPREPLY=( $(compgen -W 'bootloader recovery' -- "$cur") ) + COMPREPLY=($(compgen -W 'bootloader recovery' -- "$cur")) ;; esac } && -complete -F _adb adb + complete -F _adb adb # ex: filetype=sh diff --git a/completions/_cal b/completions/_cal index ed304aa7..1eec2674 100644 --- a/completions/_cal +++ b/completions/_cal @@ -11,28 +11,28 @@ _cal() case $prev in -m) if [[ $OSTYPE == *bsd* ]]; then - COMPREPLY=( $(compgen -W '{1..12}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..12}' -- "$cur")) return fi ;; -s) [[ $OSTYPE == *bsd* ]] && return ;; - -A|-B|-d|-H) + -A | -B | -d | -H) return ;; esac if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) return fi local args _count_args - [[ $args -eq 1 ]] && COMPREPLY=( $(compgen -W '{1..12}' -- "$cur") ) + ((args == 1)) && COMPREPLY=($(compgen -W '{1..12}' -- "$cur")) } && -complete -F _cal cal ncal + complete -F _cal cal ncal # ex: filetype=sh diff --git a/completions/_chsh b/completions/_chsh index 64ce5a1b..8f8a8077 100644 --- a/completions/_chsh +++ b/completions/_chsh @@ -9,23 +9,23 @@ _chsh() _init_completion || return case $prev in - --list-shells|--help|-v|--version) + --list-shells | --help | -v | --version) return ;; - -s|--shell) + -s | --shell) _shells return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) else _allowed_users fi } && -complete -F _chsh chsh + complete -F _chsh chsh # ex: filetype=sh diff --git a/completions/_dmesg b/completions/_dmesg index 1dff7db2..83066541 100644 --- a/completions/_dmesg +++ b/completions/_dmesg @@ -11,23 +11,23 @@ _dmesg() _init_completion || return case $prev in - -h|--help|-V|--version|-s|--buffer-size|-M|-N) + -h | --help | -V | --version | -s | --buffer-size | -M | -N) return ;; - -f|--facility) - COMPREPLY=( $(compgen -W 'kern user mail daemon auth syslog lpr - news' -- "$cur") ) + -f | --facility) + COMPREPLY=($(compgen -W 'kern user mail daemon auth syslog lpr + news' -- "$cur")) return ;; - -l|--level|-n|--console-level) - COMPREPLY=( $(compgen -W '{1..8}' -- "$cur") ) + -l | --level | -n | --console-level) + COMPREPLY=($(compgen -W '{1..8}' -- "$cur")) return ;; esac local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) } && -complete -F _dmesg dmesg + complete -F _dmesg dmesg # ex: filetype=sh diff --git a/completions/_eject b/completions/_eject index 3c5838dc..52168f74 100644 --- a/completions/_eject +++ b/completions/_eject @@ -9,17 +9,17 @@ _eject() _init_completion || return case $prev in - -h|--help|-V|--version|-c|--changerslot|-x|--cdspeed) + -h | --help | -V | --version | -c | --changerslot | -x | --cdspeed) return ;; - -a|--auto|-i|--manualeject) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + -a | --auto | -i | --manualeject) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return elif [[ $prev == @(-d|--default) ]]; then return @@ -28,6 +28,6 @@ _eject() _cd_devices _dvd_devices } && -complete -F _eject eject + complete -F _eject eject # ex: filetype=sh diff --git a/completions/_hexdump b/completions/_hexdump index a3c2a839..785f5976 100644 --- a/completions/_hexdump +++ b/completions/_hexdump @@ -9,7 +9,7 @@ _hexdump() _init_completion || return case $prev in - -V|-e|-n|-s) + -V | -e | -n | -s) return ;; -f) @@ -20,12 +20,12 @@ _hexdump() if [[ $cur == -* ]]; then local opts="$(_parse_help "$1")" - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) return fi _filedir } && -complete -F _hexdump hexdump hd + complete -F _hexdump hexdump hd # ex: filetype=sh diff --git a/completions/_hwclock b/completions/_hwclock index 86a29346..ef437a26 100644 --- a/completions/_hwclock +++ b/completions/_hwclock @@ -9,18 +9,18 @@ _hwclock() _init_completion || return case $prev in - -h|--help|-V|--version|--date|--epoch) + -h | --help | -V | --version | --date | --epoch) return ;; - -f|--rtc|--adjfile) + -f | --rtc | --adjfile) _filedir return ;; esac COMPREPLY=( - $(PATH="$PATH:/sbin" compgen -W '$(_parse_help "$1")' -- "$cur") ) + $(PATH="$PATH:/sbin" compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _hwclock hwclock + complete -F _hwclock hwclock # ex: filetype=sh diff --git a/completions/_ionice b/completions/_ionice index 1aa51f2a..b0d96a13 100644 --- a/completions/_ionice +++ b/completions/_ionice @@ -9,7 +9,7 @@ _ionice() _init_completion || return local offset=0 i - for (( i=1; i <= cword; i++ )); do + for ((i = 1; i <= cword; i++)); do case ${words[i]} in -h) return @@ -18,8 +18,8 @@ _ionice() offset=0 break ;; - -c|-n) - (( i++ )) + -c | -n) + ((i++)) continue ;; -*) @@ -30,18 +30,18 @@ _ionice() break done - if [[ $offset -gt 0 ]]; then + if ((offset > 0)); then _command_offset $offset return fi case $prev in -c) - COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..3}' -- "$cur")) return ;; -n) - COMPREPLY=( $(compgen -W '{0..7}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..7}' -- "$cur")) return ;; -p) @@ -51,10 +51,10 @@ _ionice() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) return fi } && -complete -F _ionice ionice + complete -F _ionice ionice # ex: filetype=sh diff --git a/completions/_look b/completions/_look index 074e924a..9788dec5 100644 --- a/completions/_look +++ b/completions/_look @@ -8,10 +8,10 @@ _look() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur")) fi } && -complete -F _look -o default look + complete -F _look -o default look # ex: filetype=sh diff --git a/completions/_mock b/completions/_mock index e596a4c4..b468148d 100644 --- a/completions/_mock +++ b/completions/_mock @@ -11,27 +11,27 @@ _mock() local plugins='tmpfs root_cache yum_cache bind_mount ccache' local cfgdir=/etc/mock count=0 i - for i in "${words[@]}" ; do - [[ $count -eq $cword ]] && break - if [[ "$i" == --configdir ]]; then - cfgdir="${words[((count+1))]}" - elif [[ "$i" == --configdir=* ]]; then + for i in "${words[@]}"; do + ((count == cword)) && break + if [[ $i == --configdir ]]; then + cfgdir="${words[count + 1]}" + elif [[ $i == --configdir=* ]]; then cfgdir=${i/*=/} fi - (( count++ )) + ((count++)) done case $prev in - -h|--help|--copyin|--copyout|--arch|-D|--define|--with|--without|\ - --uniqueext|--rpmbuild_timeout|--sources|--cwd) + -h | --help | --copyin | --copyout | --arch | -D | --define | --with | --without | \ + --uniqueext | --rpmbuild_timeout | --sources | --cwd) return ;; - -r|--root) - COMPREPLY=( $(compgen -W "$(command ls $cfgdir)" -- "$cur") ) - COMPREPLY=( ${COMPREPLY[@]/%.cfg/} ) + -r | --root) + COMPREPLY=($(compgen -W "$(command ls $cfgdir)" -- "$cur")) + COMPREPLY=(${COMPREPLY[@]/%.cfg/}) return ;; - --configdir|--resultdir) + --configdir | --resultdir) _filedir -d return ;; @@ -44,26 +44,26 @@ _mock() # (e.g. ix86 chroot builds in x86_64 mock host) # This would actually depend on what the target root # can be used to build for... - COMPREPLY=( $(compgen -W "$(command rpm --showrc | \ + COMPREPLY=($(compgen -W "$(command rpm --showrc | command sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p')" \ - -- "$cur") ) + -- "$cur")) return ;; - --enable-plugin|--disable-plugin) - COMPREPLY=( $(compgen -W "$plugins" -- "$cur") ) + --enable-plugin | --disable-plugin) + COMPREPLY=($(compgen -W "$plugins" -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir '@(?(no)src.r|s)pm' fi } && -complete -F _mock mock + complete -F _mock mock # ex: filetype=sh diff --git a/completions/_modules b/completions/_modules index 36fffdf6..4f7c4d48 100644 --- a/completions/_modules +++ b/completions/_modules @@ -5,8 +5,8 @@ # # Completion for Environment Modules `module' alias. # -# See http://sourceforge.net/projects/modules/ -# http://modules.sourceforge.net/ +# See https://sourceforge.net/projects/modules/ +# https://modules.sourceforge.net/ # # There are several versions of modules that are commonly used. Older # Cray UNICOS systems and many other sites use 2.2.2b. The latest GPL'd @@ -21,64 +21,65 @@ # being sourced before it and thus before the `module' alias has been defined. [ -f /etc/profile.d/modules.sh ] || return 1 -_module_list () +_module_list() { local modules="$(command sed 's/:/ /g' <<<$LOADEDMODULES | sort)" compgen -W "$modules" -- $1 } -_module_path () +_module_path() { local modules="$(command sed 's/:/ /g' <<<$MODULEPATH | sort)" compgen -W "$modules" -- $1 } -_module_avail () +_module_avail() { - local modules="$(\ - module avail 2>&1 | \ - command grep -E -v '^(-|$)' | \ - xargs printf '%s\n' | command sed -e 's/(default)//g' | sort)" + local modules="$( + module avail 2>&1 | + command grep -E -v '^(-|$)' | + xargs printf '%s\n' | command sed -e 's/(default)//g' | sort + )" compgen -W "$modules" -- $1 } # A completion function for the module alias -_module () +_module() { local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then + if ((cword == 1)); then # First parameter on line -- we expect it to be a mode selection local options - options="$(module help 2>&1 | command grep -E '^[[:space:]]*\+' | \ - awk '{print $2}' | command sed -e 's/|/ /g' | sort)" + options="$(module help 2>&1 | command grep -E '^[[:space:]]*\+' | + awk '{print $2}' | command sed -e 's/|/ /g' | sort)" - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) - elif [[ $cword -eq 2 ]]; then + elif ((cword == 2)); then case $prev in - add|display|help|load|show|whatis) - COMPREPLY=( $(_module_avail "$cur") ) + add | display | help | load | show | whatis) + COMPREPLY=($(_module_avail "$cur")) ;; - rm|switch|swap|unload|update) - COMPREPLY=( $(_module_list "$cur") ) + rm | switch | swap | unload | update) + COMPREPLY=($(_module_list "$cur")) ;; unuse) - COMPREPLY=( $(_module_path "$cur") ) + COMPREPLY=($(_module_path "$cur")) ;; esac - elif [[ $cword -eq 3 ]]; then + elif ((cword == 3)); then case ${words[1]} in - swap|switch) - COMPREPLY=( $(_module_avail "$cur") ) + swap | switch) + COMPREPLY=($(_module_avail "$cur")) ;; esac fi } && -complete -F _module -o default module + complete -F _module -o default module # ex: filetype=sh diff --git a/completions/_mount b/completions/_mount index 494f97ba..85f54907 100644 --- a/completions/_mount +++ b/completions/_mount @@ -22,44 +22,44 @@ _mount() local sm host case $prev in - -t|--types) + -t | --types) _fstypes return ;; esac - [[ "$cur" == \\ ]] && cur="/" + [[ $cur == \\ ]] && cur="/" - if [[ "$cur" == *:* ]]; then + if [[ $cur == *:* ]]; then for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do [[ -x $sm ]] || continue - COMPREPLY=( $(compgen -W "$("$sm" -e ${cur%%:*} | \ - awk 'NR>1 {print $1}')" -- "${cur#*:}") ) + COMPREPLY=($(compgen -W "$("$sm" -e ${cur%%:*} | + awk 'NR>1 {print $1}')" -- "${cur#*:}")) return done fi - if [[ "$cur" == //* ]]; then + if [[ $cur == //* ]]; then host=${cur#//} host=${host%%/*} if [[ -n $host ]]; then - COMPREPLY=( $(compgen -P "//$host" -W \ + COMPREPLY=($(compgen -P "//$host" -W \ "$(smbclient -d 0 -NL $host 2>/dev/null | - command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' | - command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p')" \ - -- "${cur#//$host}") ) + command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' | + command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p')" \ + -- "${cur#//$host}")) fi elif [[ -r /etc/vfstab ]]; then # Solaris - COMPREPLY=( $(compgen -W "$(awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab)" -- "$cur")) elif [[ ! -e /etc/fstab ]]; then # probably Cygwin - COMPREPLY=( $(compgen -W "$($1 | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}')" -- "$cur")) else # probably BSD - COMPREPLY=( $(compgen -W "$(awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab)" -- "$cur")) fi } && -complete -F _mount -o default -o dirnames mount + complete -F _mount -o default -o dirnames mount # ex: filetype=sh diff --git a/completions/_mount.linux b/completions/_mount.linux index c74aaec6..f40865ea 100644 --- a/completions/_mount.linux +++ b/completions/_mount.linux @@ -10,239 +10,243 @@ _mount() local split=false case "$prev" in - -t|--types) + -t | --types) # find /lib/modules/$(uname -r)/ -type f -path '*/fs/*.ko' -printf '%f\n' | cut -d. -f1 # FIXME: no<fstype> - if [[ "$cur" == ?*,* ]]; then + if [[ $cur == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" split=true fi - COMPREPLY=( $(compgen -W 'auto adfs affs autofs btrfs cifs coda + COMPREPLY=($(compgen -W 'auto adfs affs autofs btrfs cifs coda cramfs davfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs iso9660 jffs2 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs - udf ufs umsdos usbfs vfat xfs' -- "$cur") ) + udf ufs umsdos usbfs vfat xfs' -- "$cur")) _fstypes - $split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} ) + $split && COMPREPLY=(${COMPREPLY[@]/#/$prev,}) return ;; - --bind|-B|--rbind|-R) + --bind | -B | --rbind | -R) _filedir -d return ;; - -p|--pass-fd) - COMPREPLY=( $(compgen -W '{0..9}') ) + -p | --pass-fd) + COMPREPLY=($(compgen -W '{0..9}')) compopt -o nospace return ;; -L) - COMPREPLY=( $(cd "/dev/disk/by-label/" 2>/dev/null || return; \ - compgen -f -- "$cur") ) + COMPREPLY=($( + cd "/dev/disk/by-label/" 2>/dev/null || return + compgen -f -- "$cur" + )) return ;; -U) - COMPREPLY=( $(cd "/dev/disk/by-uuid/" 2>/dev/null || return; \ - compgen -f -- "$cur") ) + COMPREPLY=($( + cd "/dev/disk/by-uuid/" 2>/dev/null || return + compgen -f -- "$cur" + )) return ;; - -O|--test-opts) + -O | --test-opts) # argument required but no completions available return ;; - -o|--options) + -o | --options) local fstype=auto # default fstype - for (( i=${#words[@]}-1; i>0; i-- )); do - if [[ "${words[i]}" == -@(t|-types)* ]]; then - if [[ "${words[i]}" == *=* ]]; then - [[ "${words[i]}" == ?*,* ]] && break + for ((i = ${#words[@]} - 1; i > 0; i--)); do + if [[ ${words[i]} == -@(t|-types)* ]]; then + if [[ ${words[i]} == *=* ]]; then + [[ ${words[i]} == ?*,* ]] && break fstype="${words[i]#-*=}" else - [[ "${words[i+1]}" == ?*,* ]] && break - fstype="${words[i+1]}" + [[ ${words[i + 1]} == ?*,* ]] && break + fstype="${words[i + 1]}" fi break fi done # no<fstype> is not a real fstype, reset to "auto" - [[ "$fstype" == no?* ]] && fstype=auto + [[ $fstype == no?* ]] && fstype=auto # split options list - if [[ "$cur" == ?*,* ]]; then + if [[ $cur == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" split=true fi # no completion if $cur is opt=smth - [[ "$cur" == *=* ]] && return + [[ $cur == *=* ]] && return # mount options - COMPREPLY=( $(compgen -W 'loop {,a}sync {,no}atime {,no}auto + COMPREPLY=($(compgen -W 'loop {,a}sync {,no}atime {,no}auto {,fs,def,root}context= defaults {,no}dev {,no}diratime dirsync {,no}exec group {,no}iversion {,no}mand _netdev nofail {,no}relatime {,no}strictatime {,no}suid owner remount ro rw - {,no}user users' -- "$cur") ) + {,no}user users' -- "$cur")) case "$fstype" in - adfs|auto) - COMPREPLY+=( $(compgen -W '{u,g}id= {own,oth}mask=' -- "$cur") ) - ;;& - affs|auto) - COMPREPLY+=( $(compgen -W '{u,g}id= set{u,g}id= mode= protect + adfs | auto) + COMPREPLY+=($(compgen -W '{u,g}id= {own,oth}mask=' -- "$cur")) + ;;& + affs | auto) + COMPREPLY+=($(compgen -W '{u,g}id= set{u,g}id= mode= protect usemp verbose prefix= volume= reserved= root= bs= - {,no,usr,grp}quota' -- "$cur") ) - ;;& - btrfs|auto) - COMPREPLY+=( $(compgen -W 'degraded subvol= subvolid= device= + {,no,usr,grp}quota' -- "$cur")) + ;;& + btrfs | auto) + COMPREPLY+=($(compgen -W 'degraded subvol= subvolid= device= nodatasum nodatacow nobarrier max_inline= alloc_start= thread_pool= compress= compress-force= ssd noacl notreelog flushoncommit metadata_ratio= {,no}space_cache clear_cache - user_subvol_rm_allowed autodefrag inode_cache' -- "$cur") ) - ;;& - cifs|auto) - COMPREPLY+=( $(compgen -W 'user= password= credentials= {u,g}id= + user_subvol_rm_allowed autodefrag inode_cache' -- "$cur")) + ;;& + cifs | auto) + COMPREPLY+=($(compgen -W 'user= password= credentials= {u,g}id= force{u,g}id port= servern= netbiosname= {file,dir}_mode= ip= domain= guest iocharset {,no}setuids {,no,dyn}perm directio {,no}mapchars {,no}intr hard soft noacl nocase sec= nobrl sfu {,no}serverino nounix nouser_xattr {r,w}size= - rwpidforward backup{u,g}id cache=' -- "$cur") ) - ;;& - davfs|auto) - COMPREPLY+=( $(compgen -W 'conf= {file,dir}_mode= {u,g}id= - username=' -- "$cur") ) - ;;& - ext[2-4]|auto) - COMPREPLY+=( $(compgen -W '{,no}acl bsddf minixdf check= debug + rwpidforward backup{u,g}id cache=' -- "$cur")) + ;;& + davfs | auto) + COMPREPLY+=($(compgen -W 'conf= {file,dir}_mode= {u,g}id= + username=' -- "$cur")) + ;;& + ext[2-4] | auto) + COMPREPLY+=($(compgen -W '{,no}acl bsddf minixdf check= debug errors= {,no}grpid {bsd,sysv}groups {,no,usr,grp}quota nobh nouid32 oldalloc orlov res{u,g}id= sb= - {,no}user_xattr' -- "$cur") ) - ;;& - ext[34]|auto) - COMPREPLY+=( $(compgen -W 'journal= journal_dev= norecovery - noload data= barrier= commit=' -- "$cur") ) - ;;& - ext4|auto) - COMPREPLY+=( $(compgen -W 'journal_checksum journal_async_commit + {,no}user_xattr' -- "$cur")) + ;;& + ext[34] | auto) + COMPREPLY+=($(compgen -W 'journal= journal_dev= norecovery + noload data= barrier= commit=' -- "$cur")) + ;;& + ext4 | auto) + COMPREPLY+=($(compgen -W 'journal_checksum journal_async_commit nobarrier inode_readahead= stripe= {,no}delalloc abort {max,min}_batch_time= journal_ioprio= {,no}auto_da_alloc {,no}discard nouid32 resize {,no}block_validity - dioread_{,no}lock max_dir_size_kb= i_version' -- "$cur") ) - ;;& - msdos|umsdos|vfat|auto) - COMPREPLY+=( $(compgen -W 'blocksize= {u,g}id= {u,d,f}mask= + dioread_{,no}lock max_dir_size_kb= i_version' -- "$cur")) + ;;& + msdos | umsdos | vfat | auto) + COMPREPLY+=($(compgen -W 'blocksize= {u,g}id= {u,d,f}mask= allow_utime= check= codepage= conv= cvf_format= cvf_option= debug fat= iocharset= tz= quiet showexec sys_immutable flush - usefree {,no}dots dotsOK=' -- "$cur") ) - ;;& - vfat|auto) - COMPREPLY+=( $(compgen -W 'uni_xlate posix nonumtail utf8 - shortname=' -- "$cur") ) - ;;& - iso9660|auto) - COMPREPLY+=( $(compgen -W 'norock nojoliet check= {u,g}id= map= + usefree {,no}dots dotsOK=' -- "$cur")) + ;;& + vfat | auto) + COMPREPLY+=($(compgen -W 'uni_xlate posix nonumtail utf8 + shortname=' -- "$cur")) + ;;& + iso9660 | auto) + COMPREPLY+=($(compgen -W 'norock nojoliet check= {u,g}id= map= mode= unhide block= conv= cruft session= sbsector= - iocharset= utf8' -- "$cur") ) - ;;& - jffs2|auto) - COMPREPLY+=( $(compgen -W 'compr= rp_size=' -- "$cur") ) - ;;& - jfs|auto) - COMPREPLY+=( $(compgen -W 'iocharset= resize= {,no}integrity - errors= {,no,usr,grp}quota' -- "$cur") ) - ;;& - nfs|nfs4|auto) - COMPREPLY+=( $(compgen -W 'soft hard timeo= retrans= {r,w}size= + iocharset= utf8' -- "$cur")) + ;;& + jffs2 | auto) + COMPREPLY+=($(compgen -W 'compr= rp_size=' -- "$cur")) + ;;& + jfs | auto) + COMPREPLY+=($(compgen -W 'iocharset= resize= {,no}integrity + errors= {,no,usr,grp}quota' -- "$cur")) + ;;& + nfs | nfs4 | auto) + COMPREPLY+=($(compgen -W 'soft hard timeo= retrans= {r,w}size= {,no}ac acreg{min,max}= acdir{min,max}= actimeo= bg fg retry= sec= {,no}sharecache {,no}resvport lookupcache= - proto= port= {,no}intr {,no}cto {,nfs}vers= ' -- "$cur") ) - ;;& - nfs|auto) - COMPREPLY+=( $(compgen -W 'udp tcp rdma mount{port,proto,host}= + proto= port= {,no}intr {,no}cto {,nfs}vers= ' -- "$cur")) + ;;& + nfs | auto) + COMPREPLY+=($(compgen -W 'udp tcp rdma mount{port,proto,host}= mountvers= namlen={,no}lock {,no}acl {,no}rdirplus - {,no}fsc' -- "$cur") ) - ;;& - nfs4|auto) - COMPREPLY+=( $(compgen -W 'clientaddr= {,no}migration' \ - -- "$cur") ) - ;;& - ntfs-3g) - COMPREPLY+=( $(compgen -W '{u,g}id= {u,f,d}mask= usermapping= + {,no}fsc' -- "$cur")) + ;;& + nfs4 | auto) + COMPREPLY+=($(compgen -W 'clientaddr= {,no}migration' \ + -- "$cur")) + ;;& + ntfs-3g) + COMPREPLY+=($(compgen -W '{u,g}id= {u,f,d}mask= usermapping= permissions inherit locale= force {,no}recover ignore_case remove_hiberfile show_sys_files hide_{hid,dot}_files windows_names allow_other max_read= silent no_def_opts streams_interface= user_xattr efs_raw - {,no}compression debug no_detach' -- "$cur") ) - ;;& - proc|auto) - COMPREPLY+=( $(compgen -W '{u,g}id=' -- "$cur") ) - ;;& - reiserfs|auto) - COMPREPLY+=( $(compgen -W 'conv hash= {,no_un}hashed_relocation + {,no}compression debug no_detach' -- "$cur")) + ;;& + proc | auto) + COMPREPLY+=($(compgen -W '{u,g}id=' -- "$cur")) + ;;& + reiserfs | auto) + COMPREPLY+=($(compgen -W 'conv hash= {,no_un}hashed_relocation noborder nolog notail replayonly resize= user_xattr acl - barrier=' -- "$cur") ) - ;;& - tmpfs|auto) - COMPREPLY+=( $(compgen -W 'size= nr_blocks= nr_inodes= mode= - {u,g}id= mpol=' -- "$cur") ) - ;;& - udf|auto) - COMPREPLY+=( $(compgen -W '{u,g}id= umask= unhide undelete + barrier=' -- "$cur")) + ;;& + tmpfs | auto) + COMPREPLY+=($(compgen -W 'size= nr_blocks= nr_inodes= mode= + {u,g}id= mpol=' -- "$cur")) + ;;& + udf | auto) + COMPREPLY+=($(compgen -W '{u,g}id= umask= unhide undelete nostrict iocharset bs= novrs session= anchor= volume= - partition= lastblock= fileset= rootdir=' -- "$cur") ) - ;;& - usbfs|auto) - COMPREPLY+=( $(compgen -W 'dev{u,g}id= devmode= bus{u,g}id= - busmode= list{u,g}id= listmode=' -- "$cur") ) - ;;& - xfs|auto) - COMPREPLY+=( $(compgen -W 'allocsize= {,no}attr2 barrier dmapi + partition= lastblock= fileset= rootdir=' -- "$cur")) + ;;& + usbfs | auto) + COMPREPLY+=($(compgen -W 'dev{u,g}id= devmode= bus{u,g}id= + busmode= list{u,g}id= listmode=' -- "$cur")) + ;;& + xfs | auto) + COMPREPLY+=($(compgen -W 'allocsize= {,no}attr2 barrier dmapi {,no}grpid {bsd,sysv}groups ihashsize= {,no}ikeep inode{32,64} {,no}largeio logbufs= logbsize= logdev= rtdev= mtpt= noalign norecovery nouuid osyncisosync {u,g,p}qnoenforce {,u,usr,g,grp,p,prj}quota sunit= swidth= - swalloc' -- "$cur") ) - ;;& + swalloc' -- "$cur")) + ;;& esac # COMP_WORDBREAKS is a real pain in the ass prev="${prev##*[$COMP_WORDBREAKS]}" - $split && COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + $split && COMPREPLY=(${COMPREPLY[@]/#/"$prev,"}) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version --help --verbose --all --fork + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--version --help --verbose --all --fork --fake --internal-only -l --no-mtab --no-canonicalize --pass-fd -s --read-only --rw -L -U --types --test-opts --options --bind --rbind - --move' -- "$cur") ) - [[ $COMPREPLY ]] && return + --move' -- "$cur")) + [[ ${COMPREPLY-} ]] && return fi - [[ "$cur" == \\ ]] && cur="/" + [[ $cur == \\ ]] && cur="/" local sm host - if [[ "$cur" == *:* ]]; then + if [[ $cur == *:* ]]; then for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do [[ -x $sm ]] || continue - COMPREPLY=( $(compgen -W "$("$sm" -e ${cur%%:*} | \ - awk 'NR>1 {print $1}')" -- "${cur#*:}") ) + COMPREPLY=($(compgen -W "$("$sm" -e ${cur%%:*} | + awk 'NR>1 {print $1}')" -- "${cur#*:}")) return done fi - if [[ "$cur" == //* ]]; then + if [[ $cur == //* ]]; then host=${cur#//} host=${host%%/*} if [[ -n $host ]]; then - COMPREPLY=( $(compgen -P "//$host" -W \ + COMPREPLY=($(compgen -P "//$host" -W \ "$(smbclient -d 0 -NL $host 2>/dev/null | - command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' | - command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p' )" \ - -- "${cur#//$host}") ) + command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' | + command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p')" \ + -- "${cur#//$host}")) fi fi _filedir } && -complete -F _mount mount + complete -F _mount mount # ex: filetype=sh diff --git a/completions/_newgrp b/completions/_newgrp index 0f0d3f93..a2dc3eda 100644 --- a/completions/_newgrp +++ b/completions/_newgrp @@ -8,12 +8,12 @@ _newgrp() local cur prev words cword _init_completion || return - if [[ "$cur" == "-" ]]; then - COMPREPLY=( - ) + if [[ $cur == "-" ]]; then + COMPREPLY=(-) else _allowed_groups "$cur" fi } && -complete -F _newgrp newgrp + complete -F _newgrp newgrp # ex: filetype=sh diff --git a/completions/_nmcli b/completions/_nmcli index 780a477f..eac285b0 100644 --- a/completions/_nmcli +++ b/completions/_nmcli @@ -5,33 +5,33 @@ _nmcli_list() { - COMPREPLY=( $(compgen -W '$1' -- "$cur") ) + COMPREPLY=($(compgen -W '$1' -- "$cur")) } _nmcli_con_id() { local IFS=$'\n' - COMPREPLY=( $(compgen -W "$(nmcli con list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(nmcli con list 2>/dev/null | + tail -n +2 | awk -F ' {2,}' '{print $1 }')" -- "$cur")) } _nmcli_con_uuid() { - COMPREPLY=( $(compgen -W "$(nmcli con list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(nmcli con list 2>/dev/null | + tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur")) } _nmcli_ap_ssid() { local IFS=$'\n' - COMPREPLY=( $(compgen -W "$(nmcli dev wifi list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $1}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(nmcli dev wifi list 2>/dev/null | + tail -n +2 | awk -F ' {2,}' '{print $1}')" -- "$cur")) } _nmcli_ab_bssid() { - COMPREPLY=( $(compgen -W "$(nmcli dev wifi list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(nmcli dev wifi list 2>/dev/null | + tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur")) } _nmcli() @@ -40,15 +40,15 @@ _nmcli() _init_completion || return case $prev in - -m|--mode) - COMPREPLY=( $(compgen -W 'tabular multiline' -- "$cur") ) + -m | --mode) + COMPREPLY=($(compgen -W 'tabular multiline' -- "$cur")) return ;; - -f|--fields) - COMPREPLY=( $(compgen -W 'all common' -- "$cur") ) + -f | --fields) + COMPREPLY=($(compgen -W 'all common' -- "$cur")) return ;; - -e|--escape) + -e | --escape) _nmcli_list "yes no" return ;; @@ -74,12 +74,12 @@ _nmcli() ;; esac - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--terse --pretty --mode --fields - --escape --version --help' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--terse --pretty --mode --fields + --escape --version --help' -- "$cur")) else - COMPREPLY=( $(compgen -W "nm con dev" -- "$cur") ) + COMPREPLY=($(compgen -W "nm con dev" -- "$cur")) fi else local object=${words[1]} @@ -110,50 +110,50 @@ _nmcli() ;; esac - COMPREPLY=( $(compgen -W 'status permissions enable sleep - wifi wwan wimax' -- "$cur") ) + COMPREPLY=($(compgen -W 'status permissions enable sleep + wifi wwan wimax' -- "$cur")) ;; con) case $command in list) - COMPREPLY=( $(compgen -W 'id uuid' -- "$cur") ) + COMPREPLY=($(compgen -W 'id uuid' -- "$cur")) return ;; up) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--nowait --timeout' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--nowait --timeout' \ + -- "$cur")) else - COMPREPLY=( $(compgen -W 'id uuid iface ap nsp' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'id uuid iface ap nsp' \ + -- "$cur")) fi return ;; down) - COMPREPLY=( $(compgen -W 'id uuid' -- "$cur") ) + COMPREPLY=($(compgen -W 'id uuid' -- "$cur")) return ;; delete) - COMPREPLY=( $(compgen -W 'id uuid' -- "$cur") ) + COMPREPLY=($(compgen -W 'id uuid' -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W 'list status up down delete' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'list status up down delete' \ + -- "$cur")) ;; dev) case $command in list) - COMPREPLY=( $(compgen -W 'iface' -- "$cur") ) + COMPREPLY=($(compgen -W 'iface' -- "$cur")) return ;; disconnect) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--nowait --timeout' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--nowait --timeout' \ + -- "$cur")) else - COMPREPLY=( $(compgen -W 'iface' -- "$cur") ) + COMPREPLY=($(compgen -W 'iface' -- "$cur")) fi return ;; @@ -162,40 +162,40 @@ _nmcli() case $subcommand in list) - COMPREPLY=( $(compgen -W 'iface bssid' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'iface bssid' \ + -- "$cur")) return ;; connect) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--private - --nowait --timeout' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--private + --nowait --timeout' -- "$cur")) else - if [[ "$prev" == "connect" ]]; then + if [[ $prev == "connect" ]]; then _nmcli_ap_ssid else - COMPREPLY=( $(compgen -W 'password + COMPREPLY=($(compgen -W 'password wep-key-type iface bssid name' \ - -- "$cur") ) + -- "$cur")) fi fi return ;; esac - COMPREPLY=( $(compgen -W 'list connect' -- "$cur") ) + COMPREPLY=($(compgen -W 'list connect' -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W 'status list disconnect wifi' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'status list disconnect wifi' \ + -- "$cur")) ;; esac fi } && -complete -F _nmcli nmcli + complete -F _nmcli nmcli # ex: filetype=sh diff --git a/completions/_renice b/completions/_renice index 2598533d..a4167440 100644 --- a/completions/_renice +++ b/completions/_renice @@ -11,8 +11,8 @@ _renice() local command=$1 curopt i=0 # walk back through command line and find last option - while [[ $i -le $cword && ${#COMPREPLY[@]} -eq 0 ]]; do - curopt=${words[cword-$i]} + while ((i <= cword && ${#COMPREPLY[@]} == 0)); do + curopt=${words[cword - i]} case "$curopt" in -u) _allowed_users @@ -20,13 +20,13 @@ _renice() -g) _pgids ;; - -p|$command) + -p | "$command") _pids ;; esac - (( i++ )) + ((i++)) done } && -complete -F _renice renice + complete -F _renice renice # ex: filetype=sh diff --git a/completions/_repomanage b/completions/_repomanage index ea27f07e..ba0787e7 100644 --- a/completions/_repomanage +++ b/completions/_repomanage @@ -8,17 +8,17 @@ _repomanage() local cur prev words cword split _init_completion -s || return - [[ "$prev" == -@([hk]|-help|-keep) ]] && return + [[ $prev == -@([hk]|-help|-keep) ]] && return $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir -d fi } && -complete -F _repomanage repomanage + complete -F _repomanage repomanage # ex: filetype=sh diff --git a/completions/_reptyr b/completions/_reptyr index 00cccddd..01d61b2a 100644 --- a/completions/_reptyr +++ b/completions/_reptyr @@ -15,12 +15,12 @@ _reptyr() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi [[ $prev != +([0-9]) ]] && _pids } && -complete -F _reptyr reptyr + complete -F _reptyr reptyr # ex: filetype=sh diff --git a/completions/_rfkill b/completions/_rfkill index a14a3eaf..96a6c098 100644 --- a/completions/_rfkill +++ b/completions/_rfkill @@ -8,24 +8,24 @@ _rfkill() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--version' -- "$cur")) else case $cword in 1) - COMPREPLY=( $(compgen -W "help event list block unblock" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "help event list block unblock" \ + -- "$cur")) ;; 2) if [[ $prev == block || $prev == unblock ]]; then - COMPREPLY=( $(compgen -W "$($1 list | awk -F: \ + COMPREPLY=($(compgen -W "$($1 list | awk -F: \ '/^[0-9]/ {print $1}') all wifi bluetooth uwb wimax \ - wwan gps" -- "$cur") ) + wwan gps" -- "$cur")) fi ;; esac fi } && -complete -F _rfkill rfkill + complete -F _rfkill rfkill # ex: filetype=sh diff --git a/completions/_rtcwake b/completions/_rtcwake index 43d264c9..4ca452d9 100644 --- a/completions/_rtcwake +++ b/completions/_rtcwake @@ -9,24 +9,24 @@ _rtcwake() _init_completion -s || return case "$prev" in - --help|-h|--version|-V|--seconds|-s|--time|-t) + --help | -h | --version | -V | --seconds | -s | --time | -t) return ;; - --mode|-m) - COMPREPLY=( $(compgen -W 'standby mem disk on no off' -- "$cur") ) + --mode | -m) + COMPREPLY=($(compgen -W 'standby mem disk on no off' -- "$cur")) return ;; - --device|-d) - COMPREPLY=( $(command ls -d /dev/rtc?* 2>/dev/null) ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]#/dev/}' -- "$cur") ) + --device | -d) + COMPREPLY=($(command ls -d /dev/rtc?* 2>/dev/null)) + COMPREPLY=($(compgen -W '${COMPREPLY[@]#/dev/}' -- "$cur")) return ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _rtcwake rtcwake + complete -F _rtcwake rtcwake # ex: filetype=sh diff --git a/completions/_su b/completions/_su index 9c0f59c1..1a03c8f7 100644 --- a/completions/_su +++ b/completions/_su @@ -8,34 +8,34 @@ if [[ $OSTYPE != *linux* ]]; then return fi -_su() # linux-specific completion -{ +_su() +{ # linux-specific completion local cur prev words cword split _init_completion -s || return case "$prev" in - -s|--shell) + -s | --shell) _shells return ;; - -c|--command|--session-command) + -c | --command | --session-command) local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -d -c -- "$cur") ) + COMPREPLY=($(compgen -d -c -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) } && -complete -F _su su + complete -F _su su # ex: filetype=sh diff --git a/completions/_svn b/completions/_svn index 42e2dbe7..5d85c2b4 100644 --- a/completions/_svn +++ b/completions/_svn @@ -16,11 +16,11 @@ _svn() proplist plist pl propset pset ps resolved revert \ status stat st switch sw unlock update up' - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--version' -- "$cur")) else - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + COMPREPLY=($(compgen -W "$commands" -- "$cur")) fi else @@ -29,7 +29,7 @@ _svn() _filedir -d return ;; - -F|--file|--targets) + -F | --file | --targets) _filedir return ;; @@ -37,17 +37,16 @@ _svn() _xfunc iconv _iconv_charsets return ;; - --editor-cmd|--diff-cmd|--diff3-cmd) - words=(words[0] $cur) - cword=1 - _command + --editor-cmd | --diff-cmd | --diff3-cmd) + compopt -o filenames + COMPREPLY=($(compgen -c -- "$cur")) return ;; esac local command=${words[1]} - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # possible options for the command local options case $command in @@ -55,7 +54,7 @@ _svn() options='--auto-props --no-auto-props --force --targets --no-ignore --non-recursive --quiet' ;; - blame|annotate|ann|praise) + blame | annotate | ann | praise) options='--revision --username --password --no-auth-cache --non-interactive --verbose --incremental --xml' ;; @@ -63,7 +62,7 @@ _svn() options='--revision --username --password --no-auth-cache --non-interactive' ;; - checkout|co) + checkout | co) options='--revision --quiet --non-recursive --username --password --no-auth-cache --non-interactive --ignore-externals' @@ -71,23 +70,23 @@ _svn() cleanup) options='--diff3-cmd' ;; - commit|ci) + commit | ci) options='--message --file --encoding --force-log --quiet --non-recursive --targets --editor-cmd --username --password --no-auth-cache --non-interactive --no-unlock' ;; - copy|cp) + copy | cp) options='--message --file --encoding --force-log --revision --quiet --editor-cmd -username --password --no-auth-cache --non-interactive' ;; - delete|del|remove|rm) + delete | del | remove | rm) options='--force --message --file --encoding --force-log --quiet --targets --editor-cmd --username --password --no-auth-cache --non-interactive' ;; - diff|di) + diff | di) options='--revision --extensions --diff-cmd --no-diff-deleted --non-recursive --username --password --no-auth-cache --non-interactive @@ -109,7 +108,7 @@ _svn() --non-interactive --revision --xml --targets --recursive --incremental' ;; - list|ls) + list | ls) options='--revision --verbose --recursive --username --password --no-auth-cache --non-interactive --incremental --xml' @@ -136,32 +135,32 @@ _svn() --editor-cmd --username --password --no-auth-cache --non-interactive' ;; - move|mv|rename|ren) + move | mv | rename | ren) options='--message --file --encoding --force-log --revision --quiet --force --editor-cmd --username --password --no-auth-cache --non-interactive' ;; - propdel|pdel|pd) + propdel | pdel | pd) options='--quiet --recursive --revision --revprop --username --password --no-auth-cache --non-interactive' ;; - propedit|pedit|pe) + propedit | pedit | pe) options='--revision --revprop --encoding --editor-cmd --username --password --no-auth-cache --non-interactive --force' ;; - propget|pget|pg) + propget | pget | pg) options='--recursive --revision --revprop --strict --username --password --no-auth-cache --non-interactive' ;; - proplist|plist|pl) + proplist | plist | pl) options='--verbose --recursive --revision --revprop --quiet --username --password --no-auth-cache --non-interactive' ;; - propset|pset|ps) + propset | pset | ps) options='--file --quiet --targets --recursive --revprop --encoding --username --password --no-auth-cache --non-interactive --revision --force' @@ -172,13 +171,13 @@ _svn() revert) options='--targets --recursive --quiet' ;; - status|stat|st) + status | stat | st) options='--show-updates --verbose --non-recursive --quiet --username --password --no-auth-cache --non-interactive --no-ignore --ignore-externals --incremental --xml' ;; - switch|sw) + switch | sw) options='--relocate --revision --non-recursive --quiet --username --password --no-auth-cache --non-interactive --diff3-cmd' @@ -187,7 +186,7 @@ _svn() options='--targets --force --username --password --no-auth-cache --non-interactive' ;; - update|up) + update | up) options='--revision --non-recursive --quiet --username --password --no-auth-cache --non-interactive --diff3-cmd --ignore-externals' @@ -195,10 +194,10 @@ _svn() esac options+=" --help --config-dir" - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) else - if [[ "$command" == @(help|[h?]) ]]; then - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + if [[ $command == @(help|[h?]) ]]; then + COMPREPLY=($(compgen -W "$commands" -- "$cur")) else _filedir fi @@ -206,6 +205,6 @@ _svn() fi } && -complete -F _svn svn + complete -F _svn svn # ex: filetype=sh diff --git a/completions/_svnadmin b/completions/_svnadmin index 7a86c43e..654fd3ec 100644 --- a/completions/_svnadmin +++ b/completions/_svnadmin @@ -12,11 +12,11 @@ _svnadmin() commands='create deltify dump help ? hotcopy list-dblogs list-unused-dblogs load lslocks lstxns recover rmlocks rmtxns setlog verify' - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--version' -- "$cur")) else - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + COMPREPLY=($(compgen -W "$commands" -- "$cur")) fi else case $prev in @@ -25,14 +25,14 @@ _svnadmin() return ;; --fs-type) - COMPREPLY=( $(compgen -W 'fsfs bdb' -- "$cur") ) + COMPREPLY=($(compgen -W 'fsfs bdb' -- "$cur")) return ;; esac local command=${words[1]} - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # possible options for the command local options case $command in @@ -62,10 +62,10 @@ _svnadmin() esac options+=" --help" - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) else - if [[ "$command" == @(help|[h?]) ]]; then - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + if [[ $command == @(help|[h?]) ]]; then + COMPREPLY=($(compgen -W "$commands" -- "$cur")) else _filedir fi @@ -73,6 +73,6 @@ _svnadmin() fi } && -complete -F _svnadmin -o default svnadmin + complete -F _svnadmin -o default svnadmin # ex: filetype=sh diff --git a/completions/_svnlook b/completions/_svnlook index 2cbd134b..36188a57 100644 --- a/completions/_svnlook +++ b/completions/_svnlook @@ -12,20 +12,20 @@ _svnlook() commands='author cat changed date diff dirs-changed help ? h history info lock log propget pget pg proplist plist pl tree uuid youngest' - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--version' -- "$cur")) else - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + COMPREPLY=($(compgen -W "$commands" -- "$cur")) fi else local command=${words[1]} - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # possible options for the command local options case $command in - author|cat|date|dirs-changed|info|log) + author | cat | date | dirs-changed | info | log) options='--revision --transaction' ;; changed) @@ -38,7 +38,7 @@ _svnlook() history) options='--revision --show-ids' ;; - propget|proplist) + propget | proplist) options='--revision --transaction --revprop' ;; tree) @@ -47,10 +47,10 @@ _svnlook() esac options+=" --help" - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) else - if [[ "$command" == @(help|[h?]) ]]; then - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + if [[ $command == @(help|[h?]) ]]; then + COMPREPLY=($(compgen -W "$commands" -- "$cur")) else _filedir fi @@ -58,6 +58,6 @@ _svnlook() fi } && -complete -F _svnlook -o default svnlook + complete -F _svnlook -o default svnlook # ex: filetype=sh diff --git a/completions/_udevadm b/completions/_udevadm index ce43f1ad..19624be9 100644 --- a/completions/_udevadm +++ b/completions/_udevadm @@ -9,7 +9,7 @@ _udevadm() _init_completion -s || return local i udevcmd - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do if [[ ${words[i]} != -* ]]; then udevcmd=${words[i]} break @@ -17,19 +17,19 @@ _udevadm() done case $prev in - --help|--version|--property|--children-max|--timeout|--seq-start|\ - --seq-end|--attr-match|--attr-nomatch|--parent-match|--property-match|\ - --tag-match|--subsystem-match|--subsystem-nomatch|--sysname-match|\ - --path) + --help | --version | --property | --children-max | --timeout | --seq-start | \ + --seq-end | --attr-match | --attr-nomatch | --parent-match | --property-match | \ + --tag-match | --subsystem-match | --subsystem-nomatch | --sysname-match | \ + --path) return ;; --log-priority) - COMPREPLY=( $(compgen -W 'err info debug' -- "$cur") ) + COMPREPLY=($(compgen -W 'err info debug' -- "$cur")) return ;; --query) - COMPREPLY=( $(compgen -W 'name symlink path property all' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'name symlink path property all' \ + -- "$cur")) return ;; --name) @@ -37,41 +37,41 @@ _udevadm() _filedir return ;; - --device-id-of-file|--exit-if-exists) + --device-id-of-file | --exit-if-exists) _filedir return ;; --action) - COMPREPLY=( $(compgen -W 'add change remove' -- "$cur") ) + COMPREPLY=($(compgen -W 'add change remove' -- "$cur")) return ;; --type) - COMPREPLY=( $(compgen -W 'devices subsystems failed' -- "$cur") ) + COMPREPLY=($(compgen -W 'devices subsystems failed' -- "$cur")) return ;; esac $split && return - if [[ -z $udevcmd ]]; then + if [[ ! -v udevcmd ]]; then case $cur in -*) - COMPREPLY=( $(compgen -W '--help --version --debug' -- "$cur") ) + COMPREPLY=($(compgen -W '--help --version --debug' -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W "$("$1" --help 2>/dev/null | - awk '/^[ \t]/ { print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$("$1" --help 2>/dev/null | + awk '/^[ \t]/ { print $1 }')" -- "$cur")) ;; esac return fi if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W \ - '$("$1" $udevcmd --help 2>/dev/null | _parse_help -)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W \ + '$("$1" ${udevcmd-} --help 2>/dev/null | _parse_help -)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _udevadm udevadm + complete -F _udevadm udevadm # ex: filetype=sh diff --git a/completions/_umount b/completions/_umount index a5d338bc..36d5703f 100644 --- a/completions/_umount +++ b/completions/_umount @@ -17,8 +17,8 @@ _umount() _init_completion || return local IFS=$'\n' - COMPREPLY=( $(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur")) } && -complete -F _umount -o dirnames umount + complete -F _umount -o dirnames umount # ex: filetype=sh diff --git a/completions/_umount.linux b/completions/_umount.linux index 59727b4b..cf8a2595 100644 --- a/completions/_umount.linux +++ b/completions/_umount.linux @@ -15,7 +15,7 @@ _reply_compgen_array() # argument. local i wlist for i in ${!COMPREPLY[*]}; do - local q=$(quote "$(printf %q "${COMPREPLY[$i]}")") + local q=$(quote "$(printf %q "${COMPREPLY[i]}")") wlist+=$q$'\n' done @@ -25,13 +25,14 @@ _reply_compgen_array() ecur=${ecur//\'/\\\'} # Actually generate completions. - local oldifs=$IFS + local ifs=$IFS IFS=$'\n' eval 'COMPREPLY=(`compgen -W "$wlist" -- "${ecur}"`)' - IFS=$oldifs + IFS=$ifs } # Unescape strings in the linux fstab(5) format (with octal escapes). -__linux_fstab_unescape() { +__linux_fstab_unescape() +{ eval $1="'${!1//\'/\\047}'" eval $1="'${!1/%\\/\\\\}'" eval "$1=$'${!1}'" @@ -40,23 +41,24 @@ __linux_fstab_unescape() { # Complete linux fstab entries. # # Reads a file from stdin in the linux fstab(5) format; as used by /etc/fstab -# and /proc/mounts. +# and /proc/mounts. With 1st arg -L, look for entries by label. +# shellcheck disable=SC2120 _linux_fstab() { COMPREPLY=() # Read and unescape values into COMPREPLY local fs_spec fs_file fs_other - local oldifs="$IFS" + local ifs="$IFS" while read -r fs_spec fs_file fs_other; do if [[ $fs_spec == [#]* ]]; then continue; fi - if [[ $1 == -L ]]; then - local fs_label=${fs_spec/#LABEL=} + if [[ ${1-} == -L ]]; then + local fs_label=${fs_spec/#LABEL=/} if [[ $fs_label != "$fs_spec" ]]; then __linux_fstab_unescape fs_label IFS=$'\0' COMPREPLY+=("$fs_label") - IFS=$oldifs + IFS=$ifs fi else __linux_fstab_unescape fs_spec @@ -64,7 +66,7 @@ _linux_fstab() IFS=$'\0' [[ $fs_spec == */* ]] && COMPREPLY+=("$fs_spec") [[ $fs_file == */* ]] && COMPREPLY+=("$fs_file") - IFS=$oldifs + IFS=$ifs fi done @@ -81,12 +83,12 @@ _linux_fstab() dircur="${cur%/*}/" fi basecur=${cur#"$dircur"} - local i n=${#COMPREPLY[@]} - for (( i=0; i < $n; i++ )); do - [[ "${COMPREPLY[i]}" == "$realcur"* ]] && - COMPREPLY+=( $(cd "$dircur" 2>/dev/null && + local i + for i in ${!COMPREPLY[*]}; do + [[ ${COMPREPLY[i]} == "$realcur"* ]] && + COMPREPLY+=($(cd "$dircur" 2>/dev/null && compgen -f -d -P "$dircur" \ - -X "!${COMPREPLY[i]##"$dirrealcur"}" -- "$basecur") ) + -X "!${COMPREPLY[i]##"$dirrealcur"}" -- "$basecur")) done fi fi @@ -103,18 +105,18 @@ _umount() -t) # FIXME: no<fstype> local split=false - if [[ "$cur" == ?*,* ]]; then + if [[ $cur == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" split=true fi - COMPREPLY=( $(compgen -W 'adfs affs autofs btrfs cifs coda + COMPREPLY=($(compgen -W 'adfs affs autofs btrfs cifs coda cramfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs iso9660 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf ufs - umsdos usbfs vfat xfs' -- "$cur") ) + umsdos usbfs vfat xfs' -- "$cur")) _fstypes - $split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} ) + $split && COMPREPLY=(${COMPREPLY[@]/#/$prev,}) return ;; -O) @@ -123,10 +125,10 @@ _umount() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-V -h -v -n -r -d -i -a -t -O -f -l - --no-canonicalize --fake' -- "$cur") ) - [[ $COMPREPLY ]] && return + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-V -h -v -n -r -d -i -a -t -O -f -l + --no-canonicalize --fake' -- "$cur")) + [[ ${COMPREPLY-} ]] && return fi if [[ -r /proc/mounts ]]; then @@ -135,9 +137,9 @@ _umount() _linux_fstab </proc/mounts else local IFS=$'\n' - COMPREPLY=( $(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur")) fi } && -complete -F _umount -o dirnames umount + complete -F _umount -o dirnames umount # ex: filetype=sh diff --git a/completions/_xm b/completions/_xm index d7b74b89..06b25d3c 100644 --- a/completions/_xm +++ b/completions/_xm @@ -6,14 +6,14 @@ _xen_domain_names() { - COMPREPLY=( $(compgen -W "$(xm list 2>/dev/null | \ - awk '!/Name|Domain-0/ { print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(xm list 2>/dev/null | + awk '!/Name|Domain-0/ { print $1 }')" -- "$cur")) } _xen_domain_ids() { - COMPREPLY=( $(compgen -W "$(xm list 2>/dev/null | \ - awk '!/Name|Domain-0/ { print $2 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(xm list 2>/dev/null | + awk '!/Name|Domain-0/ { print $2 }')" -- "$cur")) } _xm() @@ -36,16 +36,16 @@ _xm() labels addlabel rmlabel getlabel dry-run resources dumppolicy setpolicy resetpolicy getpolicy shell help' - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W "$commands" -- "$cur")) else - if [[ "$cur" == *=* ]]; then + if [[ $cur == *=* ]]; then prev=${cur/=*/} cur=${cur/*=/} fi command=${words[1]} - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # possible options for the command case $command in create) @@ -66,7 +66,7 @@ _xm() sched-credit) options='-d -w -c' ;; - block-list|network-list|vtpm-list|vnet-list) + block-list | network-list | vtpm-list | vnet-list) options='-l --long' ;; getpolicy) @@ -78,12 +78,12 @@ _xm() -s --skipdtd -p --paused -c --console_autoconnect' ;; esac - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) else case $command in - console|destroy|domname|domid|list|mem-set|mem-max| \ - pause|reboot|rename|shutdown|unpause|vcpu-list|vcpu-pin| \ - vcpu-set|block-list|network-list|vtpm-list) + console | destroy | domname | domid | list | mem-set | mem-max | \ + pause | reboot | rename | shutdown | unpause | vcpu-list | vcpu-pin | \ + vcpu-set | block-list | network-list | vtpm-list) _count_args case $args in 2) @@ -93,7 +93,7 @@ _xm() ;; migrate) _count_args - case $args in + case $args in 2) _xen_domain_names ;; @@ -102,7 +102,7 @@ _xm() ;; esac ;; - restore|dry-run|vnet-create) + restore | dry-run | vnet-create) _filedir ;; save) @@ -123,7 +123,7 @@ _xm() _xen_domain_names ;; 3) - COMPREPLY=( $(compgen -W "r s e i u b" -- "$cur") ) + COMPREPLY=($(compgen -W "r s e i u b" -- "$cur")) ;; esac ;; @@ -134,10 +134,10 @@ _xm() _xen_domain_names ;; 3) - COMPREPLY=( $(compgen -W "phy: file:" -- "$cur") ) + COMPREPLY=($(compgen -W "phy: file:" -- "$cur")) ;; 5) - COMPREPLY=( $(compgen -W "w r" -- "$cur") ) + COMPREPLY=($(compgen -W "w r" -- "$cur")) ;; 6) _xen_domain_names @@ -151,9 +151,9 @@ _xm() _xen_domain_names ;; 3) - COMPREPLY=( $(compgen -W "$(xm block-list $prev \ + COMPREPLY=($(compgen -W "$(xm block-list $prev \ 2>/dev/null | awk '!/Vdev/ { print $1 }')" \ - -- "$cur") ) + -- "$cur")) ;; esac ;; @@ -164,8 +164,8 @@ _xm() _xen_domain_names ;; *) - COMPREPLY=( $(compgen -W "script= ip= mac= bridge= - backend=" -- "$cur") ) + COMPREPLY=($(compgen -W "script= ip= mac= bridge= + backend=" -- "$cur")) ;; esac ;; @@ -176,9 +176,9 @@ _xm() _xen_domain_names ;; 3) - COMPREPLY=( $(compgen -W "$(xm network-list $prev \ + COMPREPLY=($(compgen -W "$(xm network-list $prev \ 2>/dev/null | awk '!/Idx/ { print $1 }')" \ - -- "$cur") ) + -- "$cur")) ;; esac ;; @@ -192,13 +192,13 @@ _xm() ;; create) _filedir - COMPREPLY+=( \ + COMPREPLY+=( $(compgen -W '$(command ls /etc/xen 2>/dev/null)' \ - -- "$cur") ) + -- "$cur")) ;; new) case $prev in - -f|-F|--defconfig|--config) + -f | -F | --defconfig | --config) _filedir return ;; @@ -209,7 +209,7 @@ _xm() esac _count_args - case $args in + case $args in 2) _xen_domain_names ;; @@ -219,6 +219,6 @@ _xm() fi fi } && -complete -F _xm xm + complete -F _xm xm # ex: filetype=sh diff --git a/completions/_yum b/completions/_yum index d5e06eca..224ea254 100644 --- a/completions/_yum +++ b/completions/_yum @@ -5,16 +5,16 @@ _yum_list() { - if [[ "$1" == all ]]; then + if [[ $1 == all ]]; then # Try to strip in between headings like "Available Packages" # This will obviously only work for English :P - COMPREPLY=( $(yum -d 0 -C list $1 "$cur*" 2>/dev/null | \ + COMPREPLY=($(yum -d 0 -C list $1 "$cur*" 2>/dev/null | command sed -ne '/^Available /d' -e '/^Installed /d' -e '/^Updated /d' \ - -e 's/[[:space:]].*//p') ) + -e 's/[[:space:]].*//p')) else # Drop first line (e.g. "Updated Packages") - COMPREPLY=( $(yum -d 0 -C list $1 "$cur*" 2>/dev/null | \ - command sed -ne 1d -e 's/[[:space:]].*//p') ) + COMPREPLY=($(yum -d 0 -C list $1 "$cur*" 2>/dev/null | + command sed -ne 1d -e 's/[[:space:]].*//p')) fi } @@ -23,14 +23,14 @@ _yum_repolist() # -d 0 causes repolist to output nothing as of yum 3.2.22: # http://yum.baseurl.org/ticket/83 # Drop first ("repo id repo name") and last ("repolist: ...") rows - yum --noplugins -C repolist $1 2>/dev/null | \ + yum --noplugins -C repolist $1 2>/dev/null | command sed -ne '/^repo\s\s*id/d' -e '/^repolist:/d' -e 's/[[:space:]].*//p' } _yum_plugins() { - command ls /usr/lib/yum-plugins/*.py{,c,o} 2>/dev/null \ - | command sed -ne 's|.*/\([^./]*\)\.py[co]\{0,1\}$|\1|p' | sort -u + command ls /usr/lib/yum-plugins/*.py{,c,o} 2>/dev/null | + command sed -ne 's|.*/\([^./]*\)\.py[co]\{0,1\}$|\1|p' | sort -u } _yum() @@ -39,16 +39,17 @@ _yum() _init_completion -s || return local special i - for (( i=0; i < ${#words[@]}-1; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do if [[ ${words[i]} == @(install|update|upgrade|remove|erase|deplist|info) ]]; then special=${words[i]} + break fi done - if [[ -n $special ]]; then + if [[ -v special ]]; then # TODO: install|update|upgrade should not match *src.rpm - if [[ "$cur" == @(*/|[.~])* && \ - "$special" == @(deplist|install|update|upgrade) ]]; then + if [[ $cur == @(*/|[.~])* && \ + $special == @(deplist|install|update|upgrade) ]]; then _filedir rpm return fi @@ -57,15 +58,15 @@ _yum() _yum_list available return ;; - deplist|info) + deplist | info) _yum_list all return ;; - upgrade|update) + upgrade | update) _yum_list updates return ;; - remove|erase) + remove | erase) # _rpm_installed_packages is not arch-qualified _yum_list installed return @@ -75,22 +76,22 @@ _yum() case $prev in list) - COMPREPLY=( $(compgen -W 'all available updates installed extras - obsoletes recent' -- "$cur") ) + COMPREPLY=($(compgen -W 'all available updates installed extras + obsoletes recent' -- "$cur")) ;; clean) - COMPREPLY=( $(compgen -W 'packages headers metadata cache dbcache - all' -- "$cur") ) + COMPREPLY=($(compgen -W 'packages headers metadata cache dbcache + all' -- "$cur")) ;; repolist) - COMPREPLY=( $(compgen -W 'all enabled disabled' -- "$cur") ) + COMPREPLY=($(compgen -W 'all enabled disabled' -- "$cur")) ;; - localinstall|localupdate) + localinstall | localupdate) # TODO: should not match *src.rpm _filedir rpm ;; - -d|-e) - COMPREPLY=( $(compgen -W '{0..10}' -- "$cur") ) + -d | -e) + COMPREPLY=($(compgen -W '{0..10}' -- "$cur")) ;; -c) _filedir @@ -99,45 +100,45 @@ _yum() _filedir -d ;; --enablerepo) - COMPREPLY=( $(compgen -W '$(_yum_repolist disabled)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_yum_repolist disabled)' -- "$cur")) ;; --disablerepo) - COMPREPLY=( $(compgen -W '$(_yum_repolist enabled)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_yum_repolist enabled)' -- "$cur")) ;; --disableexcludes) - COMPREPLY=( $(compgen -W '$(_yum_repolist all) all main' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '$(_yum_repolist all) all main' \ + -- "$cur")) ;; - --enableplugin|--disableplugin) - COMPREPLY=( $(compgen -W '$(_yum_plugins)' -- "$cur") ) + --enableplugin | --disableplugin) + COMPREPLY=($(compgen -W '$(_yum_plugins)' -- "$cur")) ;; --color) - COMPREPLY=( $(compgen -W 'always auto never' -- "$cur") ) + COMPREPLY=($(compgen -W 'always auto never' -- "$cur")) ;; - -R|-x|--exclude) + -R | -x | --exclude) # argument required but no completions available return ;; - -h|--help|--version) + -h | --help | --version) # no other options useful with these return ;; *) - COMPREPLY=( $(compgen -W 'install update check-update upgrade + COMPREPLY=($(compgen -W 'install update check-update upgrade remove erase list info provides whatprovides clean makecache groupinstall groupupdate grouplist groupremove groupinfo search shell resolvedep localinstall localupdate deplist - repolist help' -- "$cur") ) + repolist help' -- "$cur")) ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _yum yum + complete -F _yum yum # ex: filetype=sh diff --git a/completions/a2x b/completions/a2x index cf9f9516..b59c7861 100644 --- a/completions/a2x +++ b/completions/a2x @@ -6,15 +6,15 @@ _a2x() _init_completion -s || return case $prev in - --attribute|--asciidoc-opts|--dblatex-opts|--fop-opts|--help|\ - --version|--xsltproc-opts|-!(-*)[ah]) + --attribute | --asciidoc-opts | --dblatex-opts | --fop-opts | --help | \ + --version | --xsltproc-opts | -!(-*)[ah]) return ;; - --destination-dir|--icons-dir|-!(-*)D) + --destination-dir | --icons-dir | -!(-*)D) _filedir -d return ;; - --doctype|-!(-*)d) + --doctype | -!(-*)d) _xfunc asciidoc _asciidoc_doctype return ;; @@ -27,13 +27,13 @@ _a2x() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _a2x a2x + complete -F _a2x a2x # ex: filetype=sh diff --git a/completions/abook b/completions/abook index 29d326b9..42197d10 100644 --- a/completions/abook +++ b/completions/abook @@ -6,12 +6,12 @@ _abook() _init_completion || return # abook only takes options, tabbing after command name adds a single dash - [[ $cword -eq 1 && -z "$cur" ]] && - { - compopt -o nospace - COMPREPLY=( "-" ) - return - } + [[ $cword -eq 1 && -z $cur ]] && + { + compopt -o nospace + COMPREPLY=("-") + return + } case $cur in -*) @@ -22,28 +22,28 @@ _abook() case $prev in --informat) - COMPREPLY=( $(compgen -W "$($1 --formats | \ + COMPREPLY=($(compgen -W "$($1 --formats | command sed -n -e 's/^'$'\t''\([a-z]*\).*/\1/p' -e '/^$/q')" \ - -- "$cur") ) + -- "$cur")) ;; --outformat) - COMPREPLY=( $(compgen -W "$($1 --formats | \ + COMPREPLY=($(compgen -W "$($1 --formats | command sed -n -e '/^$/,$s/^'$'\t''\([a-z]*\).*/\1/p')" \ - -- "$cur") ) + -- "$cur")) ;; --infile) - COMPREPLY=( $(compgen -W stdin -- "$cur") ) + COMPREPLY=($(compgen -W stdin -- "$cur")) _filedir ;; --outfile) - COMPREPLY=( $(compgen -W stdout -- "$cur") ) + COMPREPLY=($(compgen -W stdout -- "$cur")) _filedir ;; - --config|--datafile) + --config | --datafile) _filedir ;; esac } && -complete -F _abook abook + complete -F _abook abook # ex: filetype=sh diff --git a/completions/aclocal b/completions/aclocal index f0cc6114..010862fb 100644 --- a/completions/aclocal +++ b/completions/aclocal @@ -6,10 +6,10 @@ _aclocal() _init_completion -s || return case "$prev" in - --help|--print-ac-dir|--version) + --help | --print-ac-dir | --version) return ;; - --acdir|-I) + --acdir | -I) _filedir -d return ;; @@ -17,19 +17,19 @@ _aclocal() _filedir return ;; - --warnings|-W) - local cats=( syntax unsupported ) - COMPREPLY=( $(compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) + --warnings | -W) + local cats=(syntax unsupported) + COMPREPLY=($(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur")) return ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _aclocal aclocal aclocal-1.1{0..6} + complete -F _aclocal aclocal aclocal-1.1{0..6} # ex: filetype=sh diff --git a/completions/acpi b/completions/acpi index 745b8f78..f2c38b21 100644 --- a/completions/acpi +++ b/completions/acpi @@ -6,17 +6,17 @@ _acpi() _init_completion || return case $prev in - --help|--version|-!(-*)[hv]) + --help | --version | -!(-*)[hv]) return ;; - --directory|-!(-*)d) + --directory | -!(-*)d) _filedir -d return ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _acpi acpi + complete -F _acpi acpi # ex: filetype=sh diff --git a/completions/add_members b/completions/add_members index 75ae417c..efa4f1e2 100644 --- a/completions/add_members +++ b/completions/add_members @@ -6,26 +6,26 @@ _add_members() _init_completion -s || return case $prev in - -r|-d|--regular-members-file|--digest-members-file) + -r | -d | --regular-members-file | --digest-members-file) _filedir return ;; - -w|-a|--welcome-msg|--admin-notify) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + -w | -a | --welcome-msg | --admin-notify) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--regular-members-file --digest-members-file - --welcome-msg --admin-notify --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--regular-members-file --digest-members-file + --welcome-msg --admin-notify --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _add_members add_members + complete -F _add_members add_members # ex: filetype=sh diff --git a/completions/alias b/completions/alias index af39302a..92211d83 100644 --- a/completions/alias +++ b/completions/alias @@ -7,14 +7,14 @@ _alias() case ${words[@]} in *[^=]) - COMPREPLY=( $(compgen -A alias -- "$cur") ) + COMPREPLY=($(compgen -A alias -- "$cur")) ;; *=) - COMPREPLY=( "$(alias ${cur%=} 2>/dev/null | command sed \ - -e 's|^alias '"$cur"'\(.*\)$|\1|')" ) + COMPREPLY=("$(alias ${cur%=} 2>/dev/null | command sed \ + -e 's|^alias '"$cur"'\(.*\)$|\1|')") ;; esac } && -complete -F _alias -o nospace alias + complete -F _alias -o nospace alias # ex: filetype=sh diff --git a/completions/ant b/completions/ant index ba141965..197c0e96 100644 --- a/completions/ant +++ b/completions/ant @@ -31,14 +31,14 @@ _ant() _init_completion || return case $prev in - -h|-help|--h|--help|-projecthelp|-p|-version|-diagnostics) + -h | -help | --h | --help | -projecthelp | -p | -version | -diagnostics) return ;; - -buildfile|-file|-f) + -buildfile | -file | -f) _filedir 'xml' return ;; - -logfile|-l) + -logfile | -l) [[ $1 != *phing || $prev != -l ]] && _filedir return ;; @@ -47,37 +47,37 @@ _ant() return ;; -nice) - COMPREPLY=( $(compgen -W '{1..10}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..10}' -- "$cur")) return ;; -lib) _filedir -d return ;; - -logger|-listener|-inputhandler|-main|-find|-s) + -logger | -listener | -inputhandler | -main | -find | -s) return ;; esac if [[ $cur == -D* ]]; then return - elif [[ "$cur" == -* ]]; then + elif [[ $cur == -* ]]; then # The </dev/null prevents "phing -" weirdness/getting just a literal # tab displayed on complete on CentOS 6 with phing 2.6.1. COMPREPLY=( - $(compgen -W '$(_parse_help "$1" -h </dev/null)' -- "$cur") ) + $(compgen -W '$(_parse_help "$1" -h </dev/null)' -- "$cur")) else # available targets completion # find which buildfile to use local buildfile=build.xml i - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -@(?(build)file|f) ]]; then - buildfile=${words[i+1]} + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -@(?(build)file|f) ]]; then + buildfile=${words[i + 1]} break fi done - if [[ $i -eq $cword ]]; then - for i in $ANT_ARGS; do + if ((i == cword)); then + for i in ${ANT_ARGS-}; do if [[ $prev == -@(?(build)file|f) ]]; then buildfile=$i break @@ -92,11 +92,11 @@ _ant() # fill targets _ant_parse_targets $buildfile - COMPREPLY=( $(compgen -W '$targets' -- "$cur") ) + COMPREPLY=($(compgen -W '$targets' -- "$cur")) fi } && -complete -F _ant ant phing -type complete-ant-cmd.pl &>/dev/null && \ + complete -F _ant ant phing +type complete-ant-cmd.pl &>/dev/null && complete -C complete-ant-cmd.pl -F _ant ant || : # ex: filetype=sh diff --git a/completions/apache2ctl b/completions/apache2ctl index fe2a2d7b..980b3c58 100644 --- a/completions/apache2ctl +++ b/completions/apache2ctl @@ -6,11 +6,11 @@ _apache2ctl() _init_completion || return local APWORDS - APWORDS=$($1 2>&1 >/dev/null | awk 'NR<2 { print $3; exit }' | \ + APWORDS=$($1 2>&1 >/dev/null | awk 'NR<2 { print $3; exit }' | tr "|" " ") - COMPREPLY=( $(compgen -W "$APWORDS" -- "$cur") ) + COMPREPLY=($(compgen -W "$APWORDS" -- "$cur")) } && -complete -F _apache2ctl apache2ctl + complete -F _apache2ctl apache2ctl # ex: filetype=sh diff --git a/completions/appdata-validate b/completions/appdata-validate index e6c6ddd6..03d8cc9a 100644 --- a/completions/appdata-validate +++ b/completions/appdata-validate @@ -6,13 +6,13 @@ _appdata_validate() _init_completion -s || return case $prev in - -h|--help|--version) + -h | --help | --version) return ;; --output-format) - COMPREPLY=( $(compgen -W "$($1 --help | + COMPREPLY=($(compgen -W "$($1 --help | command sed -ne 's/--output-format.*\[\(.*\)\]/\1/' -e 's/|/ /gp')" \ - -- "$cur") ) + -- "$cur")) return ;; esac @@ -20,13 +20,13 @@ _appdata_validate() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir appdata.xml } && -complete -F _appdata_validate appdata-validate + complete -F _appdata_validate appdata-validate # ex: filetype=sh diff --git a/completions/apt-build b/completions/apt-build index b6cf8eff..713f4c39 100644 --- a/completions/apt-build +++ b/completions/apt-build @@ -6,48 +6,49 @@ _apt_build() _init_completion || return local special i - for (( i=0; i < ${#words[@]}-1; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do if [[ ${words[i]} == @(install|remove|source|info|clean) ]]; then special=${words[i]} + break fi done - if [[ -n $special ]]; then + if [[ -v special ]]; then case $special in - install|source|info) - COMPREPLY=( $(apt-cache pkgnames "$cur" 2>/dev/null) ) + install | source | info) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)) ;; remove) - COMPREPLY=( \ - $(_xfunc dpkg _comp_dpkg_installed_packages "$cur") ) + COMPREPLY=( + $(_xfunc dpkg _comp_dpkg_installed_packages "$cur")) ;; esac return fi case $prev in - --patch|--build-dir|--repository-dir) + --patch | --build-dir | --repository-dir) _filedir return ;; - -h|--help) + -h | --help) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --show-upgraded -u --build-dir + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --show-upgraded -u --build-dir --repository-dir --build-only --build-command --reinstall --rebuild --remove-builddep --no-wrapper --purge --patch --patch-strip -p - --yes -y --version -v --no-source' -- "$cur") ) + --yes -y --version -v --no-source' -- "$cur")) else - COMPREPLY=( $(compgen -W 'update upgrade install remove source + COMPREPLY=($(compgen -W 'update upgrade install remove source dist-upgrade world clean info clean-build update-repository' \ - -- "$cur") ) + -- "$cur")) fi } && -complete -F _apt_build apt-build + complete -F _apt_build apt-build # ex: filetype=sh diff --git a/completions/apt-cache b/completions/apt-cache index 5bd85e90..61aa07be 100644 --- a/completions/apt-cache +++ b/completions/apt-cache @@ -1,18 +1,21 @@ # Debian apt-cache(8) completion -*- shell-script -*- # List APT binary packages -_apt_cache_packages() { - apt-cache --no-generate pkgnames "$cur" 2>/dev/null +_apt_cache_packages() +{ + apt-cache --no-generate pkgnames "$cur" 2>/dev/null || : } # List APT source packages -_apt_cache_sources() { - compgen -W "$(apt-cache dumpavail | \ +_apt_cache_sources() +{ + compgen -W "$(apt-cache dumpavail | awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$1" } # List APT source packages -_apt_cache_src_packages() { +_apt_cache_src_packages() +{ compgen -W '$(_apt_cache_sources "$cur")' -- "$cur" } @@ -21,63 +24,62 @@ _apt_cache() local cur prev words cword _init_completion || return - local special i + local special ispecial if [[ $cur != show ]]; then - for (( i=0; i < ${#words[@]}-1; i++ )); do - if [[ ${words[i]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then - special=${words[i]} + for ((ispecial = 1; ispecial < ${#words[@]} - 1; ispecial++)); do + if [[ ${words[ispecial]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then + special=${words[ispecial]} + break fi done fi - - if [[ -n $special ]]; then + if [[ -v special && $ispecial -lt $cword ]]; then case $special in - add) - _filedir - ;; + add) + _filedir + ;; - showsrc) - COMPREPLY=( $(_apt_cache_sources "$cur") ) - ;; + showsrc) + COMPREPLY=($(_apt_cache_sources "$cur")) + ;; - *) - COMPREPLY=( $(_apt_cache_packages) ) - ;; + *) + COMPREPLY=($(_apt_cache_packages)) + ;; esac return fi - case $prev in - --config-file|--pkg-cache|--src-cache|-!(-*)[cps]) + --config-file | --pkg-cache | --src-cache | -!(-*)[cps]) _filedir return ;; search) - if [[ "$cur" != -* ]]; then + if [[ $cur != -* ]]; then return fi ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-h -v -p -s -q -i -f -a -g -c -o --help + COMPREPLY=($(compgen -W '-h -v -p -s -q -i -f -a -g -c -o --help --version --pkg-cache --src-cache --quiet --important --full --all-versions --no-all-versions --generate --no-generate --names-only --all-names --recurse --config-file --option - --installed' -- "$cur") ) - else + --installed' -- "$cur")) + elif [[ ! -v special ]]; then - COMPREPLY=( $(compgen -W 'add gencaches show showpkg showsrc stats + COMPREPLY=($(compgen -W 'add gencaches show showpkg showsrc stats dump dumpavail unmet search search depends rdepends pkgnames - dotty xvcg policy madison' -- "$cur") ) + dotty xvcg policy madison' -- "$cur")) fi } && -complete -F _apt_cache apt-cache + complete -F _apt_cache apt-cache # ex: filetype=sh diff --git a/completions/apt-get b/completions/apt-get index 9c88fe60..4aee2639 100644 --- a/completions/apt-get +++ b/completions/apt-get @@ -6,28 +6,30 @@ _apt_get() _init_completion -n ':=' || return local special i - for (( i=0; i < ${#words[@]}-1; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do if [[ ${words[i]} == @(install|remove|autoremove|purge|source|build-dep|download|changelog) ]]; then special=${words[i]} + break fi done - if [[ -n $special ]]; then + if [[ -v special ]]; then case $special in - remove|autoremove|purge) + remove | autoremove | purge) if [[ -f /etc/debian_version ]]; then # Debian system - COMPREPLY=( $(\ - _xfunc dpkg _comp_dpkg_installed_packages $cur) ) + COMPREPLY=($( + _xfunc dpkg _comp_dpkg_installed_packages $cur + )) else # assume RPM based _xfunc rpm _rpm_installed_packages fi ;; source) - COMPREPLY=( $(apt-cache --no-generate pkgnames "$cur" \ - 2>/dev/null) $(compgen -W "$(apt-cache dumpavail | - awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$cur") ) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages) + $(compgen -W "$(apt-cache dumpavail | + awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$cur")) ;; install) if [[ $cur == */* ]]; then @@ -36,42 +38,46 @@ _apt_get() elif [[ $cur == *=* ]]; then package="${cur%%=*}" cur="${cur#*=}" - COMPREPLY=($(IFS=$'\n' compgen -W "$( \ - apt-cache --no-generate madison "$package" 2>/dev/null | \ - while IFS=' |' read -r _ version _; do - echo "$version" - done )" \ - -- "$cur")) + COMPREPLY=($(IFS=$'\n' compgen -W "$( + apt-cache --no-generate madison "$package" 2>/dev/null | + while IFS=' |' read -r _ version _; do + echo "$version" + done + )" \ + -- "$cur")) __ltrim_colon_completions "$cur" return fi ;;& + build-dep) + _filedir -d + [[ $cur != */* ]] || return + ;;& *) - COMPREPLY=( $(apt-cache --no-generate pkgnames "$cur" \ - 2>/dev/null) ) + COMPREPLY+=($(_xfunc apt-cache _apt_cache_packages)) ;; esac return fi case $prev in - --help|--version|--option|-!(-*)[hvo]) + --help | --version | --option | -!(-*)[hvo]) return ;; - --config-file|-!(-*)c) + --config-file | -!(-*)c) _filedir return ;; - --target-release|--default-release|-!(-*)t) - COMPREPLY=( $(compgen -W "$(apt-cache policy | command sed -ne \ + --target-release | --default-release | -!(-*)t) + COMPREPLY=($(compgen -W "$(apt-cache policy | command sed -ne \ 's/^ *release.*[ ,]o=\(Debian\|Ubuntu\),a=\(\w*\).*/\2/p')" \ - -- "$cur") ) + -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--no-install-recommends --install-suggests + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--no-install-recommends --install-suggests --download-only --fix-broken --ignore-missing --fix-missing --no-download --quiet --simulate --just-print --dry-run --recon --no-act --yes --assume-yes --assume-no --no-show-upgraded @@ -84,15 +90,15 @@ _apt_get() --diff-only --dsc-only --tar-only --arch-only --indep-only --allow-unauthenticated --no-allow-insecure-repositories --allow-releaseinfo-change --show-progress --with-source --help - --version --config-file --option' -- "$cur") ) + --version --config-file --option' -- "$cur")) else - COMPREPLY=( $(compgen -W 'update upgrade dist-upgrade + COMPREPLY=($(compgen -W 'update upgrade dist-upgrade dselect-upgrade install remove purge source build-dep check download clean autoclean autoremove changelog indextargets' \ - -- "$cur") ) + -- "$cur")) fi } && -complete -F _apt_get apt-get + complete -F _apt_get apt-get # ex: filetype=sh diff --git a/completions/aptitude b/completions/aptitude index 3f4e5500..e5ea1636 100644 --- a/completions/aptitude +++ b/completions/aptitude @@ -1,16 +1,16 @@ # Debian aptitude(1) completion -*- shell-script -*- _have grep-status && { -_comp_dpkg_hold_packages() -{ - grep-status -P -e "^$1" -a -FStatus 'hold' -n -s Package -} + _comp_dpkg_hold_packages() + { + grep-status -P -e "^$1" -a -FStatus 'hold' -n -s Package + } } || { -_comp_dpkg_hold_packages() -{ - command grep -B 2 'hold' /var/lib/dpkg/status | \ - awk "/Package: $1/ { print \$2 }" -} + _comp_dpkg_hold_packages() + { + command grep -B 2 'hold' /var/lib/dpkg/status | + awk "/Package: $1/ { print \$2 }" + } } _aptitude() @@ -18,37 +18,29 @@ _aptitude() local cur prev words cword _init_completion || return - local dashoptions='-S -u -i -h --help --version -s --simulate -d - --download-only -P --prompt -y --assume-yes -F --display-format -O - --sort -w --width -f -r -g --with-recommends -R -G --without-recommends - -t --target-release -V --show-versions -D --show-deps -Z -v --verbose - --purge-unused --schedule-only' - local special i - for (( i=0; i < ${#words[@]}-1; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do if [[ ${words[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full|safe)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag|versions) ]]; then special=${words[i]} + break fi - #exclude some mutually exclusive options - [[ ${words[i]} == '-u' ]] && dashoptions=${dashoptions/-i} - [[ ${words[i]} == '-i' ]] && dashoptions=${dashoptions/-u} done - if [[ -n "$special" ]]; then + if [[ -v special ]]; then case $special in - install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade| \ - safe-upgrade|download|show|changelog|why|why-not|build-dep| \ - add-user-tag|remove-user-tag|versions) - COMPREPLY=( $(_xfunc apt-cache _apt_cache_packages) ) + install | hold | markauto | unmarkauto | dist-upgrade | full-upgrade | \ + safe-upgrade | download | show | changelog | why | why-not | build-dep | \ + add-user-tag | remove-user-tag | versions) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)) return ;; - purge|remove|reinstall|forbid-version) - COMPREPLY=( \ - $(_xfunc dpkg _comp_dpkg_installed_packages "$cur") ) + purge | remove | reinstall | forbid-version) + COMPREPLY=( + $(_xfunc dpkg _comp_dpkg_installed_packages "$cur")) return ;; unhold) - COMPREPLY=( $(_comp_dpkg_hold_packages "$cur") ) + COMPREPLY=($(_comp_dpkg_hold_packages "$cur")) return ;; esac @@ -56,32 +48,72 @@ _aptitude() case $prev in # don't complete anything if these options are found - autoclean|clean|forget-new|search|upgrade|update|keep-all) + autoclean | clean | forget-new | search | upgrade | update | keep-all) return ;; -!(-*)S) _filedir return ;; - --target-release|--default-release|-!(-*)t) - COMPREPLY=( $(apt-cache policy | \ - command grep "release.o=Debian,a=$cur" | \ - command sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2>/dev/null) ) + --display-format | --width | -!(-*)[wFo]) + return + ;; + --sort | -!(-*)O) + COMPREPLY=($(compgen -W 'installsize installsizechange debsize + name priority version' -- "$cur")) + return + ;; + --target-release | --default-release | -!(-*)t) + COMPREPLY=($(apt-cache policy | + command grep "release.o=Debian,a=$cur" | + command sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2>/dev/null)) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$dashoptions" -- "$cur") ) + if [[ $cur == -* ]]; then + local opts=" $($1 --help 2>&1 | command sed -e \ + 's/--with(out)-recommends/--without-recommends\n--with-recommends/' | + _parse_help - | tr '\n' ' ') " + + # Exclude some mutually exclusive options + for i in "${words[@]}"; do + [[ $i == -u ]] && opts=${opts/ -i / } + [[ $i == -i ]] && opts=${opts/ -u / } + done + + # Do known short -> long replacements; at least up to 0.8.12, --help + # outputs mostly only short ones. + COMPREPLY=($opts) + for i in "${!COMPREPLY[@]}"; do + case ${COMPREPLY[i]} in + -h) COMPREPLY[i]=--help ;; + -s) COMPREPLY[i]=--simulate ;; + -d) COMPREPLY[i]=--download-only ;; + -P) COMPREPLY[i]=--prompt ;; + -y) COMPREPLY[i]=--assume-yes ;; + -F) COMPREPLY[i]=--display-format ;; + -O) COMPREPLY[i]=--sort ;; + -W) COMPREPLY[i]=--show-why ;; + -w) COMPREPLY[i]=--width ;; + -V) COMPREPLY[i]=--show-versions ;; + -D) COMPREPLY[i]=--show-deps ;; + -v) COMPREPLY[i]=--verbose ;; + -t) COMPREPLY[i]=--target-release ;; + -q) COMPREPLY[i]=--quiet ;; + esac + done + + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) else - COMPREPLY=( $(compgen -W 'update upgrade safe-upgrade forget-new + 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 keep-all build-dep add-user-tag - remove-user-tag versions' -- "$cur") ) + remove-user-tag versions' -- "$cur")) fi } && -complete -F _aptitude -o default aptitude aptitude-curses + complete -F _aptitude -o default aptitude aptitude-curses # ex: filetype=sh diff --git a/completions/arch b/completions/arch index e275577b..afeed05d 100644 --- a/completions/arch +++ b/completions/arch @@ -3,44 +3,44 @@ # Try to detect whether this is the mailman "arch" to avoid installing # it for the coreutils/util-linux-ng one. _have mailmanctl && -_arch() -{ - local cur prev words cword split - _init_completion -s || return + _arch() + { + local cur prev words cword split + _init_completion -s || return - case $prev in - -w|-g|-d|--welcome-msg|--goodbye-msg|--digest) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) - return - ;; - -d|--file) - _filedir - return - ;; - esac - - $split && return - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - else - local args=$cword - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -* ]]; then - (( args-- )) - fi - done - case $args in - 1) - _xfunc list_lists _mailman_lists + case $prev in + -w | -g | -d | --welcome-msg | --goodbye-msg | --digest) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) + return ;; - 2) + --file) _filedir + return ;; esac - fi -} && -complete -F _arch arch + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + else + local args=$cword + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -* ]]; then + ((args--)) + fi + done + case $args in + 1) + _xfunc list_lists _mailman_lists + ;; + 2) + _filedir + ;; + esac + fi + + } && + complete -F _arch arch # ex: filetype=sh diff --git a/completions/arp b/completions/arp index e83f05d3..922e800a 100644 --- a/completions/arp +++ b/completions/arp @@ -6,28 +6,28 @@ _arp() _init_completion || return case $prev in - --device|-!(-*)i) + --device | -!(-*)i) _available_interfaces -a return ;; - --protocol|-!(-*)[Ap]) + --protocol | -!(-*)[Ap]) # TODO protocol/address family return ;; - --file|-!(-*)f) + --file | -!(-*)f) _filedir return ;; - --hw-type|-!(-*)[Ht]) + --hw-type | -!(-*)[Ht]) # TODO: parse from --help output? - COMPREPLY=( $(compgen -W 'ash ether ax25 netrom rose arcnet \ - dlci fddi hippi irda x25 eui64' -- "$cur") ) + COMPREPLY=($(compgen -W 'ash ether ax25 netrom rose arcnet \ + dlci fddi hippi irda x25 eui64' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi @@ -37,7 +37,7 @@ _arp() 1) local ips=$("$1" -an | command sed -ne \ 's/.*(\([0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}\)).*/\1/p') - COMPREPLY=( $(compgen -W '$ips' -- "$cur") ) + COMPREPLY=($(compgen -W '$ips' -- "$cur")) ;; 2) # TODO if -d mode: "pub"; if not -f mode: hw_addr @@ -54,6 +54,6 @@ _arp() ;; esac } && -complete -F _arp arp + complete -F _arp arp # ex: filetype=sh diff --git a/completions/arping b/completions/arping index 6adcde7c..57e1e19b 100644 --- a/completions/arping +++ b/completions/arping @@ -6,7 +6,7 @@ _arping() _init_completion || return case $prev in - -*c|-*w) + -*c | -*w) return ;; -*I) @@ -20,12 +20,12 @@ _arping() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) return fi _known_hosts_real -- "$cur" } && -complete -F _arping arping + complete -F _arping arping # ex: filetype=sh diff --git a/completions/arpspoof b/completions/arpspoof index 6275a667..d1a13735 100644 --- a/completions/arpspoof +++ b/completions/arpspoof @@ -16,13 +16,13 @@ _arpspoof() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) else _known_hosts_real -- "$cur" fi } && -complete -F _arpspoof arpspoof + complete -F _arpspoof arpspoof # ex: filetype=sh diff --git a/completions/asciidoc b/completions/asciidoc index 2ddcdfe9..1ea4abf2 100644 --- a/completions/asciidoc +++ b/completions/asciidoc @@ -2,7 +2,7 @@ _asciidoc_doctype() { - COMPREPLY+=( $(compgen -W 'article book manpage' -- "$cur") ) + COMPREPLY+=($(compgen -W 'article book manpage' -- "$cur")) } _asciidoc() @@ -11,26 +11,26 @@ _asciidoc() _init_completion -s || return case $prev in - --attribute|-!(-*)a) + --attribute | -!(-*)a) return ;; - --backend|-!(-*)b) - COMPREPLY=( $(compgen -W 'docbook html4 xhtml11' -- "$cur") ) + --backend | -!(-*)b) + COMPREPLY=($(compgen -W 'docbook html4 xhtml11' -- "$cur")) return ;; - --conf-file|-!(-*)f) + --conf-file | -!(-*)f) _filedir conf return ;; - --doctype|-!(-*)d) + --doctype | -!(-*)d) _asciidoc_doctype return ;; - --help|-!(-*)h) - COMPREPLY=( $(compgen -W 'manpage syntax topics' -- "$cur") ) + --help | -!(-*)h) + COMPREPLY=($(compgen -W 'manpage syntax topics' -- "$cur")) return ;; - --out-file|-!(-*)o) + --out-file | -!(-*)o) _filedir return ;; @@ -39,14 +39,14 @@ _asciidoc() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" "--help manpage")' \ - -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" "--help manpage")' \ + -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _asciidoc asciidoc asciidoc.py + complete -F _asciidoc asciidoc asciidoc.py # ex: filetype=sh diff --git a/completions/aspell b/completions/aspell index 040853cb..e080a07d 100644 --- a/completions/aspell +++ b/completions/aspell @@ -5,12 +5,12 @@ _aspell_dictionary() local datadir aspell=${1:-aspell} datadir=$($aspell config data-dir 2>/dev/null || echo /usr/lib/aspell) # First, get aliases (dicts dump does not list them) - COMPREPLY=( $(printf '%s\n' $datadir/*.alias) ) - COMPREPLY=( "${COMPREPLY[@]%.alias}" ) - COMPREPLY=( "${COMPREPLY[@]#$datadir/}" ) + COMPREPLY=($(printf '%s\n' $datadir/*.alias)) + COMPREPLY=("${COMPREPLY[@]%.alias}") + COMPREPLY=("${COMPREPLY[@]#$datadir/}") # Then, add the canonical dicts - COMPREPLY+=( $($aspell dicts 2>/dev/null) ) - COMPREPLY=( $(compgen -X '\*' -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY+=($($aspell dicts 2>/dev/null)) + COMPREPLY=($(compgen -X '\*' -W '${COMPREPLY[@]}' -- "$cur")) } _aspell() @@ -19,47 +19,47 @@ _aspell() _init_completion -s || return case $prev in - -c|-p|check|--conf|--personal|--repl|--per-conf) + -c | -p | check | --conf | --personal | --repl | --per-conf) _filedir return ;; - --conf-dir|--data-dir|--dict-dir|--home-dir|--local-data-dir|--prefix) + --conf-dir | --data-dir | --dict-dir | --home-dir | --local-data-dir | --prefix) _filedir -d return ;; - dump|create|merge) - COMPREPLY=( $(compgen -W 'master personal repl' -- "$cur") ) + dump | create | merge) + COMPREPLY=($(compgen -W 'master personal repl' -- "$cur")) return ;; --mode) - COMPREPLY=( $(compgen -W "$($1 modes 2>/dev/null | \ - awk '{ print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 modes 2>/dev/null | + awk '{ print $1 }')" -- "$cur")) return ;; --sug-mode) - COMPREPLY=( $(compgen -W 'ultra fast normal bad-speller' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'ultra fast normal bad-speller' \ + -- "$cur")) return ;; --keymapping) - COMPREPLY=( $(compgen -W 'aspell ispell' -- "$cur") ) + COMPREPLY=($(compgen -W 'aspell ispell' -- "$cur")) return ;; - -d|--master) + -d | --master) _aspell_dictionary "$1" return ;; - --add-filter|--rem-filter) - COMPREPLY=( $(compgen -W "$($1 filters 2>/dev/null | \ - awk '{ print $1 }')" -- "$cur") ) + --add-filter | --rem-filter) + COMPREPLY=($(compgen -W "$($1 filters 2>/dev/null | + awk '{ print $1 }')" -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= --encoding= --add-filter= --rem-filter= --mode= --add-extra-dicts= --rem-extra-dicts= --home-dir= --ignore= --ignore-accents --dont-ignore-accents --ignore-case --dont-ignore-case @@ -76,13 +76,13 @@ _aspell() --add-tex-command= --rem-tex-command= --tex-check-comments --dont-tex-check-comments --add-tex-extension --rem-tex-extension --add-sgml-check= --rem-sgml-check= --add-sgml-extension - --rem-sgml-extension' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + --rem-sgml-extension' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - COMPREPLY=( $(compgen -W 'usage help check pipe list config soundslike - filter version dump create merge' -- "$cur") ) + COMPREPLY=($(compgen -W 'usage help check pipe list config soundslike + filter version dump create merge' -- "$cur")) fi } && -complete -F _aspell aspell + complete -F _aspell aspell # ex: filetype=sh diff --git a/completions/autoconf b/completions/autoconf index 94a014ff..b51e797e 100644 --- a/completions/autoconf +++ b/completions/autoconf @@ -6,20 +6,20 @@ _autoconf() _init_completion -s || return case "$prev" in - --help|-h|--version|-V|--trace|-t) + --help | -h | --version | -V | --trace | -t) return ;; - --output|-o) + --output | -o) _filedir return ;; - --warnings|-W) - local cats=( cross obsolete syntax ) - COMPREPLY=( $(compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) + --warnings | -W) + local cats=(cross obsolete syntax) + COMPREPLY=($(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur")) return ;; - --prepend-include|-B|--include|-I) + --prepend-include | -B | --include | -I) _filedir -d return ;; @@ -27,14 +27,14 @@ _autoconf() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir '@(ac|in)' } && -complete -F _autoconf autoconf + complete -F _autoconf autoconf # ex: filetype=sh diff --git a/completions/automake b/completions/automake index ff3d4523..5fe5f4f8 100644 --- a/completions/automake +++ b/completions/automake @@ -6,13 +6,13 @@ _automake() _init_completion -s || return case "$prev" in - --help|--version) + --help | --version) return ;; - --warnings|-W) - local cats=( gnu obsolete override portability syntax unsupported ) - COMPREPLY=( $(compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) + --warnings | -W) + local cats=(gnu obsolete override portability syntax unsupported) + COMPREPLY=($(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur")) return ;; --libdir) @@ -23,14 +23,14 @@ _automake() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _automake automake automake-1.1{0..6} + complete -F _automake automake automake-1.1{0..6} # ex: filetype=sh diff --git a/completions/autoreconf b/completions/autoreconf index cf983312..9b0f0dc9 100644 --- a/completions/autoreconf +++ b/completions/autoreconf @@ -6,17 +6,17 @@ _autoreconf() _init_completion -s || return case "$prev" in - --help|-h|--version|-V) + --help | -h | --version | -V) return ;; - --warnings|-W) - local cats=( cross gnu obsolete override portability syntax \ - unsupported ) - COMPREPLY=( $(compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) + --warnings | -W) + local cats=(cross gnu obsolete override portability syntax + unsupported) + COMPREPLY=($(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur")) return ;; - --prepend-include|-B|--include|-I) + --prepend-include | -B | --include | -I) _filedir -d return ;; @@ -24,9 +24,9 @@ _autoreconf() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -36,6 +36,6 @@ _autoreconf() _filedir -d fi } && -complete -F _autoreconf autoreconf autoheader + complete -F _autoreconf autoreconf autoheader # ex: filetype=sh diff --git a/completions/autorpm b/completions/autorpm index 7a0bbe18..d55322ab 100644 --- a/completions/autorpm +++ b/completions/autorpm @@ -5,10 +5,10 @@ _autorpm() local cur prev words cword _init_completion || return - COMPREPLY=( $(compgen -W '--notty --debug --help --version auto add - fullinfo info help install list remove set' -- "$cur") ) + COMPREPLY=($(compgen -W '--notty --debug --help --version auto add + fullinfo info help install list remove set' -- "$cur")) } && -complete -F _autorpm autorpm + complete -F _autorpm autorpm # ex: filetype=sh diff --git a/completions/autoscan b/completions/autoscan index 5f70a508..e0071437 100644 --- a/completions/autoscan +++ b/completions/autoscan @@ -6,10 +6,10 @@ _autoscan() _init_completion -s || return case "$prev" in - --help|--version|-!(-*)[hV]) + --help | --version | -!(-*)[hV]) return ;; - --prepend-include|--include|-!(-*)[BI]) + --prepend-include | --include | -!(-*)[BI]) _filedir -d return ;; @@ -17,9 +17,9 @@ _autoscan() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -29,6 +29,6 @@ _autoscan() _filedir -d fi } && -complete -F _autoscan autoscan autoupdate + complete -F _autoscan autoscan autoupdate # ex: filetype=sh diff --git a/completions/avctrl b/completions/avctrl index 2ef499f3..89c24e47 100644 --- a/completions/avctrl +++ b/completions/avctrl @@ -5,16 +5,16 @@ _avctrl() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --quiet' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --quiet' -- "$cur")) else local args _count_args - if [[ $args -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'discover switch' -- "$cur") ) + if ((args == 1)); then + COMPREPLY=($(compgen -W 'discover switch' -- "$cur")) fi fi } && -complete -F _avctrl avctrl + complete -F _avctrl avctrl # ex: filetype=sh diff --git a/completions/badblocks b/completions/badblocks index 221f42b9..29c4e00d 100644 --- a/completions/badblocks +++ b/completions/badblocks @@ -15,15 +15,15 @@ _badblocks() ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # Filter out -w (dangerous) and -X (internal use) - COMPREPLY=( $(compgen -X -[wX] -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -X -[wX] -W '$(_parse_usage "$1")' -- "$cur")) return fi cur=${cur:=/dev/} _filedir } && -complete -F _badblocks badblocks + complete -F _badblocks badblocks # ex: filetype=sh diff --git a/completions/bind b/completions/bind index c06654b1..2ee428b2 100644 --- a/completions/bind +++ b/completions/bind @@ -10,8 +10,8 @@ _bind() return ;; -*m) - COMPREPLY=( $(compgen -W "emacs emacs-standard emacs-meta - emacs-ctlx vi vi-move vi-command vi-insert" -- "$cur") ) + COMPREPLY=($(compgen -W "emacs emacs-standard emacs-meta + emacs-ctlx vi vi-move vi-command vi-insert" -- "$cur")) return ;; -*f) @@ -19,18 +19,18 @@ _bind() return ;; -*[qu]) - COMPREPLY=( $(compgen -W '$("$1" -l)' -- "$cur") ) + COMPREPLY=($(compgen -W '$("$1" -l)' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -A binding -- "$cur") ) + COMPREPLY=($(compgen -A binding -- "$cur")) } && -complete -F _bind bind + complete -F _bind bind # ex: filetype=sh diff --git a/completions/bk b/completions/bk index 73b5bb1c..4e4d140a 100644 --- a/completions/bk +++ b/completions/bk @@ -6,13 +6,13 @@ _bk() local cur prev words cword _init_completion || return - local BKCMDS="$(bk help topics 2>/dev/null | \ + local BKCMDS="$(bk help topics 2>/dev/null | awk '/^ bk/ { print $2 }' | xargs printf '%s ')" - COMPREPLY=( $(compgen -W "$BKCMDS" -- "$cur") ) + COMPREPLY=($(compgen -W "$BKCMDS" -- "$cur")) _filedir } && -complete -F _bk bk + complete -F _bk bk # ex: filetype=sh diff --git a/completions/brctl b/completions/brctl index 755812d3..14569b64 100644 --- a/completions/brctl +++ b/completions/brctl @@ -9,31 +9,32 @@ _brctl() case $cword in 1) - COMPREPLY=( $(compgen -W "addbr delbr addif delif setageing + COMPREPLY=($(compgen -W "addbr delbr addif delif setageing setbridgeprio setfd sethello setmaxage setpathcost setportprio - show showmacs showstp stp" -- "$cur") ) + show showmacs showstp stp" -- "$cur")) ;; 2) case $command in - show) - ;; + show) ;; + *) - COMPREPLY=( $(compgen -W "$($1 show | \ - awk 'NR>1 {print $1}' )" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 show | + awk 'NR>1 {print $1}')" -- "$cur")) + ;; esac ;; 3) case $command in - addif|delif) + addif | delif) _configured_interfaces ;; stp) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) ;; esac ;; esac } && -complete -F _brctl -o default brctl + complete -F _brctl -o default brctl # ex: filetype=sh diff --git a/completions/btdownloadheadless.py b/completions/btdownloadheadless.py index c15de1a4..a470e535 100644 --- a/completions/btdownloadheadless.py +++ b/completions/btdownloadheadless.py @@ -6,14 +6,14 @@ _btdownload() _init_completion || return case $prev in - --responsefile|--saveas) + --responsefile | --saveas) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--max_uploads --keepalive_interval + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--max_uploads --keepalive_interval --download_slice_size --request_backlog --max_message_length --ip --minport --maxport --responsefile --url --saveas --timeout --timeout_check_interval --max_slice_length --max_rate_period @@ -21,12 +21,12 @@ _btdownload() --min_peers --http_timeout --max_initiate --max_allow_in --check_hashes --max_upload_rate --snub_time --spew --rarest_first_cutoff --min_uploads --report_hash_failures' \ - -- "$cur") ) + -- "$cur")) else _filedir fi } && -complete -F _btdownload btdownloadheadless.py btdownloadcurses.py \ - btdownloadgui.py + complete -F _btdownload btdownloadheadless.py btdownloadcurses.py \ + btdownloadgui.py # ex: filetype=sh diff --git a/completions/bts b/completions/bts index c87b51e1..d535d13e 100644 --- a/completions/bts +++ b/completions/bts @@ -1,92 +1,89 @@ # bts completion -*- shell-script -*- # List bug numbers from bugs cache in ~/.devscripts_cache/bts -_cached_bugs() { - [[ -d $HOME/.devscripts_cache/bts ]] && \ +_cached_bugs() +{ + [[ -d $HOME/.devscripts_cache/bts ]] && find $HOME/.devscripts_cache/bts -maxdepth 1 -name "${cur}[0-9]*.html" \ -printf "%f\n" | cut -d'.' -f1 } # List APT source packages prefixed with "src:" -_src_packages_with_prefix() { +_src_packages_with_prefix() +{ ppn=${cur:4} # partial package name, after stripping "src:" compgen -P "src:" -W '$(_xfunc apt-cache _apt_cache_sources "$ppn")' \ -- "$ppn" } - _bts() { local cur prev words cword split _init_completion -s || return case $prev in - show|bugs) - COMPREPLY=( $(compgen -W 'release-critical RC from: tag: + show | bugs) + COMPREPLY=($(compgen -W 'release-critical RC from: tag: usertag:' -- "$cur") $(_cached_bugs) - $(_src_packages_with_prefix) ) + $(_src_packages_with_prefix)) return ;; select) - COMPREPLY=( $(compgen -W 'package: source: maintainer: submitter: + COMPREPLY=($(compgen -W 'package: source: maintainer: submitter: severity: status: tag: owner: correspondent: affects: bugs: - users: archive:' -- "$cur") ) + users: archive:' -- "$cur")) return ;; status) - COMPREPLY=( $(compgen -W 'file: fields: verbose' -- "$cur") - $(_cached_bugs) ) + COMPREPLY=($(compgen -W 'file: fields: verbose' -- "$cur") + $(_cached_bugs)) return ;; - block|unblock) - COMPREPLY=( $(compgen -W 'by with' -- "$cur") ) + block | unblock) + COMPREPLY=($(compgen -W 'by with' -- "$cur")) return ;; severity) - COMPREPLY=( $(compgen -W 'wishlist minor normal important serious - grave critical' -- "$cur") ) + COMPREPLY=($(compgen -W 'wishlist minor normal important serious + grave critical' -- "$cur")) return ;; limit) - COMPREPLY=( $(compgen -W 'submitter date subject msgid package - source tag severity owner affects archive' -- "$cur") ) + COMPREPLY=($(compgen -W 'submitter date subject msgid package + source tag severity owner affects archive' -- "$cur")) return ;; - clone|"done"|reopen|archive|unarchive|retitle|summary|submitter|found\ - |notfound|fixed|notfixed|merge|forcemerge|unmerge|claim|unclaim\ - |forwarded|notforwarded|owner|noowner|subscribe|unsubscribe\ - |reportspam|spamreport|affects|usertag|usertags|reassign|tag\ - |tags) - COMPREPLY=( $(_cached_bugs) ) + clone | "done" | reopen | archive | unarchive | retitle | summary | submitter | found | notfound | fixed | notfixed | merge | forcemerge | unmerge | claim | unclaim | forwarded | notforwarded | owner | noowner | subscribe | unsubscribe | reportspam | spamreport | affects | usertag | usertags | reassign | tag | tags) + COMPREPLY=($(_cached_bugs)) return ;; package) - COMPREPLY=( $(_xfunc apt-cache _apt_cache_packages) ) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)) return ;; cache) - COMPREPLY=( $(_xfunc apt-cache _apt_cache_packages) - $(_src_packages_with_prefix) - $(compgen -W 'from: release-critical RC' -- "$cur") ) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages) + $(_src_packages_with_prefix) + $(compgen -W 'from: release-critical RC' -- "$cur")) return ;; cleancache) - COMPREPLY=( $(_xfunc apt-cache _apt_cache_packages) - $(_src_packages_with_prefix) - $(compgen -W 'from: tag: usertag: ALL' -- "$cur") ) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages) + $(_src_packages_with_prefix) + $(compgen -W 'from: tag: usertag: ALL' -- "$cur")) return ;; user) # non-predicible arguments - COMPREPLY=( ) + COMPREPLY=() return ;; :) # Chances are that "src:<src_package>" is being completed # COMP_WORDS would be: "bts cleancache src : <partial_pkg_name>" pos=$((COMP_CWORD - 2)) - if [[ $pos -gt 0 && "${COMP_WORDS[$pos]}" == "src" ]]; then - COMPREPLY=( $(_xfunc apt-cache _apt_cache_src_packages) ) + if [[ $pos -gt 0 && ${COMP_WORDS[pos]} == "src" ]]; then + COMPREPLY=($(_xfunc apt-cache _apt_cache_src_packages)) return fi ;; @@ -94,7 +91,7 @@ _bts() $split && return - COMPREPLY=( $(compgen -W '--offline --online --no-offline + COMPREPLY=($(compgen -W '--offline --online --no-offline --no-action --cache --no-cache --cache-mode --cache-delay --mbox --mailreader --cc-addr --use-default-cc --no-use-default-cc --sendmail --mutt --no-mutt --smtp-host --smtp-username @@ -107,9 +104,9 @@ _bts() merge forcemerge unmerge tag tags affects user usertag usertags claim unclaim severity forwarded notforwarded package limit owner noowner subscribe unsubscribe reportspam spamreport cache cleancache version - help' -- "$cur") ) + help' -- "$cur")) } && -complete -F _bts bts + complete -F _bts bts # ex: filetype=sh diff --git a/completions/bzip2 b/completions/bzip2 index 8bd72cc9..40e50fe3 100644 --- a/completions/bzip2 +++ b/completions/bzip2 @@ -6,37 +6,37 @@ _bzip2() _init_completion || return case $prev in - --help|-!(-*)[bhp]) + --help | -!(-*)[bhp]) return ;; -!(-*)n) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local helpopts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ + -- "$cur")) return fi local IFS=$'\n' xspec="*.?(t)bz2" - if [[ "$prev" == --* ]]; then - [[ "$prev" == --@(decompress|list|test) ]] && xspec="!"$xspec - [[ "$prev" == --compress ]] && xspec= - elif [[ "$prev" == -* ]]; then - [[ "$prev" == -*[dt]* ]] && xspec="!"$xspec - [[ "$prev" == -*z* ]] && xspec= + if [[ $prev == --* ]]; then + [[ $prev == --@(decompress|list|test) ]] && xspec="!"$xspec + [[ $prev == --compress ]] && xspec= + elif [[ $prev == -* ]]; then + [[ $prev == -*[dt]* ]] && xspec="!"$xspec + [[ $prev == -*z* ]] && xspec= fi _tilde "$cur" || return compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _bzip2 bzip2 pbzip2 lbzip2 + complete -F _bzip2 bzip2 pbzip2 lbzip2 # ex: filetype=sh diff --git a/completions/cancel b/completions/cancel index b903517b..3e0c1d52 100644 --- a/completions/cancel +++ b/completions/cancel @@ -14,14 +14,14 @@ _cancel() return ;; -u) - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W \ - "$(lpstat 2>/dev/null | cut -d' ' -f1)" -- "$cur") ) + COMPREPLY=($(compgen -W \ + "$(lpstat 2>/dev/null | cut -d' ' -f1)" -- "$cur")) } && -complete -F _cancel cancel + complete -F _cancel cancel # ex: filetype=sh diff --git a/completions/cardctl b/completions/cardctl index 588ea467..bb3a0dba 100644 --- a/completions/cardctl +++ b/completions/cardctl @@ -5,11 +5,11 @@ _cardctl() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'status config ident suspend resume reset - eject insert scheme' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'status config ident suspend resume reset + eject insert scheme' -- "$cur")) fi } && -complete -F _cardctl cardctl pccardctl + complete -F _cardctl cardctl pccardctl # ex: filetype=sh diff --git a/completions/carton b/completions/carton index 0cf6e2ca..5d700c89 100644 --- a/completions/carton +++ b/completions/carton @@ -2,15 +2,15 @@ _carton_commands() { - local cmds=$("${1:-carton}" usage 2>&1 | \ - command sed -ne '/.*command.* is one of/{n;p;q}') - COMPREPLY+=( $(IFS="$IFS," compgen -W "$cmds" -- "$cur") ) + local cmds=$("${1:-carton}" usage 2>&1 | + command sed -ne '/.*command.* is one of/{n;p;q;}') + COMPREPLY+=($(IFS="$IFS," compgen -W "$cmds" -- "$cur")) } _carton_command_help() { local help=$(PERLDOC_PAGER=cat PERLDOC=-otext "${1:-carton}" -h $2 2>&1) - COMPREPLY+=( $(compgen -W '$help' -- "$cur") ) + COMPREPLY+=($(compgen -W '$help' -- "$cur")) } _carton() @@ -19,24 +19,27 @@ _carton() _init_completion -s || return local i command - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in -*) ;; - *) command=${words[i]}; break ;; + *) + command=${words[i]} + break + ;; esac done - if [[ -z "$command" ]]; then + if [[ ! -v command ]]; then _carton_commands "$1" return fi case $prev in - --version|-v) + --version | -v) return ;; - --help|-h) - [[ -n "$command" ]] || _carton_commands "$1" + --help | -h) + [[ -n $command ]] || _carton_commands "$1" return ;; --cpanfile) @@ -54,7 +57,7 @@ _carton() --without) if [[ $command == install ]]; then local phases="configure build test runtime develop" - COMPREPLY+=( $(compgen -W '$phases' -- "$cur") ) + COMPREPLY+=($(compgen -W '$phases' -- "$cur")) return fi ;; @@ -68,11 +71,11 @@ _carton() fi case $command in - show|update) - : # TODO modules completion + show | update) + : # TODO modules completion ;; esac } && -complete -F _carton carton + complete -F _carton carton # ex: filetype=sh diff --git a/completions/ccache b/completions/ccache index 7dbec9fe..80c39de0 100644 --- a/completions/ccache +++ b/completions/ccache @@ -6,7 +6,7 @@ _ccache() _init_completion -s || return local i - for (( i=1; i <= COMP_CWORD; i++ )); do + for ((i = 1; i <= COMP_CWORD; i++)); do if [[ ${COMP_WORDS[i]} != -* ]]; then _command_offset $i return @@ -15,14 +15,14 @@ _ccache() done case $prev in - --help|--version|--max-files|--max-size|-!(-*)[hVFM]) + --help | --version | --max-files | --max-size | -!(-*)[hVFM]) return ;; - --set-config|-!(-*)o) + --set-config | -!(-*)o) if [[ $cur != *=* ]]; then - COMPREPLY=( $(compgen -S = -W "$($1 -p 2>/dev/null | \ - awk '$3 = "=" { print $2 }')" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -S = -W "$($1 -p 2>/dev/null | + awk '$3 = "=" { print $2 }')" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi return ;; @@ -30,9 +30,9 @@ _ccache() $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _ccache ccache + complete -F _ccache ccache # ex: filetype=sh diff --git a/completions/ccze b/completions/ccze index 7c17f364..35f4c3f3 100644 --- a/completions/ccze +++ b/completions/ccze @@ -6,38 +6,39 @@ _ccze() _init_completion -s || return case $prev in - -'?'|--help|--usage|-V|--version) + -'?' | --help | --usage | -V | --version) return ;; - --argument|--color|-!(-*)[ac]) + --argument | --color | -!(-*)[ac]) # TODO? return ;; - --rcfile|-!(-*)F) + --rcfile | -!(-*)F) _filedir return ;; - --mode|-!(-*)m) - COMPREPLY=( $(compgen -W "curses ansi html" -- "$cur") ) + --mode | -!(-*)m) + COMPREPLY=($(compgen -W "curses ansi html" -- "$cur")) return ;; - --option|-!(-*)o) + --option | -!(-*)o) local -a opts=(scroll wordcolor lookups transparent cssfile) - COMPREPLY=( $(compgen -W '${opts[@]} ${opts[@]/#/no}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]/#/no}' -- "$cur")) return ;; - --plugin|-!(-*)p) - COMPREPLY=( $(compgen -W '$("$1" --list-plugins | command \ + --plugin | -!(-*)p) + COMPREPLY=($(compgen -W '$("$1" --list-plugins | command \ sed -ne "s/^\([a-z0-9]\{1,\}\)[[:space:]]\{1,\}|.*/\1/p")' \ - -- "$cur") ) + -- "$cur")) return + ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _ccze ccze + complete -F _ccze ccze # ex: filetype=sh diff --git a/completions/cfagent b/completions/cfagent index 14987723..e7ba04de 100644 --- a/completions/cfagent +++ b/completions/cfagent @@ -6,16 +6,16 @@ _cfagent() _init_completion || return case $prev in - -f|--file) + -f | --file) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _cfagent cfagent + complete -F _cfagent cfagent # ex: filetype=sh diff --git a/completions/cfrun b/completions/cfrun index 0a7d0542..72b61389 100644 --- a/completions/cfrun +++ b/completions/cfrun @@ -6,9 +6,9 @@ _cfrun() _init_completion || return local i section=1 - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -- ]]; then - (( section++ )) + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -- ]]; then + ((section++)) fi done @@ -21,27 +21,27 @@ _cfrun() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-f -h -d -S -T -v' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-f -h -d -S -T -v' -- "$cur")) else - hostfile=${CFINPUTS:-/var/lib/cfengine/inputs}/cfrun.hosts - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -f ]]; then - hostfile=${words[i+1]} + local hostfile=${CFINPUTS:-/var/lib/cfengine/inputs}/cfrun.hosts + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -f ]]; then + hostfile=${words[i + 1]} break fi done [[ ! -f $hostfile ]] && return - COMPREPLY=( $(compgen -W "$(command grep -v \ - -E '(=|^$|^#)' $hostfile )" -- "$cur") ) + COMPREPLY=($(compgen -W "$(command grep -v \ + -E '(=|^$|^#)' $hostfile)" -- "$cur")) fi ;; 2) - COMPREPLY=( $(compgen -W '$(_parse_help cfagent)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help cfagent)' -- "$cur")) ;; esac } && -complete -F _cfrun cfrun + complete -F _cfrun cfrun # ex: filetype=sh diff --git a/completions/chage b/completions/chage index cb9d8fcf..fcf87cd4 100644 --- a/completions/chage +++ b/completions/chage @@ -6,11 +6,11 @@ _chage() _init_completion -s || return case $prev in - --lastday|--expiredate|--help|--inactive|--mindays|--maxdays|\ - --warndays|-!(-*)[dEhImMW]) + --lastday | --expiredate | --help | --inactive | --mindays | --maxdays | \ + --warndays | -!(-*)[dEhImMW]) return ;; - --root|-!(-*)R) + --root | -!(-*)R) _filedir -d return ;; @@ -18,13 +18,13 @@ _chage() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) } && -complete -F _chage chage + complete -F _chage chage # ex: filetype=sh diff --git a/completions/change_pw b/completions/change_pw index 61c45768..04837ea9 100644 --- a/completions/change_pw +++ b/completions/change_pw @@ -6,7 +6,7 @@ _change_pw() _init_completion -s || return case $prev in - -l|--listname) + -l | --listname) _xfunc list_lists _mailman_lists return ;; @@ -14,12 +14,12 @@ _change_pw() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--all --domain --listname --password --quiet - --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--all --domain --listname --password --quiet + --help' -- "$cur")) fi } && -complete -F _change_pw change_pw + complete -F _change_pw change_pw # ex: filetype=sh diff --git a/completions/check_db b/completions/check_db index ade03a5a..aaec99fd 100644 --- a/completions/check_db +++ b/completions/check_db @@ -5,13 +5,13 @@ _check_db() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--all --verbose --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--all --verbose --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _check_db check_db + complete -F _check_db check_db # ex: filetype=sh diff --git a/completions/check_perms b/completions/check_perms index d53b22a6..8ff276ef 100644 --- a/completions/check_perms +++ b/completions/check_perms @@ -5,11 +5,11 @@ _check_perms() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-f -v -h' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-f -v -h' -- "$cur")) fi } && -complete -F _check_perms check_perms + complete -F _check_perms check_perms # ex: filetype=sh diff --git a/completions/checksec b/completions/checksec index e07d07d0..fc2fef79 100644 --- a/completions/checksec +++ b/completions/checksec @@ -6,10 +6,10 @@ _checksec() _init_completion || return case $prev in - --version|--help) + --version | --help) return ;; - --file|--fortify-file) + --file | --fortify-file) _filedir return ;; @@ -21,17 +21,17 @@ _checksec() _pnames return ;; - --proc-libs|--fortify-proc) + --proc-libs | --fortify-proc) _pids return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi } && -complete -F _checksec checksec + complete -F _checksec checksec # ex: filetype=sh diff --git a/completions/chgrp b/completions/chgrp index 0e39739c..4793a457 100644 --- a/completions/chgrp +++ b/completions/chgrp @@ -7,7 +7,7 @@ _chgrp() cur=${cur//\\\\/} - if [[ "$prev" == --reference ]]; then + if [[ $prev == --reference ]]; then _filedir return fi @@ -15,25 +15,25 @@ _chgrp() $split && return # options completion - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local w opts - for w in "${words[@]}" ; do - [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break + for w in "${words[@]}"; do + [[ $w == -@(R|-recursive) ]] && opts="-H -L -P" && break done - COMPREPLY=( $(compgen -W '-c -h -f -R -v --changes --dereference + COMPREPLY=($(compgen -W '-c -h -f -R -v --changes --dereference --no-dereference --silent --quiet --reference --recursive --verbose - --help --version $opts' -- "$cur") ) + --help --version $opts' -- "$cur")) return fi # first parameter on line or first since an option? - if [[ $cword -eq 1 && "$cur" != -* || "$prev" == -* ]]; then + if [[ $cword -eq 1 && $cur != -* || $prev == -* ]]; then _allowed_groups "$cur" else _filedir fi } && -complete -F _chgrp chgrp + complete -F _chgrp chgrp # ex: filetype=sh diff --git a/completions/chkconfig b/completions/chkconfig index f1ee8704..8ff66376 100644 --- a/completions/chkconfig +++ b/completions/chkconfig @@ -6,32 +6,32 @@ _chkconfig() _init_completion -s || return case $prev in - --level=[1-6]|[1-6]|--list|--add|--del|--override) + --level=[1-6] | [1-6] | --list | --add | --del | --override) _services _xinetd_services return ;; --level) - COMPREPLY=( $(compgen -W '{1..6}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..6}' -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--list --add --del --override --level' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--list --add --del --override --level' \ + -- "$cur")) else - if [[ $cword -eq 2 || $cword -eq 4 ]]; then - COMPREPLY=( $(compgen -W 'on off reset resetpriorities' \ - -- "$cur") ) + if ((cword == 2 || cword == 4)); then + COMPREPLY=($(compgen -W 'on off reset resetpriorities' \ + -- "$cur")) else _services _xinetd_services fi fi } && -complete -F _chkconfig chkconfig + complete -F _chkconfig chkconfig # ex: filetype=sh diff --git a/completions/chmod b/completions/chmod index 849da851..d3fc3499 100644 --- a/completions/chmod +++ b/completions/chmod @@ -6,7 +6,7 @@ _chmod() _init_completion -s || return case $prev in - --help|--version) + --help | --version) return ;; --reference) @@ -20,10 +20,11 @@ _chmod() # Adapted from coreutils 8.28 chmod man page local modearg="-@(@(+([rwxXst])|[ugo])|+([0-7]))" + # shellcheck disable=SC2053 if [[ $cur == -* && $cur != $modearg ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -31,10 +32,10 @@ _chmod() _count_args "" "" "$modearg" case $args in - 1) ;; # mode + 1) ;; # mode *) _filedir ;; esac } && -complete -F _chmod chmod + complete -F _chmod chmod # ex: filetype=sh diff --git a/completions/chown b/completions/chown index 6bfa264a..1d746b7a 100644 --- a/completions/chown +++ b/completions/chown @@ -19,28 +19,28 @@ _chown() $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # Complete -options local w opts - for w in "${words[@]}" ; do - [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break + for w in "${words[@]}"; do + [[ $w == -@(R|-recursive) ]] && opts="-H -L -P" && break done - COMPREPLY=( $(compgen -W '-c -h -f -R -v --changes --dereference + COMPREPLY=($(compgen -W '-c -h -f -R -v --changes --dereference --no-dereference --from --silent --quiet --reference --recursive - --verbose --help --version $opts' -- "$cur") ) + --verbose --help --version $opts' -- "$cur")) else local args # The first argument is an usergroup; the rest are filedir. _count_args : - if [[ $args -eq 1 ]]; then + if ((args == 1)); then _usergroup -u else _filedir fi fi } && -complete -F _chown chown + complete -F _chown chown # ex: filetype=sh diff --git a/completions/chpasswd b/completions/chpasswd index 8c5a4dfd..3abea998 100644 --- a/completions/chpasswd +++ b/completions/chpasswd @@ -6,15 +6,15 @@ _chpasswd() _init_completion -s || return case $prev in - --crypt|-!(-*)c) - COMPREPLY=( $(compgen -W 'DES MD5 NONE SHA256 SHA512' \ - -- "$cur") ) + --crypt | -!(-*)c) + COMPREPLY=($(compgen -W 'DES MD5 NONE SHA256 SHA512' \ + -- "$cur")) return ;; - --sha-rounds|-!(-*)s) + --sha-rounds | -!(-*)s) return ;; - --root|-!(-*)R) + --root | -!(-*)R) _filedir -d return ;; @@ -22,9 +22,9 @@ _chpasswd() $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _chpasswd chpasswd + complete -F _chpasswd chpasswd # ex: filetype=sh diff --git a/completions/chromium-browser b/completions/chromium-browser index a26b04f2..9ee98962 100644 --- a/completions/chromium-browser +++ b/completions/chromium-browser @@ -6,7 +6,7 @@ _chromium_browser() _init_completion -s -n : || return case $prev in - --help|--app|--proxy-pac-url|-h) + --help | --app | --proxy-pac-url | -h) return ;; --user-data-dir) @@ -18,18 +18,18 @@ _chromium_browser() *://*) local prefix="${cur%%://*}://" _known_hosts_real -- "${cur#*://}" - COMPREPLY=( "${COMPREPLY[@]/#/$prefix}" ) + COMPREPLY=("${COMPREPLY[@]/#/$prefix}") __ltrim_colon_completions "$cur" ;; *) compopt -o nospace - COMPREPLY=( $(compgen -S :// -W 'http socks socks4 socks5' -- "$cur") ) + COMPREPLY=($(compgen -S :// -W 'http socks socks4 socks5' -- "$cur")) ;; esac return ;; --password-store) - COMPREPLY=( $(compgen -W 'basic gnome kwallet' -- "$cur") ) + COMPREPLY=($(compgen -W 'basic gnome kwallet' -- "$cur")) return ;; esac @@ -37,14 +37,14 @@ _chromium_browser() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - _filedir "@(?([mxs])htm?(l)|pdf)" + _filedir "@(?([mxs])htm?(l)|pdf|txt)" } && -complete -F _chromium_browser chromium-browser google-chrome \ - google-chrome-stable chromium chrome + complete -F _chromium_browser chromium-browser google-chrome \ + google-chrome-stable chromium chrome # ex: filetype=sh diff --git a/completions/chronyc b/completions/chronyc index a59746aa..e6bb8e9d 100644 --- a/completions/chronyc +++ b/completions/chronyc @@ -2,12 +2,13 @@ _chronyc_command_args() { - local -a args=( $(compgen -W "$($1 help 2>/dev/null | \ - awk '/^'$prev'\s[^ []/ { gsub("\\|", " ", $2); print $2 }')") ) + local -a args + args=($(compgen -W "$($1 help 2>/dev/null | + awk '/^'$prev'\s[^ []/ { gsub("\\|", " ", $2); print $2 }')")) case $args in \<address\>) _known_hosts_real -- "$cur" ;; \<*) ;; - *) COMPREPLY+=( $(compgen -W '${args[@]}' -- "$cur") ) ;; + *) COMPREPLY+=($(compgen -W '${args[@]}' -- "$cur")) ;; esac } @@ -17,7 +18,7 @@ _chronyc() _init_completion || return case $prev in - --help|-*p) + --help | -*p) return ;; -*h) @@ -27,26 +28,27 @@ _chronyc() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1") -6' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1") -6' -- "$cur")) return fi - local i args=0 - for (( i=1; i < cword; i++ )); do - [[ ${words[i]} != -* && ${words[i-1]} != @(-p|-h) ]] && (( args++ )) + local i args + args=0 + for ((i = 1; i < cword; i++)); do + [[ ${words[i]} != -* && ${words[i - 1]} != @(-p|-h) ]] && ((args++)) done case $args in 0) - COMPREPLY=( $(compgen -W "$($1 help 2>/dev/null | \ + COMPREPLY=($(compgen -W "$($1 help 2>/dev/null | awk '!/(^ |: *$)/ { sub("\\|", " ", $1); print $1 }')" \ - -- "$cur") ) + -- "$cur")) ;; 1) _chronyc_command_args "$1" - if [[ ! $COMPREPLY && $prev == sources?(tats) ]]; then + if [[ ! ${COMPREPLY-} && $prev == sources?(tats) ]]; then # [-v] not handled by _chronyc_command_args yet - COMPREPLY=( $(compgen -W '-v' -- "$cur") ) + COMPREPLY=($(compgen -W '-v' -- "$cur")) fi ;; 2) @@ -54,6 +56,6 @@ _chronyc() ;; esac } && -complete -F _chronyc chronyc + complete -F _chronyc chronyc # ex: filetype=sh diff --git a/completions/chrpath b/completions/chrpath index bcd0f91d..2883967b 100644 --- a/completions/chrpath +++ b/completions/chrpath @@ -6,22 +6,22 @@ _chrpath() _init_completion || return case $prev in - --version|--help|-!(-*)[vh]) + --version | --help | -!(-*)[vh]) return ;; - --replace|-!(-*)r) + --replace | -!(-*)r) _filedir -d return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir } && -complete -F _chrpath chrpath + complete -F _chrpath chrpath # ex: filetype=sh diff --git a/completions/cksfv b/completions/cksfv index 89ccc7b7..da404dda 100644 --- a/completions/cksfv +++ b/completions/cksfv @@ -5,13 +5,13 @@ _cksfv() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi case "$prev" in - -*C|-*g) + -*C | -*g) _filedir -d return ;; @@ -24,6 +24,6 @@ _cksfv() _filedir } && -complete -F _cksfv cksfv + complete -F _cksfv cksfv # ex: filetype=sh diff --git a/completions/cleanarch b/completions/cleanarch index 5e57e5be..0f7d5f57 100644 --- a/completions/cleanarch +++ b/completions/cleanarch @@ -5,12 +5,12 @@ _cleanarch() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--status --dry-run --quiet --help' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--status --dry-run --quiet --help' \ + -- "$cur")) fi } && -complete -F _cleanarch cleanarch + complete -F _cleanarch cleanarch # ex: filetype=sh diff --git a/completions/clisp b/completions/clisp index f9ccfbb8..c4259a00 100644 --- a/completions/clisp +++ b/completions/clisp @@ -8,15 +8,15 @@ _clisp() _init_completion || return # completing an option (may or may not be separated by a space) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-h --help --version --license -B -K -M -m -L + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-h --help --version --license -B -K -M -m -L -N -E -q --quiet --silent -w -I -ansi -traditional -p -C -norc -i - -c -l -o -x ' -- "$cur") ) + -c -l -o -x ' -- "$cur")) else _filedir fi } && -complete -F _clisp -o default clisp + complete -F _clisp -o default clisp # ex: filetype=sh diff --git a/completions/clone_member b/completions/clone_member index 5a0797fe..a3ca2b31 100644 --- a/completions/clone_member +++ b/completions/clone_member @@ -6,7 +6,7 @@ _clone_member() _init_completion -s || return case $prev in - -l|--listname) + -l | --listname) _xfunc list_lists _mailman_lists return ;; @@ -14,12 +14,12 @@ _clone_member() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--listname --remove --admin --quiet - --nomodify --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--listname --remove --admin --quiet + --nomodify --help' -- "$cur")) fi } && -complete -F _clone_member clone_member + complete -F _clone_member clone_member # ex: filetype=sh diff --git a/completions/complete b/completions/complete index 0519744d..a57f366f 100644 --- a/completions/complete +++ b/completions/complete @@ -7,43 +7,43 @@ _complete() case $prev in -*o) - COMPREPLY=( $(compgen -W 'bashdefault default dirnames filenames - nospace plusdirs' -- "$cur") ) + COMPREPLY=($(compgen -W 'bashdefault default dirnames filenames + nospace plusdirs' -- "$cur")) return ;; -*A) - COMPREPLY=( $(compgen -W 'alias arrayvar binding builtin command + COMPREPLY=($(compgen -W 'alias arrayvar binding builtin command directory disabled enabled export file function group helptopic hostname job keyword running service setopt shopt signal - stopped user variable' -- "$cur") ) + stopped user variable' -- "$cur")) return ;; -*C) - COMPREPLY=( $(compgen -A command -- "$cur") ) + COMPREPLY=($(compgen -A command -- "$cur")) return ;; -*F) - COMPREPLY=( $(compgen -A function -- "$cur") ) + COMPREPLY=($(compgen -A function -- "$cur")) return ;; - -*p|-*r) - COMPREPLY=( $(complete -p | command sed -e 's|.* ||') ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + -*p | -*r) + COMPREPLY=($(complete -p | command sed -e 's|.* ||')) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # relevant options completion local opts="-a -b -c -d -e -f -g -j -k -o -s -u -v -A -G -W -P -S -X" [[ $1 != compgen ]] && opts+=" -F -C" - COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) + COMPREPLY=($(compgen -W "$opts" -- "$cur")) else - COMPREPLY=( $(compgen -A command -- "$cur") ) + COMPREPLY=($(compgen -A command -- "$cur")) fi } && -complete -F _complete compgen complete + complete -F _complete compgen complete # ex: filetype=sh diff --git a/completions/config_list b/completions/config_list index f86263d7..1807e338 100644 --- a/completions/config_list +++ b/completions/config_list @@ -6,7 +6,7 @@ _config_list() _init_completion -s || return case $prev in - -i|-o|--inputfile|--outputfile) + -i | -o | --inputfile | --outputfile) _filedir return ;; @@ -14,14 +14,14 @@ _config_list() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--inputfile --outputfile --checkonly - --verbose --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--inputfile --outputfile --checkonly + --verbose --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _config_list config_list + complete -F _config_list config_list # ex: filetype=sh diff --git a/completions/configure b/completions/configure index 726c7bda..3f59a012 100644 --- a/completions/configure +++ b/completions/configure @@ -6,15 +6,15 @@ _configure() _init_completion -s || return case $prev in - -h|--help|-V|--version|--program-prefix|--program-suffix|\ - --program-transform-name) + -h | --help | -V | --version | --program-prefix | --program-suffix | \ + --program-transform-name) return ;; --*file) _filedir return ;; - --*prefix|--*dir) + --*prefix | --*dir) _filedir -d return ;; @@ -24,19 +24,19 @@ _configure() # if $COMP_CONFIGURE_HINTS is not null, then completions of the form # --option=SETTING will include 'SETTING' as a contextual hint - [[ "$cur" != -* ]] && return + [[ $cur != -* ]] && return - if [[ -n $COMP_CONFIGURE_HINTS ]]; then - COMPREPLY=( $(compgen -W "$($1 --help 2>&1 | \ + if [[ ${COMP_CONFIGURE_HINTS-} ]]; then + COMPREPLY=($(compgen -W "$($1 --help 2>&1 | awk '/^ --[A-Za-z]/ { print $1; \ if ($2 ~ /--[A-Za-z]/) print $2 }' | command sed -e 's/[[,].*//g')" \ - -- "$cur") ) - [[ $COMPREPLY == *=* ]] && compopt -o nospace + -- "$cur")) + [[ ${COMPREPLY-} == *=* ]] && compopt -o nospace else - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _configure configure + complete -F _configure configure # ex: filetype=sh diff --git a/completions/convert b/completions/convert index 3ebfc5e9..ef7baea9 100644 --- a/completions/convert +++ b/completions/convert @@ -4,122 +4,122 @@ _ImageMagick() { case $prev in -channel) - COMPREPLY=( $(compgen -W 'Red Green Blue Opacity Matte Cyan - Magenta Yellow Black' -- "$cur") ) + COMPREPLY=($(compgen -W 'Red Green Blue Opacity Matte Cyan + Magenta Yellow Black' -- "$cur")) return ;; -colormap) - COMPREPLY=( $(compgen -W 'shared private' -- "$cur") ) + COMPREPLY=($(compgen -W 'shared private' -- "$cur")) return ;; -colorspace) - COMPREPLY=( $(compgen -W 'GRAY OHTA RGB Transparent XYZ YCbCr YIQ - YPbPr YUV CMYK' -- "$cur") ) + COMPREPLY=($(compgen -W 'GRAY OHTA RGB Transparent XYZ YCbCr YIQ + YPbPr YUV CMYK' -- "$cur")) return ;; -compose) - COMPREPLY=( $(compgen -W 'Over In Out Atop Xor Plus Minus Add + COMPREPLY=($(compgen -W 'Over In Out Atop Xor Plus Minus Add Subtract Difference Multiply Bumpmap Copy CopyRed CopyGreen - CopyBlue CopyOpacity' -- "$cur") ) + CopyBlue CopyOpacity' -- "$cur")) return ;; -compress) - COMPREPLY=( $(compgen -W 'None BZip Fax Group4 JPEG Lossless LZW - RLE Zip' -- "$cur") ) + COMPREPLY=($(compgen -W 'None BZip Fax Group4 JPEG Lossless LZW + RLE Zip' -- "$cur")) return ;; -dispose) - COMPREPLY=( $(compgen -W 'Undefined None Background Previous' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'Undefined None Background Previous' \ + -- "$cur")) return ;; -encoding) - COMPREPLY=( $(compgen -W 'AdobeCustom AdobeExpert AdobeStandard + COMPREPLY=($(compgen -W 'AdobeCustom AdobeExpert AdobeStandard AppleRoman BIG5 GB2312 Latin2 None SJIScode Symbol Unicode - Wansung' -- "$cur") ) + Wansung' -- "$cur")) return ;; -endian) - COMPREPLY=( $(compgen -W 'MSB LSB' -- "$cur") ) + COMPREPLY=($(compgen -W 'MSB LSB' -- "$cur")) return ;; -filter) - COMPREPLY=( $(compgen -W 'Point Box Triangle Hermite Hanning + COMPREPLY=($(compgen -W 'Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell - Lanczos Bessel Sinc' -- "$cur") ) + Lanczos Bessel Sinc' -- "$cur")) return ;; -format) - COMPREPLY=( $(compgen -W "$(convert -list format | awk \ + COMPREPLY=($(compgen -W "$(convert -list format | awk \ '/ [r-][w-][+-] / { sub("[*]$","",$1); print tolower($1) }')" \ - -- "$cur") ) + -- "$cur")) return ;; -gravity) - COMPREPLY=( $(compgen -W 'Northwest North NorthEast West Center - East SouthWest South SouthEast' -- "$cur") ) + COMPREPLY=($(compgen -W 'Northwest North NorthEast West Center + East SouthWest South SouthEast' -- "$cur")) return ;; -intent) - COMPREPLY=( $(compgen -W 'Absolute Perceptual Relative - Saturation' -- "$cur") ) + COMPREPLY=($(compgen -W 'Absolute Perceptual Relative + Saturation' -- "$cur")) return ;; -interlace) - COMPREPLY=( $(compgen -W 'None Line Plane Partition' -- "$cur") ) + COMPREPLY=($(compgen -W 'None Line Plane Partition' -- "$cur")) return ;; -limit) - COMPREPLY=( $(compgen -W 'Disk File Map Memory' -- "$cur") ) + COMPREPLY=($(compgen -W 'Disk File Map Memory' -- "$cur")) return ;; -list) - COMPREPLY=( $(compgen -W 'Delegate Format Magic Module Resource - Type' -- "$cur") ) + COMPREPLY=($(compgen -W 'Delegate Format Magic Module Resource + Type' -- "$cur")) return ;; -map) - COMPREPLY=( $(compgen -W 'best default gray red green blue' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'best default gray red green blue' \ + -- "$cur")) _filedir return ;; -noise) - COMPREPLY=( $(compgen -W 'Uniform Gaussian Multiplicative - Impulse Laplacian Poisson' -- "$cur") ) + COMPREPLY=($(compgen -W 'Uniform Gaussian Multiplicative + Impulse Laplacian Poisson' -- "$cur")) return ;; -preview) - COMPREPLY=( $(compgen -W 'Rotate Shear Roll Hue Saturation + COMPREPLY=($(compgen -W 'Rotate Shear Roll Hue Saturation Brightness Gamma Spiff Dull Grayscale Quantize Despeckle ReduceNoise AddNoise Sharpen Blur Treshold EdgeDetect Spread Shade Raise Segment Solarize Swirl Implode Wave OilPaint - CharcoalDrawing JPEG' -- "$cur") ) + CharcoalDrawing JPEG' -- "$cur")) return ;; - -mask|-profile|-texture|-tile|-write) + -mask | -profile | -texture | -tile | -write) _filedir return ;; -type) - COMPREPLY=( $(compgen -W 'Bilevel Grayscale Palette PaletteMatte + COMPREPLY=($(compgen -W 'Bilevel Grayscale Palette PaletteMatte TrueColor TrueColorMatte ColorSeparation ColorSeparationlMatte - Optimize' -- "$cur") ) + Optimize' -- "$cur")) return ;; -units) - COMPREPLY=( $(compgen -W 'Undefined PixelsPerInch - PixelsPerCentimeter' -- "$cur") ) + COMPREPLY=($(compgen -W 'Undefined PixelsPerInch + PixelsPerCentimeter' -- "$cur")) return ;; -virtual-pixel) - COMPREPLY=( $(compgen -W 'Constant Edge mirror tile' -- "$cur") ) + COMPREPLY=($(compgen -W 'Constant Edge mirror tile' -- "$cur")) return ;; -visual) - COMPREPLY=( $(compgen -W 'StaticGray GrayScale StaticColor + COMPREPLY=($(compgen -W 'StaticGray GrayScale StaticColor PseudoColor TrueColor DirectColor defaut visualid' \ - -- "$cur") ) + -- "$cur")) return ;; esac @@ -134,17 +134,17 @@ _convert() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+adjoin +append +compress +contrast +debug + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+adjoin +append +compress +contrast +debug +dither +endian +gamma +label +map +mask +matte +negate +noise - +page +raise +render +write' -- "$cur") ) + +page +raise +render +write' -- "$cur")) else _filedir fi } && -complete -F _convert convert + complete -F _convert convert _mogrify() { @@ -153,16 +153,16 @@ _mogrify() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+compress +contrast +debug +dither +endian - +gamma +label +map +mask +matte +negate +page +raise' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+compress +contrast +debug +dither +endian + +gamma +label +map +mask +matte +negate +page +raise' -- "$cur")) else _filedir fi } && -complete -F _mogrify mogrify + complete -F _mogrify mogrify _display() { @@ -171,16 +171,16 @@ _display() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+compress +contrast +debug +dither +endian - +gamma +label +map +matte +negate +page +raise +write' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+compress +contrast +debug +dither +endian + +gamma +label +map +matte +negate +page +raise +write' -- "$cur")) else _filedir fi } && -complete -F _display display + complete -F _display display _animate() { @@ -189,16 +189,16 @@ _animate() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug +dither +gamma +map +matte' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug +dither +gamma +map +matte' \ + -- "$cur")) else _filedir fi } && -complete -F _animate animate + complete -F _animate animate _identify() { @@ -207,15 +207,15 @@ _identify() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug' -- "$cur")) else _filedir fi } && -complete -F _identify identify + complete -F _identify identify _montage() { @@ -224,16 +224,16 @@ _montage() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+adjoin +compress +debug +dither +endian - +gamma +label +matte +page' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+adjoin +compress +debug +dither +endian + +gamma +label +matte +page' -- "$cur")) else _filedir fi } && -complete -F _montage montage + complete -F _montage montage _composite() { @@ -242,16 +242,16 @@ _composite() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+compress +debug +dither +endian +label - +matte +negate +page +write' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+compress +debug +dither +endian +label + +matte +negate +page +write' -- "$cur")) else _filedir fi } && -complete -F _composite composite + complete -F _composite composite _compare() { @@ -260,15 +260,15 @@ _compare() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug' -- "$cur")) else _filedir fi } && -complete -F _compare compare + complete -F _compare compare _conjure() { @@ -277,15 +277,15 @@ _conjure() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug' -- "$cur")) else _filedir fi } && -complete -F _conjure conjure + complete -F _conjure conjure _import() { @@ -294,15 +294,15 @@ _import() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug' -- "$cur")) else _filedir fi } && -complete -F _import import + complete -F _import import _stream() { @@ -311,14 +311,14 @@ _stream() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug' -- "$cur")) else _filedir fi } && -complete -F _stream stream + complete -F _stream stream # ex: filetype=sh diff --git a/completions/cowsay b/completions/cowsay index c6cbf813..6ba1d0fb 100644 --- a/completions/cowsay +++ b/completions/cowsay @@ -7,17 +7,17 @@ _cowsay() case $prev in -f) - COMPREPLY=( $(compgen -W \ - '$(cowsay -l 2>/dev/null | tail -n +2)' -- "$cur") ) + COMPREPLY=($(compgen -W \ + '$(cowsay -l 2>/dev/null | tail -n +2)' -- "$cur")) return ;; esac # relevant options completion - COMPREPLY=( $(compgen -W '-b -d -g -p -s -t -w -y -e -f -h -l -n -T -W' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '-b -d -g -p -s -t -w -y -e -f -h -l -n -T -W' \ + -- "$cur")) } && -complete -F _cowsay -o default cowsay cowthink + complete -F _cowsay -o default cowsay cowthink # ex: filetype=sh diff --git a/completions/cpan2dist b/completions/cpan2dist index b24e068c..b5e59dae 100644 --- a/completions/cpan2dist +++ b/completions/cpan2dist @@ -8,30 +8,30 @@ _cpan2dist() case $prev in --format) # should remove ":" from COMP_WORDBREAKS, but doesn't work (?) - COMPREPLY=( $(compgen -W '$(perl -MCPANPLUS::Dist -e \ + COMPREPLY=($(compgen -W '$(perl -MCPANPLUS::Dist -e \ "print map { \"\$_\n\" } CPANPLUS::Dist->dist_types")' \ - -- "$cur") ) + -- "$cur")) return ;; - --banlist|--ignorelist|--modulelist|--logfile) + --banlist | --ignorelist | --modulelist | --logfile) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - local cpandirs=( "$HOME/.cpanplus/" "$HOME/.cpan/source/modules/" ) + local cpandirs=("$HOME/.cpanplus/" "$HOME/.cpan/source/modules/") local packagelist for dir in "${cpandirs[@]}"; do - [[ -d "$dir" && -r "$dir/02packages.details.txt.gz" ]] && \ + [[ -d $dir && -r "$dir/02packages.details.txt.gz" ]] && packagelist="$dir/02packages.details.txt.gz" done - [[ $packagelist ]] && COMPREPLY=( $(zgrep "^${cur//-/::}" \ - $packagelist 2>/dev/null | awk '{print $1}' | command sed -e 's/::/-/g') ) + [[ -v packagelist ]] && COMPREPLY=($(zgrep "^${cur//-/::}" \ + $packagelist 2>/dev/null | awk '{print $1}' | command sed -e 's/::/-/g')) fi } && -complete -F _cpan2dist -o default cpan2dist + complete -F _cpan2dist -o default cpan2dist # ex: filetype=sh diff --git a/completions/cpio b/completions/cpio index bbb1ecf9..d6fde0c3 100644 --- a/completions/cpio +++ b/completions/cpio @@ -7,46 +7,46 @@ _cpio() # --name value style option case $prev in - --format|-!(-*)H) - COMPREPLY=( $(compgen -W \ - 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur") ) + --format | -!(-*)H) + COMPREPLY=($(compgen -W \ + 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur")) return ;; - --file|--pattern-file|-!(-*)[EFI]) + --file | --pattern-file | -!(-*)[EFI]) _filedir return ;; - --owner|-!(-*)R) + --owner | -!(-*)R) _usergroup return ;; --rsh-command) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; esac $split && return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W '-o --create -i --extract -p --pass-through - -? --help --license --usage --version' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W '-o --create -i --extract -p --pass-through + -? --help --license --usage --version' -- "$cur")) else case ${words[1]} in - -o|--create) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-0 -a -c -v -A -B -L -V -C -H -M + -o | --create) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-0 -a -c -v -A -B -L -V -C -H -M -O -F --file --format --message --null --reset-access-time --verbose --dot --append --block-size --dereference --io-size --quiet --force-local --rsh-command --help --version' \ - -- "$cur") ) + -- "$cur")) fi ;; - -i|--extract) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-b -c -d -f -m -n -r -t -s -u -v + -i | --extract) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-b -c -d -f -m -n -r -t -s -u -v -B -S -V -C -E -H -M -R -I -F --file --make-directories --nonmatching --preserve-modification-time --numeric-uid-gid --rename --list --swap-bytes --swap @@ -55,17 +55,17 @@ _cpio() --owner --no-preserve-owner --message --force-local --no-absolute-filenames --sparse --only-verify-crc --quiet --rsh-command --help --to-stdout --version' \ - -- "$cur") ) + -- "$cur")) fi ;; - -p*|--pass-through) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-0 -a -d -l -m -u -v -L -V -R + -p* | --pass-through) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-0 -a -d -l -m -u -v -L -V -R --null --reset-access-time --make-directories --link --quiet --preserve-modification-time --unconditional --verbose --dot --dereference --owner --no-preserve-owner --sparse --help --version' \ - -- "$cur") ) + -- "$cur")) else _filedir -d fi @@ -73,6 +73,6 @@ _cpio() esac fi } && -complete -F _cpio cpio + complete -F _cpio cpio # ex: filetype=sh diff --git a/completions/cppcheck b/completions/cppcheck index ebc3ba3b..8ea95715 100644 --- a/completions/cppcheck +++ b/completions/cppcheck @@ -6,36 +6,36 @@ _cppcheck() _init_completion -s || return case $prev in - --append|--exitcode-suppressions|--rule-file|--config-excludes-file|\ - --suppressions-list|--includes-file|--include|-i) + --append | --exitcode-suppressions | --rule-file | --config-excludes-file | \ + --suppressions-list | --includes-file | --include | -i) _filedir return ;; - -D|-U|--rule|--suppress|--template|--max-configs|-h|--help|--version|\ - --errorlist|--config-exclude|-l) + -D | -U | --rule | --suppress | --template | --max-configs | -h | --help | --version | \ + --errorlist | --config-exclude | -l) return ;; --enable) # split comma-separated list split=false - if [[ "$cur" == ?*,* ]]; then + if [[ $cur == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" split=true fi - COMPREPLY=( $(compgen -W 'all warning style performance + COMPREPLY=($(compgen -W 'all warning style performance portability information unusedFunction missingInclude' \ - -- "$cur") ) - $split && COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} ) + -- "$cur")) + $split && COMPREPLY=(${COMPREPLY[@]/#/"$prev,"}) return ;; --error-exitcode) - COMPREPLY=( $(compgen -W '{0..255}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..255}' -- "$cur")) return ;; --file-list) _filedir - [[ -z $cur || $cur == - ]] && COMPREPLY+=( - ) + [[ -z $cur || $cur == - ]] && COMPREPLY+=(-) return ;; -I) @@ -43,25 +43,25 @@ _cppcheck() return ;; -j) - COMPREPLY=( $(compgen -W "{2..$(_ncpus)}" -- "$cur") ) + COMPREPLY=($(compgen -W "{2..$(_ncpus)}" -- "$cur")) return ;; - --language|-x) - COMPREPLY=( $(compgen -W 'c c++' -- "$cur") ) + --language | -x) + COMPREPLY=($(compgen -W 'c c++' -- "$cur")) return ;; --std) - COMPREPLY=( $(compgen -W 'c89 c99 c11 c++03 c++11 c++14 c++17 - c++20' -- "$cur") ) + COMPREPLY=($(compgen -W 'c89 c99 c11 c++03 c++11 c++14 c++17 + c++20' -- "$cur")) return ;; --platform) _filedir - COMPREPLY+=( $(compgen -W 'unix32 unix64 win32A win32W win64 - native' -- "$cur") ) + COMPREPLY+=($(compgen -W 'unix32 unix64 win32A win32W win64 + native' -- "$cur")) return ;; - -rp|--relative-paths) + -rp | --relative-paths) if $split; then # -rp without argument is allowed _filedir -d return @@ -72,7 +72,7 @@ _cppcheck() return ;; --xml-version) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; esac @@ -80,12 +80,12 @@ _cppcheck() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir '@([cht]pp|[cht]xx|cc|[ch]++|[ch])' fi } && -complete -F _cppcheck cppcheck + complete -F _cppcheck cppcheck # ex: filetype=sh diff --git a/completions/crontab b/completions/crontab index a5e5cc58..cac78533 100644 --- a/completions/crontab +++ b/completions/crontab @@ -12,13 +12,13 @@ _crontab() ;; esac - local -A opts=( [-u]= [-l]= [-r]= [-e]= ) + local -A opts=([-u]="" [-l]="" [-r]="" [-e]="") [[ $OSTYPE == *linux* ]] && opts[-i]= [[ -d /sys/fs/selinux || -d /selinux ]] && opts[-s]= local i - for (( i=0; i < ${#words[@]}-1; i++ )); do - [[ ${words[i]} ]] && unset "opts[${words[i]}]" + for i in "${!words[@]}"; do + [[ ${words[i]} && $i -ne $cword ]] && unset "opts[${words[i]}]" case "${words[i]}" in -l) unset 'opts[-r]' 'opts[-e]' 'opts[-i]' 'opts[-s]' @@ -35,14 +35,14 @@ _crontab() esac done - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '${!opts[@]}' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '${!opts[@]}' -- "$cur")) return fi # do filenames only if we did not have -l, -r, or -e - [[ "${words[*]}" == *\ -[lre]* ]] || _filedir + [[ ${words[*]} == *\ -[lre]* ]] || _filedir } && -complete -F _crontab crontab + complete -F _crontab crontab # ex: filetype=sh diff --git a/completions/cryptsetup b/completions/cryptsetup index f8be116f..e73e165e 100644 --- a/completions/cryptsetup +++ b/completions/cryptsetup @@ -2,7 +2,7 @@ _cryptsetup_name() { - COMPREPLY=( $(compgen -X control -W '$(command ls /dev/mapper)' -- "$cur") ) + COMPREPLY=($(compgen -X control -W '$(command ls /dev/mapper)' -- "$cur")) } _cryptsetup_device() @@ -17,16 +17,16 @@ _cryptsetup() _init_completion -s || return case $prev in - --help|--version|--cipher|--hash|--*-size|--key-slot|--size|--offset|\ - --skip|--iter-time|--timeout|--tries|-!(-*)[chslSbopitT]) + --help | --version | --cipher | --hash | --*-size | --key-slot | --size | --offset | \ + --skip | --iter-time | --timeout | --tries | -!(-*)[chslSbopitT]) return ;; - --key-file|--master-key-file|--header-backup-file|-!(-*)d) + --key-file | --master-key-file | --header-backup-file | -!(-*)d) _filedir return ;; - --type|-!(-*)M) - COMPREPLY=( $(compgen -W "luks plain loopaes tcrypt" -- "$cur") ) + --type | -!(-*)M) + COMPREPLY=($(compgen -W "luks plain loopaes tcrypt" -- "$cur")) return ;; esac @@ -36,19 +36,20 @@ _cryptsetup() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - COMPREPLY=( $(compgen -W 'open close resize status benchmark + COMPREPLY=($(compgen -W 'open close resize status benchmark repair erase luksFormat luksAddKey luksRemoveKey luksChangeKey luksKillSlot luksUUID isLuks luksDump tcryptDump luksSuspend - luksResume luksHeaderBackup luksHeaderRestore' -- "$cur") ) + luksResume luksHeaderBackup luksHeaderRestore' -- "$cur")) fi else - local args; _count_args "" "-!(-*)[chslSbopitTdM]" + local args + _count_args "" "-!(-*)[chslSbopitTdM]" case $arg in - open|create|luksOpen|loopaesOpen|tcryptOpen) + open | create | luksOpen | loopaesOpen | tcryptOpen) case $args in 2) _cryptsetup_device @@ -58,15 +59,15 @@ _cryptsetup() ;; esac ;; - close|remove|luksClose|loopaesClose|tcryptClose|status|resize|\ - luksSuspend|luksResume) + close | remove | luksClose | loopaesClose | tcryptClose | status | resize | \ + luksSuspend | luksResume) case $args in 2) _cryptsetup_name ;; esac ;; - luksFormat|luksAddKey|luksRemoveKey) + luksFormat | luksAddKey | luksRemoveKey | luksChangeKey) case $args in 2) _cryptsetup_device @@ -76,27 +77,27 @@ _cryptsetup() ;; esac ;; - luksKillSlot|luksDelKey|luksUUID|isLuks|luksDump) + luksKillSlot | luksDelKey | luksUUID | isLuks | luksDump) case $args in 2) _cryptsetup_device ;; esac ;; - luksHeaderBackup|luksHeaderRestore) + luksHeaderBackup | luksHeaderRestore) case $args in 2) _cryptsetup_device ;; 3) - COMPREPLY=( '--header-backup-file' ) + COMPREPLY=('--header-backup-file') ;; - esac + esac ;; esac fi } && -complete -F _cryptsetup cryptsetup + complete -F _cryptsetup cryptsetup # ex: filetype=sh diff --git a/completions/curl b/completions/curl index d744e49a..6e842697 100644 --- a/completions/curl +++ b/completions/curl @@ -6,24 +6,24 @@ _curl() _init_completion || return case $prev in - --ciphers|--connect-timeout|--continue-at|--form|--form-string|\ - --ftp-account|--ftp-alternative-to-user|--ftp-port|--header|--help|\ - --hostpubmd5|--keepalive-time|--krb|--limit-rate|--local-port|\ - --mail-from|--mail-rcpt|--max-filesize|--max-redirs|--max-time|--pass|\ - --proto|--proto-redir|--proxy-user|--proxy1.0|--quote|--range|\ - --request|--retry|--retry-delay|--retry-max-time|\ - --socks5-gssapi-service|--telnet-option|--tftp-blksize|--time-cond|\ - --url|--user|--user-agent|--version|--write-out|--resolve|--tlsuser|\ - --tlspassword|-!(-*)[CFPHhmQrXtzuAVw]) - return - ;; - --config|--cookie|--cookie-jar|--dump-header|--egd-file|\ - --key|--libcurl|--output|--random-file|--upload-file|--trace|\ - --trace-ascii|--netrc-file|-!(-*)[KbcDoT]) + --ciphers | --connect-timeout | --continue-at | --form | --form-string | \ + --ftp-account | --ftp-alternative-to-user | --ftp-port | --header | --help | \ + --hostpubmd5 | --keepalive-time | --krb | --limit-rate | --local-port | \ + --mail-from | --mail-rcpt | --max-filesize | --max-redirs | --max-time | --pass | \ + --proto | --proto-redir | --proxy-user | --proxy1.0 | --quote | --range | \ + --request | --retry | --retry-delay | --retry-max-time | \ + --socks5-gssapi-service | --telnet-option | --tftp-blksize | --time-cond | \ + --url | --user | --user-agent | --version | --write-out | --resolve | --tlsuser | \ + --tlspassword | -!(-*)[CFPHhmQrXtzuAVw]) + return + ;; + --config | --cookie | --cookie-jar | --dump-header | --egd-file | \ + --key | --libcurl | --output | --random-file | --upload-file | --trace | \ + --trace-ascii | --netrc-file | -!(-*)[KbcDoT]) _filedir return ;; - --cacert|--cert|-!(-*)E) + --cacert | --cert | -!(-*)E) _filedir '@(c?(e)rt|cer|pem|der)' return ;; @@ -31,47 +31,47 @@ _curl() _filedir -d return ;; - --cert-type|--key-type) - COMPREPLY=( $(compgen -W 'DER PEM ENG' -- "$cur") ) + --cert-type | --key-type) + COMPREPLY=($(compgen -W 'DER PEM ENG' -- "$cur")) return ;; --crlfile) _filedir crl return ;; - --data|--data-ascii|--data-binary|--data-urlencode|-!(-*)d) + --data | --data-ascii | --data-binary | --data-urlencode | -!(-*)d) if [[ $cur == \@* ]]; then cur=${cur:1} _filedir - if [[ ${#COMPREPLY[@]} -eq 1 && -d "${COMPREPLY[0]}" ]]; then + if [[ ${#COMPREPLY[@]} -eq 1 && -d ${COMPREPLY[0]} ]]; then COMPREPLY[0]+=/ compopt -o nospace fi - COMPREPLY=( "${COMPREPLY[@]/#/@}" ) + COMPREPLY=("${COMPREPLY[@]/#/@}") fi return ;; --delegation) - COMPREPLY=( $(compgen -W 'none policy always' -- "$cur") ) + COMPREPLY=($(compgen -W 'none policy always' -- "$cur")) return ;; --engine) - COMPREPLY=( $(compgen -W 'list' -- "$cur") ) + COMPREPLY=($(compgen -W 'list' -- "$cur")) return ;; --ftp-method) - COMPREPLY=( $(compgen -W 'multicwd nocwd singlecwd' -- "$cur") ) + COMPREPLY=($(compgen -W 'multicwd nocwd singlecwd' -- "$cur")) return ;; --ftp-ssl-ccc-mode) - COMPREPLY=( $(compgen -W 'active passive' -- "$cur") ) + COMPREPLY=($(compgen -W 'active passive' -- "$cur")) return ;; --interface) _available_interfaces -a return ;; - --proxy|--socks4|--socks4a|--socks5|--socks5-hostname|-!(-*)x) + --proxy | --socks4 | --socks4a | --socks5 | --socks5-hostname | -!(-*)x) _known_hosts_real -- "$cur" return ;; @@ -80,20 +80,20 @@ _curl() return ;; --stderr) - COMPREPLY=( $(compgen -W '-' -- "$cur") ) + COMPREPLY=($(compgen -W '-' -- "$cur")) _filedir return ;; --tlsauthtype) - COMPREPLY=( $(compgen -W 'SRP' -- "$cur") ) + COMPREPLY=($(compgen -W 'SRP' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _curl curl + complete -F _curl curl # ex: filetype=sh diff --git a/completions/cvs b/completions/cvs index 0fb49f9c..ba1f0622 100644 --- a/completions/cvs +++ b/completions/cvs @@ -4,9 +4,9 @@ _cvs_entries() { local prefix=${cur%/*}/ IFS=$'\n' [[ -e ${prefix:-}CVS/Entries ]] || prefix="" - entries=( $(cut -d/ -f2 -s ${prefix:-}CVS/Entries 2>/dev/null) ) + entries=($(cut -d/ -f2 -s ${prefix:-}CVS/Entries 2>/dev/null)) if [[ $entries ]]; then - entries=( "${entries[@]/#/${prefix:-}}" ) + entries=("${entries[@]/#/${prefix:-}}") compopt -o filenames fi } @@ -14,9 +14,9 @@ _cvs_entries() _cvs_modules() { if [[ -n $prefix ]]; then - COMPREPLY=( $(command ls -d ${cvsroot}/${prefix}/!(CVSROOT)) ) + COMPREPLY=($(command ls -d ${cvsroot}/${prefix}/!(CVSROOT))) else - COMPREPLY=( $(command ls -d ${cvsroot}/!(CVSROOT)) ) + COMPREPLY=($(command ls -d ${cvsroot}/!(CVSROOT))) fi } @@ -27,21 +27,21 @@ _cvs_commands() _cvs_command_options() { - COMPREPLY=( $(compgen -W '$(_parse_help "$1" "--help $2")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" "--help $2")' -- "$cur")) } _cvs_kflags() { - COMPREPLY=( $(compgen -W 'kv kvl k o b v' -- "$cur") ) + COMPREPLY=($(compgen -W 'kv kvl k o b v' -- "$cur")) } _cvs_roots() { local -a cvsroots - cvsroots=( $CVSROOT ) - [[ -r ~/.cvspass ]] && cvsroots+=( $(awk '{ print $2 }' ~/.cvspass) ) + [[ -v CVSROOT ]] && cvsroots=("$CVSROOT") + [[ -r ~/.cvspass ]] && cvsroots+=($(awk '{ print $2 }' ~/.cvspass)) [[ -r CVS/Root ]] && mapfile -tO ${#cvsroots[@]} cvsroots <CVS/Root - COMPREPLY=( $(compgen -W '${cvsroots[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${cvsroots[@]}' -- "$cur")) __ltrim_colon_completions "$cur" } @@ -55,89 +55,89 @@ _cvs() count=0 for i in "${words[@]}"; do - [[ $count -eq $cword ]] && break + ((count == cword)) && break # Last parameter was the CVSROOT, now go back to mode selection - if [[ "${words[((count))]}" == "$cvsroot" && "$mode" == cvsroot ]]; then + if [[ ${words[count]} == "${cvsroot-}" && ${mode-} == cvsroot ]]; then mode="" fi - if [[ -z $mode ]]; then + if [[ ! -v mode ]]; then case $i in - --help|-!(-*)H) - COMPREPLY=( $(compgen -W "$(_cvs_commands)" -- "$cur") ) + --help | -!(-*)H) + COMPREPLY=($(compgen -W "$(_cvs_commands)" -- "$cur")) return ;; -!(-*)d) mode=cvsroot - cvsroot=${words[((count+1))]} + cvsroot=${words[count + 1]} ;; - add|ad|new) + add | ad | new) mode=add ;; - admin|adm|rcs) - mode=admin + admin | adm | rcs) + mode="admin" ;; - annotate|ann|blame|rannotate|rann|ra) + annotate | ann | blame | rannotate | rann | ra) mode=annotate ;; - checkout|co|get) + checkout | co | get) mode=checkout ;; - commit|ci|com) + commit | ci | com) mode=commit ;; - diff|di|dif) - mode=diff + diff | di | dif) + mode="diff" ;; - export|ex|exp) - mode=export + export | ex | exp) + mode="export" ;; - edit|unedit|editors|logout|pserver|server|watch|watchers) + edit | unedit | editors | logout | pserver | server | watch | watchers) mode=$i ;; - history|hi|his) + history | hi | his) mode=history ;; - import|im|imp) + import | im | imp) mode=import ;; - log|lo|rlog|rl) + log | lo | rlog | rl) mode=log ;; - login|logon|lgn) + login | logon | lgn) mode=login ;; - rdiff|patch|pa) + rdiff | patch | pa) mode=rdiff ;; - release|re|rel) + release | re | rel) mode=release ;; - remove|rm|delete) + remove | rm | delete) mode=remove ;; - rtag|rt|rfreeze) + rtag | rt | rfreeze) mode=rtag ;; - status|st|stat) + status | st | stat) mode=status ;; - tag|ta|freeze) + tag | ta | freeze) mode=tag ;; - update|up|upd) + update | up | upd) mode=update ;; - version|ve|ver) + version | ve | ver) mode=version ;; esac - elif [[ "$i" == -* ]]; then - flags+=( $i ) + elif [[ $i == -* ]]; then + flags+=($i) fi - (( count++ )) + ((count++)) done - case $mode in + case ${mode-} in add) case $prev in --*) ;; @@ -150,25 +150,25 @@ _cvs() ;; esac - if [[ "$cur" != -* ]]; then + if [[ $cur != -* ]]; then _cvs_entries - [[ -z $cur ]] && files=( !(CVS) ) || \ - files=( $(command ls -d ${cur}* 2>/dev/null) ) + [[ -z $cur ]] && files=(!(CVS)) || + files=($(command ls -d ${cur}* 2>/dev/null)) local f for i in "${!files[@]}"; do if [[ ${files[i]} == ?(*/)CVS ]]; then unset 'files[i]' else for f in "${entries[@]}"; do - if [[ ${files[i]} == $f && ! -d $f ]]; then + if [[ ${files[i]} == "$f" && ! -d $f ]]; then unset 'files[i]' break fi done fi done - COMPREPLY=( $(compgen -X "$_backup_glob" -W '${files[@]}' \ - -- "$cur") ) + COMPREPLY=($(compgen -X "$_backup_glob" -W '${files[@]}' \ + -- "$cur")) else _cvs_command_options "$1" $mode fi @@ -189,21 +189,21 @@ _cvs() ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur")) fi ;; annotate) - [[ "$prev" == -[rD] ]] && return + [[ $prev == -[rD] ]] && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur")) fi ;; checkout) @@ -222,11 +222,11 @@ _cvs() ;; esac - if [[ "$cur" != -* ]]; then - [[ -z $cvsroot ]] && cvsroot=$CVSROOT - COMPREPLY=( $(cvs -d "$cvsroot" co -c 2>/dev/null | \ - awk '{print $1}') ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + if [[ $cur != -* ]]; then + [[ ! -v cvsroot ]] && cvsroot=${CVSROOT-} + COMPREPLY=($(cvs -d "$cvsroot" co -c 2>/dev/null | + awk '{print $1}')) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) else _cvs_command_options "$1" $mode fi @@ -243,7 +243,7 @@ _cvs() ;; esac - if [[ "$cur" != -* ]]; then + if [[ $cur != -* ]]; then # if $COMP_CVS_REMOTE is not null, 'cvs commit' will # complete on remotely checked-out files (requires # passwordless access to the remote repository @@ -251,15 +251,15 @@ _cvs() # this is the least computationally intensive way found so # far, but other changes (something other than # changed/removed/new) may be missing - changed=( $(cvs -q diff --brief 2>&1 | \ - command sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p') ) - newremoved=( $(cvs -q diff --brief 2>&1 | \ - command sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p') ) - COMPREPLY=( $(compgen -W '${changed[@]:-} \ - ${newremoved[@]:-}' -- "$cur") ) + changed=($(cvs -q diff --brief 2>&1 | + command sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p')) + newremoved=($(cvs -q diff --brief 2>&1 | + command sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p')) + COMPREPLY=($(compgen -W '${changed[@]:-} \ + ${newremoved[@]:-}' -- "$cur")) else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur")) fi else _cvs_command_options "$1" $mode @@ -268,21 +268,21 @@ _cvs() cvsroot) _cvs_roots ;; - diff|log) - if [[ "$cur" == -* ]]; then + diff | log) + if [[ $cur == -* ]]; then _cvs_command_options "$1" $mode - [[ $COMPREPLY == *= ]] && compopt -o nospace + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]:-}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]:-}' -- "$cur")) fi ;; - editors|watchers) - if [[ "$cur" == -* ]]; then + editors | watchers) + if [[ $cur == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur")) fi ;; export) @@ -301,10 +301,10 @@ _cvs() ;; esac - if [[ "$cur" != -* ]]; then - [[ -z $cvsroot ]] && cvsroot=$CVSROOT - COMPREPLY=( $(cvs -d "$cvsroot" co -c | awk '{print $1}') ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + if [[ $cur != -* ]]; then + [[ ! -v cvsroot ]] && cvsroot=${CVSROOT-} + COMPREPLY=($(cvs -d "$cvsroot" co -c | awk '{print $1}')) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) else _cvs_command_options "$1" $mode fi @@ -321,32 +321,32 @@ _cvs() ;; esac - if [[ "$cur" != -* ]]; then + if [[ $cur != -* ]]; then # starts with same algorithm as checkout - [[ -z $cvsroot ]] && cvsroot=$CVSROOT + [[ ! -v cvsroot ]] && cvsroot=${CVSROOT-} local prefix=${cur%/*} if [[ -r ${cvsroot}/${prefix} ]]; then _cvs_modules - COMPREPLY=( ${COMPREPLY[@]#$cvsroot} ) - COMPREPLY=( ${COMPREPLY[@]#\/} ) + COMPREPLY=(${COMPREPLY[@]#$cvsroot}) + COMPREPLY=(${COMPREPLY[@]#\/}) fi pwd=$(pwd) pwd=${pwd##*/} - COMPREPLY=( $(compgen -W '${COMPREPLY[@]} $pwd' -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]} $pwd' -- "$cur")) else _cvs_command_options "$1" $mode fi ;; remove) - if [[ "$cur" != -* ]]; then + if [[ $cur != -* ]]; then _cvs_entries - if [[ "$prev" != -f ]]; then + if [[ $prev != -f ]]; then # find out what files are missing for i in "${!entries[@]}"; do - [[ -r "${entries[i]}" ]] && unset 'entries[i]' + [[ -r ${entries[i]} ]] && unset 'entries[i]' done fi - COMPREPLY=( $(compgen -W '${entries[@]:-}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]:-}' -- "$cur")) else _cvs_command_options "$1" $mode fi @@ -363,11 +363,11 @@ _cvs() ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur")) fi ;; "") @@ -381,18 +381,18 @@ _cvs() return ;; -*z) - COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..9}' -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W '$(_cvs_commands) + COMPREPLY=($(compgen -W '$(_cvs_commands) $(_parse_help "$1" --help-options) --help --help-commands - --help-options --version' -- "$cur") ) + --help-options --version' -- "$cur")) ;; esac } && -complete -F _cvs cvs + complete -F _cvs cvs # ex: filetype=sh diff --git a/completions/cvsps b/completions/cvsps index 721a5b73..4fdfefc3 100644 --- a/completions/cvsps +++ b/completions/cvsps @@ -6,27 +6,27 @@ _cvsps() _init_completion -n : || return case $prev in - -h|-z|-f|-d|-l|--diff-opts|--debuglvl) + -h | -z | -f | -d | -l | --diff-opts | --debuglvl) return ;; -s) - COMPREPLY=( $(compgen -W "$($1 2>/dev/null | - awk '/^PatchSet:?[ \t]/ { print $2 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 2>/dev/null | + awk '/^PatchSet:?[ \t]/ { print $2 }')" -- "$cur")) return ;; -a) - COMPREPLY=( $(compgen -W "$($1 2>/dev/null | - awk '/^Author:[ \t]/ { print $2 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 2>/dev/null | + awk '/^Author:[ \t]/ { print $2 }')" -- "$cur")) return ;; -b) - COMPREPLY=( $(compgen -W "$($1 2>/dev/null | - awk '/^Branch:[ \t]/ { print $2 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 2>/dev/null | + awk '/^Branch:[ \t]/ { print $2 }')" -- "$cur")) return ;; -r) - COMPREPLY=( $(compgen -W "$($1 2>/dev/null | - awk '/^Tag:[ \t]+[^(]/ { print $2 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 2>/dev/null | + awk '/^Tag:[ \t]+[^(]/ { print $2 }')" -- "$cur")) return ;; -p) @@ -38,7 +38,7 @@ _cvsps() return ;; -Z) - COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..9}' -- "$cur")) return ;; --root) @@ -47,12 +47,12 @@ _cvsps() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) else _xfunc cvs _cvs_roots fi } && -complete -F _cvsps cvsps + complete -F _cvsps cvsps # ex: filetype=sh diff --git a/completions/dd b/completions/dd index 5384dd5e..04d876a0 100644 --- a/completions/dd +++ b/completions/dd @@ -6,37 +6,37 @@ _dd() _init_completion -n = || return case $cur in - if=*|of=*) + if=* | of=*) cur=${cur#*=} _filedir return ;; conv=*) cur=${cur#*=} - COMPREPLY=( $(compgen -W 'ascii ebcdic ibm block unblock lcase + COMPREPLY=($(compgen -W 'ascii ebcdic ibm block unblock lcase ucase sparse swab sync excl nocreat notrunc noerror fdatasync - fsync' -- "$cur") ) + fsync' -- "$cur")) return ;; - iflag=*|oflag=*) + iflag=* | oflag=*) cur=${cur#*=} - COMPREPLY=( $(compgen -W 'append direct directory dsync sync + COMPREPLY=($(compgen -W 'append direct directory dsync sync fullblock nonblock noatime nocache noctty nofollow count_bytes - skip_bytes seek_bytes' -- "$cur") ) + skip_bytes seek_bytes' -- "$cur")) return ;; status=*) cur=${cur#*=} - COMPREPLY=( $(compgen -W 'none noxfer progress' -- "$cur") ) + COMPREPLY=($(compgen -W 'none noxfer progress' -- "$cur")) return ;; esac - 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 + 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 dd + complete -F _dd dd # ex: filetype=sh diff --git a/completions/deja-dup b/completions/deja-dup index ad3baeb8..1854d6a4 100644 --- a/completions/deja-dup +++ b/completions/deja-dup @@ -6,7 +6,7 @@ _deja_dup() _init_completion -s || return case $prev in - -'?'|--help|--help-*) + -'?' | --help | --help-*) return ;; --restore) @@ -21,12 +21,12 @@ _deja_dup() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi } && -complete -F _deja_dup deja-dup + complete -F _deja_dup deja-dup # ex: filetype=sh diff --git a/completions/desktop-file-validate b/completions/desktop-file-validate index 7d9f05b2..8f4e139d 100644 --- a/completions/desktop-file-validate +++ b/completions/desktop-file-validate @@ -12,12 +12,12 @@ _desktop_file_validate() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir desktop } && -complete -F _desktop_file_validate desktop-file-validate + complete -F _desktop_file_validate desktop-file-validate # ex: filetype=sh diff --git a/completions/dhclient b/completions/dhclient index b097bbac..ce4b7452 100644 --- a/completions/dhclient +++ b/completions/dhclient @@ -6,11 +6,11 @@ _dhclient() _init_completion || return case $prev in - -p|-e) + -p | -e) return ;; -D) - COMPREPLY=( $(compgen -W 'LL LLT' -- "$cur") ) + COMPREPLY=($(compgen -W 'LL LLT' -- "$cur")) return ;; -*f) @@ -23,12 +23,12 @@ _dhclient() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) else _available_interfaces fi } && -complete -F _dhclient dhclient + complete -F _dhclient dhclient # ex: filetype=sh diff --git a/completions/dict b/completions/dict index c3ea9906..f3426ffd 100644 --- a/completions/dict +++ b/completions/dict @@ -13,35 +13,35 @@ _dict() local host port db i - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in - --host|-!(-*)h) + --host | -!(-*)h) host=${words[++i]} [[ -n $host ]] && host="-h $host" ;; - --port|-!(-*)p) + --port | -!(-*)p) port=${words[++i]} [[ -n $port ]] && port="-p $port" ;; - --database|-!(-*)d) + --database | -!(-*)d) db=${words[++i]} [[ -n $db ]] && host="-d $db" ;; esac done - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi case $prev in - --database|-info|-!(-*)[di]) - COMPREPLY=( $(compgen -W '$(_dictdata -D)' -- "$cur") ) + --database | -info | -!(-*)[di]) + COMPREPLY=($(compgen -W '$(_dictdata -D)' -- "$cur")) return ;; - --strategy|-!(-*)s) - COMPREPLY=( $(compgen -W '$(_dictdata -S)' -- "$cur") ) + --strategy | -!(-*)s) + COMPREPLY=($(compgen -W '$(_dictdata -S)' -- "$cur")) return ;; esac @@ -52,13 +52,13 @@ _dict() # it down with grep if $cur looks like something that's safe to embed # in a pattern instead. if [[ $cur == +([-A-Za-z0-9/.]) ]]; then - COMPREPLY=( $(compgen -W \ - '$(command grep "^${cur//./\\.}" $dictfile)' -- "$cur") ) + COMPREPLY=($(compgen -W \ + '$(command grep "^${cur//./\\.}" $dictfile)' -- "$cur")) else - COMPREPLY=( $(compgen -W '$(cat $dictfile)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(cat $dictfile)' -- "$cur")) fi fi } && -complete -F _dict -o default dict rdict + complete -F _dict -o default dict rdict # ex: filetype=sh diff --git a/completions/dmypy b/completions/dmypy index a8c07437..5abe37d7 100644 --- a/completions/dmypy +++ b/completions/dmypy @@ -6,7 +6,7 @@ _dmypy() _init_completion || return case $prev in - --help|--version|-[hV]) + --help | --version | -[hV]) return ;; --status-file) @@ -16,32 +16,33 @@ _dmypy() esac local cmd i - for (( i=1; i < cword; i++ )); do - if [[ ${words[i]} != -* && ${words[i-1]} != --status-file ]]; then + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} != -* && ${words[i - 1]} != --status-file ]]; then cmd=${words[i]} break fi done - case $cmd in - check|run) + case ${cmd-} in + check | run) _filedir '@(py|pyi)' return + ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - if [[ ! $cmd ]]; then - local cmds=$($1 --help 2>&1 \ - | command sed -ne '/positional arguments/{p;n;p;q}' \ - | command sed -ne 's/{\(.*\)}/\1/p') - COMPREPLY=( $(IFS="," compgen -W '$cmds' -- "$cur") ) + if [[ ! -v cmd ]]; then + local cmds=$($1 --help 2>&1 | + command sed -ne '/positional arguments/{p;n;p;q}' | + command sed -ne 's/{\(.*\)}/\1/p') + COMPREPLY=($(IFS="," compgen -W '$cmds' -- "$cur")) return fi } && -complete -F _dmypy dmypy + complete -F _dmypy dmypy # ex: filetype=sh diff --git a/completions/dnssec-keygen b/completions/dnssec-keygen index 2ecfcdc5..3f68a687 100644 --- a/completions/dnssec-keygen +++ b/completions/dnssec-keygen @@ -2,11 +2,11 @@ _dnssec_keygen_optarg() { - local args=$("$1" -h 2>&1 | \ + local args=$("$1" -h 2>&1 | command sed -e 's/|/ /g' -e 's/(.*//' \ - -ne '/^[[:space:]]*'$2'/,/^[[:space:]]*[(-]/p' | \ + -ne '/^[[:space:]]*'$2'/,/^[[:space:]]*[(-]/p' | command sed -e 's/^[[:space:]]*'$2'.*://' -e '/^[[:space:]]*-/d') - COMPREPLY+=( $(compgen -W '$args' -- "$cur") ) + COMPREPLY+=($(compgen -W '$args' -- "$cur")) } _dnssec_keygen() @@ -32,17 +32,17 @@ _dnssec_keygen() return ;; -v) - COMPREPLY=( $(compgen -W '{0..10}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..10}' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" | \ - command sed -e "s/:\$//")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" | \ + command sed -e "s/:\$//")' -- "$cur")) return fi } && -complete -F _dnssec_keygen dnssec-keygen + complete -F _dnssec_keygen dnssec-keygen # ex: filetype=sh diff --git a/completions/dnsspoof b/completions/dnsspoof index e45d48d6..86ade91d 100644 --- a/completions/dnsspoof +++ b/completions/dnsspoof @@ -16,11 +16,11 @@ _dnsspoof() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) fi } && -complete -F _dnsspoof dnsspoof + complete -F _dnsspoof dnsspoof # ex: filetype=sh diff --git a/completions/dot b/completions/dot index bad82f2c..81222292 100644 --- a/completions/dot +++ b/completions/dot @@ -8,38 +8,38 @@ _dot() [[ $prev == -[V?] ]] && return case $cur in - -G*|-N*|-E*|-l?*|-q?*|-s?*|-Ln*|-LU*|-LC*|-LT*) + -G* | -N* | -E* | -l?* | -q?* | -s?* | -Ln* | -LU* | -LC* | -LT*) return ;; -T*) - local langs=( $("$1" -TNON_EXISTENT 2>&1 | \ - command sed -ne 's/.*one of://p') ) - COMPREPLY=( $(compgen -P -T -W '${langs[@]}' -- "${cur#-T}") ) + local langs=($("$1" -TNON_EXISTENT 2>&1 | + command sed -ne 's/.*one of://p')) + COMPREPLY=($(compgen -P -T -W '${langs[@]}' -- "${cur#-T}")) return ;; -K*) - local layouts=( $("$1" -KNON_EXISTENT 2>&1 | \ - command sed -ne 's/.*one of://p') ) - COMPREPLY=( $(compgen -P -K -W '${layouts[@]}' -- "${cur#-K}") ) + local layouts=($("$1" -KNON_EXISTENT 2>&1 | + command sed -ne 's/.*one of://p')) + COMPREPLY=($(compgen -P -K -W '${layouts[@]}' -- "${cur#-K}")) return ;; -o*) cur=${cur#-o} _filedir - COMPREPLY=( $(compgen -P -o -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY=($(compgen -P -o -W '${COMPREPLY[@]}' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-V -v -G -N -E -T -K -l -o -O -P -q -s -y -n - -n1 -n2 -x -Lg -LO -Ln -LU -LC -LT -m -c -?' -- "$cur") ) - [[ $COMPREPLY == -@([GNETKo]|L[nUCT]) ]] && compopt -o nospace + COMPREPLY=($(compgen -W '-V -v -G -N -E -T -K -l -o -O -P -q -s -y -n + -n1 -n2 -x -Lg -LO -Ln -LU -LC -LT -m -c -?' -- "$cur")) + [[ ${COMPREPLY-} == -@([GNETKo]|L[nUCT]) ]] && compopt -o nospace return fi _filedir dot } && -complete -F _dot dot + complete -F _dot dot # ex: filetype=sh diff --git a/completions/dpkg b/completions/dpkg index 827d9cad..0b90b14b 100644 --- a/completions/dpkg +++ b/completions/dpkg @@ -1,35 +1,35 @@ # This function is required by _dpkg and _dpkg-reconfigure -*- shell-script -*- _have grep-status && { -_comp_dpkg_installed_packages() -{ - grep-status -P -e "^$1" -a -FStatus 'ok installed' -n -s Package -} + _comp_dpkg_installed_packages() + { + grep-status -P -e "^$1" -a -FStatus 'ok installed' -n -s Package + } } || { -_comp_dpkg_installed_packages() -{ - command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null | \ - command grep -B 1 -Ee "ok installed|half-installed|unpacked| \ + _comp_dpkg_installed_packages() + { + command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null | + command grep -B 1 -Ee "ok installed|half-installed|unpacked| \ half-configured" \ - -Ee "^Essential: yes" | \ - awk "/Package: $1/ { print \$2 }" 2>/dev/null -} + -Ee "^Essential: yes" | + awk "/Package: $1/ { print \$2 }" 2>/dev/null + } } _have grep-status && { -_comp_dpkg_purgeable_packages() -{ - grep-status -P -e "^$1" -a -FStatus 'ok installed' -o -FStatus 'ok config-files' -n -s Package -} + _comp_dpkg_purgeable_packages() + { + grep-status -P -e "^$1" -a -FStatus 'ok installed' -o -FStatus 'ok config-files' -n -s Package + } } || { -_comp_dpkg_purgeable_packages() -{ - command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null | \ - command grep -B 1 -Ee "ok installed|half-installed|unpacked| \ + _comp_dpkg_purgeable_packages() + { + command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null | + command grep -B 1 -Ee "ok installed|half-installed|unpacked| \ half-configured|config-files" \ - -Ee "^Essential: yes" | \ - awk "/Package: $1/ { print \$2 }" 2>/dev/null -} + -Ee "^Essential: yes" | + awk "/Package: $1/ { print \$2 }" 2>/dev/null + } } # Debian dpkg(1) completion @@ -49,39 +49,47 @@ _dpkg() fi case $prev in - --install|--unpack|--record-avail|--contents|--info|--fsys-tarfile|\ - --field|--control|--extract|--vextract|-!(-*)[ciAIfexW]) + --install | --unpack | --record-avail | --contents | --info | --fsys-tarfile | \ + --field | --control | --extract | --vextract | --raw-extract | -!(-*)[ciAIfexX]) _filedir '?(u|d)deb' return ;; - --build|-!(-*)b) + --build | -!(-*)b) _filedir -d return ;; - --status|--print-avail|--list|--show|-!(-*)[splW]) - COMPREPLY=( $(apt-cache pkgnames "$cur" 2>/dev/null) ) + --status | --print-avail | --list | -!(-*)[spl]) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)) + return + ;; + --show | -!(-*)W) + if [[ $1 == *dpkg-query ]]; then + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)) + else + _filedir '?(u|d)deb' + fi return ;; - --search|-!(-*)S) + --search | -!(-*)S) _filedir return ;; - --remove|--verify|-!(-*)[rV]) - COMPREPLY=( $(_comp_dpkg_installed_packages "$cur") ) + --remove | --verify | -!(-*)[rV]) + COMPREPLY=($(_comp_dpkg_installed_packages "$cur")) return ;; - --listfiles|--purge|-!(-*)[LP]) - COMPREPLY=( $(_comp_dpkg_purgeable_packages "$cur") ) + --listfiles | --purge | -!(-*)[LP]) + COMPREPLY=($(_comp_dpkg_purgeable_packages "$cur")) return ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _dpkg dpkg dpkg-deb dpkg-query + complete -F _dpkg dpkg dpkg-deb dpkg-query # Debian GNU dpkg-reconfigure(8) completion # @@ -93,26 +101,26 @@ _dpkg_reconfigure() local opt case $prev in - --frontend|-!(-*)f) - opt=( $(printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/*) ) - opt=( ${opt[@]##*/} ) - opt=( ${opt[@]%.pm} ) - COMPREPLY=( $(compgen -W '${opt[@]}' -- "$cur") ) + --frontend | -!(-*)f) + opt=($(printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/*)) + opt=(${opt[@]##*/}) + opt=(${opt[@]%.pm}) + COMPREPLY=($(compgen -W '${opt[@]}' -- "$cur")) return ;; - --priority|-!(-*)p) - COMPREPLY=( $(compgen -W 'low medium high critical' -- "$cur") ) + --priority | -!(-*)p) + COMPREPLY=($(compgen -W 'low medium high critical' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--frontend --priority --all --unseen-only - --help --showold --force --terse' -- "$cur" ) ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--frontend --priority --all --unseen-only + --help --showold --force --terse' -- "$cur")) else - COMPREPLY=( $(_comp_dpkg_installed_packages "$cur") ) + COMPREPLY=($(_comp_dpkg_installed_packages "$cur")) fi } && -complete -F _dpkg_reconfigure -o default dpkg-reconfigure + complete -F _dpkg_reconfigure -o default dpkg-reconfigure # ex: filetype=sh diff --git a/completions/dpkg-source b/completions/dpkg-source index ffc34c41..05fa3a11 100644 --- a/completions/dpkg-source +++ b/completions/dpkg-source @@ -5,7 +5,7 @@ _dpkg_source() local cur prev words cword _init_completion || return - local options work i action packopts unpackopts fields + local options word action packopts unpackopts fields packopts="-c -l -F -V -T -D -U -W -E -sa -i -I -sk -sr -ss -sA -sK -sP \ -sU -sR" @@ -14,13 +14,13 @@ _dpkg_source() fields="Format Source Version Binary Maintainer Uploader Architecture \ Standards-Version Build-Depends Files" - action="options" - for (( i=0; i < ${#words[@]}-1; i++ )); do - if [[ ${words[$i]} == "-x" ]]; then + action=options + for word in "${words[@]:1}"; do + if [[ $word == -x ]]; then action=unpack - elif [[ ${words[$i]} == "-b" ]]; then + elif [[ $word == -b ]]; then action=pack - elif [[ ${words[$i]} == "-h" ]]; then + elif [[ $word == -h ]]; then action=help fi done @@ -33,7 +33,7 @@ _dpkg_source() _filedir 'dsc' ;; *) - COMPREPLY=( $(compgen -W "$unpackopts" -- "$cur") ) + COMPREPLY=($(compgen -W "$unpackopts" -- "$cur")) _filedir -d _filedir ;; @@ -45,7 +45,7 @@ _dpkg_source() -b) _filedir -d ;; - -c|-l|-T|-i|-I) + -c | -l | -T | -i | -I) # -c: get controlfile # -l: get per-version info from this file # -T: read variables here, not debian/substvars @@ -57,9 +57,9 @@ _dpkg_source() ;; -F) # -F: force change log format - COMPREPLY=( $(command ls /usr/lib/dpkg/parsechangelog) ) + COMPREPLY=($(command ls /usr/lib/dpkg/parsechangelog)) ;; - -V|-D) + -V) # -V: set a substitution variable # we don't know anything about possible variables or values # so we don't try to suggest any completion. @@ -68,31 +68,31 @@ _dpkg_source() -D) # -D: override or add a .dsc field and value # if $cur doesn't contain a = yet, suggest variable names - if [[ "$cur" == *=* ]]; then + if [[ $cur == *=* ]]; then # $cur contains a "=" COMPREPLY=() else - COMPREPLY=( $(compgen -W "$fields" -- "$cur") ) + COMPREPLY=($(compgen -W "$fields" -- "$cur")) fi ;; -U) # -U: remove a field # Suggest possible fieldnames - COMPREPLY=( $(compgen -W "$fields" -- "$cur") ) + COMPREPLY=($(compgen -W "$fields" -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W "$packopts $unpackopts" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "$packopts $unpackopts" \ + -- "$cur")) ;; esac return ;; *) - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) return ;; esac } && -complete -F _dpkg_source dpkg-source + complete -F _dpkg_source dpkg-source # ex: filetype=sh diff --git a/completions/dselect b/completions/dselect index 6ad38842..4c180267 100644 --- a/completions/dselect +++ b/completions/dselect @@ -10,20 +10,20 @@ _dselect() _filedir -d return ;; - -D|-debug) + -D | -debug) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - COMPREPLY=( $(compgen -W 'access update select install config remove - quit' -- "$cur") ) + COMPREPLY=($(compgen -W 'access update select install config remove + quit' -- "$cur")) fi } && -complete -F _dselect dselect + complete -F _dselect dselect # ex: filetype=sh diff --git a/completions/dsniff b/completions/dsniff index e8e5bf37..749c533c 100644 --- a/completions/dsniff +++ b/completions/dsniff @@ -6,7 +6,7 @@ _dsniff() _init_completion || return case $prev in - -r|-w|-f|-p) + -r | -w | -f | -p) _filedir return ;; @@ -16,11 +16,11 @@ _dsniff() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1") -r -w -p' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1") -r -w -p' -- "$cur")) fi } && -complete -F _dsniff dsniff + complete -F _dsniff dsniff # ex: filetype=sh diff --git a/completions/dumpdb b/completions/dumpdb index 981211bb..eb1927fa 100644 --- a/completions/dumpdb +++ b/completions/dumpdb @@ -5,14 +5,14 @@ _dumpdb() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--marshal --pickle --noprint --help' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--marshal --pickle --noprint --help' \ + -- "$cur")) else _filedir fi } && -complete -F _dumpdb dumpdb + complete -F _dumpdb dumpdb # ex: filetype=sh diff --git a/completions/dumpe2fs b/completions/dumpe2fs index f44ecc32..413a5bf6 100644 --- a/completions/dumpe2fs +++ b/completions/dumpe2fs @@ -15,14 +15,14 @@ _dumpe2fs() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi cur=${cur:=/dev/} _filedir } && -complete -F _dumpe2fs dumpe2fs + complete -F _dumpe2fs dumpe2fs # ex: filetype=sh diff --git a/completions/e2freefrag b/completions/e2freefrag index 355ebb94..c89dc9cb 100644 --- a/completions/e2freefrag +++ b/completions/e2freefrag @@ -6,19 +6,19 @@ _e2freefrag() _init_completion || return case $prev in - -c|-h) + -c | -h) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h)' -- "$cur")) return fi cur=${cur:=/dev/} _filedir } && -complete -F _e2freefrag e2freefrag + complete -F _e2freefrag e2freefrag # ex: filetype=sh diff --git a/completions/e2label b/completions/e2label index c145c3a0..ac8e4b5f 100644 --- a/completions/e2label +++ b/completions/e2label @@ -5,11 +5,11 @@ _e2label() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then + if ((cword == 1)); then cur=${cur:=/dev/} _filedir fi } && -complete -F _e2label e2label + complete -F _e2label e2label # ex: filetype=sh diff --git a/completions/ebtables b/completions/ebtables index 325962b5..de6bc549 100644 --- a/completions/ebtables +++ b/completions/ebtables @@ -6,42 +6,42 @@ _ebtables() _init_completion -s || return local table chain='s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \ - targets='ACCEPT DROP CONTINUE RETURN' + targets='ACCEPT DROP CONTINUE RETURN' - [[ "${words[*]}" =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] \ - && table="-t ${BASH_REMATCH[2]}" + [[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] && + table="-t ${BASH_REMATCH[2]}" 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 + -!(-*)[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 + -- "$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 + -- "$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 + -- "$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 @@ -67,12 +67,12 @@ _ebtables() --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 - ;; + --vlan-prio --zero' -- "$cur")) + fi + ;; esac } && -complete -F _ebtables ebtables + complete -F _ebtables ebtables # ex: filetype=sh diff --git a/completions/ecryptfs-migrate-home b/completions/ecryptfs-migrate-home index bad0962e..d2eeb381 100644 --- a/completions/ecryptfs-migrate-home +++ b/completions/ecryptfs-migrate-home @@ -9,14 +9,14 @@ _ecryptfs_migrate_home() --help) return ;; - --user|-u) - COMPREPLY=( $(compgen -u -- "$cur") ) + --user | -u) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _ecryptfs_migrate_home ecryptfs-migrate-home + complete -F _ecryptfs_migrate_home ecryptfs-migrate-home # ex: filetype=sh diff --git a/completions/eog b/completions/eog index d10cbbae..2330e1a2 100644 --- a/completions/eog +++ b/completions/eog @@ -6,7 +6,7 @@ _eog() _init_completion -s || return case $prev in - -'?'|--help|--help-all|--help-gtk) + -'?' | --help | --help-all | --help-gtk) return ;; esac @@ -14,13 +14,13 @@ _eog() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir '@(ani|?(w)bmp|gif|ico|j2[ck]|jp[cefgx2]|jpeg|jpg2|pcx|p[gp]m|pn[gm]|ras|svg?(z)|tga|tif?(f)|x[bp]m)' } && -complete -F _eog eog + complete -F _eog eog # ex: filetype=sh diff --git a/completions/ether-wake b/completions/ether-wake index a3e3e406..d9526736 100644 --- a/completions/ether-wake +++ b/completions/ether-wake @@ -16,12 +16,12 @@ _ether_wake() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -u) -V' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" -u) -V' -- "$cur")) return fi _mac_addresses } && -complete -F _ether_wake ether-wake etherwake + complete -F _ether_wake ether-wake etherwake # ex: filetype=sh diff --git a/completions/evince b/completions/evince index d50f23c3..1c97dd93 100644 --- a/completions/evince +++ b/completions/evince @@ -6,9 +6,9 @@ _evince() _init_completion -s || return case $prev in - --help*|--sm-client-id|--class|--name|--screen|--gdk-debug|\ - --gdk-no-debug|--gtk-module|--gtk-debug|--gtk-no-debug|--page-label|\ - --page-index|--find|--display|-!(-*)[hpil]) + --help* | --sm-client-id | --class | --name | --screen | --gdk-debug | \ + --gdk-no-debug | --gtk-module | --gtk-debug | --gtk-no-debug | --page-label | \ + --page-index | --find | --display | -!(-*)[hpil]) return ;; --sm-client-state-file) @@ -20,13 +20,13 @@ _evince() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir '@(@(?(e)ps|?(E)PS|[pf]df|[PF]DF|dvi|DVI)?(.gz|.GZ|.bz2|.BZ2|.xz|.XZ)|cb[rz]|djv?(u)|gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx)' } && -complete -F _evince evince + complete -F _evince evince # ex: filetype=sh diff --git a/completions/export b/completions/export index 816182f6..8d823614 100644 --- a/completions/export +++ b/completions/export @@ -6,7 +6,7 @@ _export() _init_completion -n = || return local i action=variable remove=false - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in -p) return @@ -33,10 +33,10 @@ _export() case $cur in *=) - local pval=$(quote "$(eval printf %s \"\$${cur%=}\")") + local pval=$(quote "$(eval printf %s \"\$\{${cur%=}-\}\")") # Complete previous value if it's not empty. if [[ $pval != \'\' ]]; then - COMPREPLY=( "$pval" ) + COMPREPLY=("$pval") else cur=${cur#*=} _filedir @@ -48,18 +48,18 @@ _export() ;; *) if [[ $cword -eq 1 && $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-p $(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '-p $(_parse_usage "$1")' -- "$cur")) return fi - local suffix + local suffix="" if ! $remove; then - suffix+== + suffix="=" compopt -o nospace fi - COMPREPLY=( $(compgen -A $action -S "$suffix" -- "$cur") ) + COMPREPLY=($(compgen -A $action -S "$suffix" -- "$cur")) ;; esac } && -complete -F _export export + complete -F _export export # ex: filetype=sh diff --git a/completions/faillog b/completions/faillog index 5e7d2ab2..c8b81bd0 100644 --- a/completions/faillog +++ b/completions/faillog @@ -6,22 +6,22 @@ _faillog() _init_completion -s || return case $prev in - --help|--lock-time|--maximum|--time|-!(-*)[hlmt]) + --help | --lock-time | --maximum | --time | -!(-*)[hlmt]) return ;; - --user|-!(-*)u) - COMPREPLY=( $(compgen -u -- "$cur") ) + --user | -!(-*)u) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _faillog faillog + complete -F _faillog faillog # ex: filetype=sh diff --git a/completions/fbgs b/completions/fbgs index 7a3ad7be..1947b872 100644 --- a/completions/fbgs +++ b/completions/fbgs @@ -6,45 +6,45 @@ _fbgs() _init_completion || return case "$prev" in - -f|--font) + -f | --font) local IFS=$'\n' - COMPREPLY=( $(compgen -W '$(fc-list 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(fc-list 2>/dev/null)' -- "$cur")) return ;; - -m|--mode) - COMPREPLY=( $(compgen -W '$(command sed \ + -m | --mode) + COMPREPLY=($(compgen -W '$(command sed \ -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \ - /etc/fb.modes 2>/dev/null)' -- "$cur") ) + /etc/fb.modes 2>/dev/null)' -- "$cur")) return ;; - -d|--device) - COMPREPLY=( $(compgen -f -d -- "${cur:-/dev/}") ) + -d | --device) + COMPREPLY=($(compgen -f -d -- "${cur:-/dev/}")) return ;; - -fp|--firstpage|-lp|--lastpage|-r|--resolution|-s|--scroll|-t|\ - --timeout) + -fp | --firstpage | -lp | --lastpage | -r | --resolution | -s | --scroll | -t | \ + --timeout) # expect integer value - COMPREPLY+=( $(compgen -W '{0..9}') ) + COMPREPLY+=($(compgen -W '{0..9}')) compopt -o nospace return ;; - -T|--vt|-p|--password|-g|--gamma) + -T | --vt | -p | --password | -g | --gamma) # argument required but no completions available return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--bell --help --password -fp --firstpage + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--bell --help --password -fp --firstpage -lp --lastpage --color -l -xl -xxl --resolution --autozoom --{,no}autoup --{,no}autodown --{,no}fitwidth --{,no}verbose --{,no}random --vt --scroll --timeout --{,no}once --gamma --font - --device --mode' -- "$cur") ) - [[ $COMPREPLY ]] && return + --device --mode' -- "$cur")) + [[ ${COMPREPLY-} ]] && return fi _filedir '?(e)ps|pdf' } && -complete -F _fbgs fbgs + complete -F _fbgs fbgs # ex: filetype=sh diff --git a/completions/fbi b/completions/fbi index ac92e60f..455887a3 100644 --- a/completions/fbi +++ b/completions/fbi @@ -6,49 +6,49 @@ _fbi() _init_completion || return case "$prev" in - -l|--list) + -l | --list) _filedir return ;; - -r|--resolution) - COMPREPLY+=( $(compgen -W '{1..5}') ) + -r | --resolution) + COMPREPLY+=($(compgen -W '{1..5}')) return ;; - -f|--font) + -f | --font) local IFS=$'\n' - COMPREPLY=( $(compgen -W '$(fc-list 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(fc-list 2>/dev/null)' -- "$cur")) return ;; - -m|--mode) - COMPREPLY=( $(compgen -W '$(command sed \ + -m | --mode) + COMPREPLY=($(compgen -W '$(command sed \ -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \ - /etc/fb.modes 2>/dev/null)' -- "$cur") ) + /etc/fb.modes 2>/dev/null)' -- "$cur")) return ;; - -d|--device) - COMPREPLY=( $(compgen -f -d -- "${cur:-/dev/}") ) + -d | --device) + COMPREPLY=($(compgen -f -d -- "${cur:-/dev/}")) return ;; - --cachemem|--blend|-T|--vt|-s|--scroll|-t|--timeout|-g|--gamma) + --cachemem | --blend | -T | --vt | -s | --scroll | -t | --timeout | -g | --gamma) # argument required but no completions available return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --version --store --list --text + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --version --store --list --text --autozoom --{,no}autoup --{,no}autodown --{,no}fitwidth --{,no}verbose --{,no}random --{,no}comments --{,no}edit --{,no}backup --{,no}preserve --{,no}readahead --cachemem --blend --vt --scroll --timeout --{,no}once --resolution --gamma --font - --device --mode' -- "$cur") ) - [[ $COMPREPLY ]] && return + --device --mode' -- "$cur")) + [[ ${COMPREPLY-} ]] && return fi # FIXME: It is hard to determine correct supported extensions. # fbi can handle any format that imagemagick can plus some others _filedir 'bmp|gif|jp?(e)g|pcd|png|p[pgb]m|tif?(f)|webp|xpm|xwd|?(e)ps|pdf|dvi|txt|svg?(z)|cdr|[ot]tf' } && -complete -F _fbi fbi + complete -F _fbi fbi # ex: filetype=sh diff --git a/completions/feh b/completions/feh index 71e59798..f1d4b18a 100644 --- a/completions/feh +++ b/completions/feh @@ -6,22 +6,22 @@ _feh() _init_completion -s || return case "$prev" in - --image-bg|-B) - COMPREPLY=( $(compgen -W 'checks white black' -- "$cur") ) + --image-bg | -B) + COMPREPLY=($(compgen -W 'checks white black' -- "$cur")) return ;; - --filelist|--output|--output-only|--start-at|-!(-*)[foO\|]) + --filelist | --output | --output-only | --start-at | -!(-*)[foO\|]) _filedir return ;; - --caption-path|--fontpath|--output-dir|-!(-*)[KCj]) + --caption-path | --fontpath | --output-dir | -!(-*)[KCj]) _filedir -d return ;; - --font|--menu-font|--title-font|-!(-*)[eM@]) + --font | --menu-font | --title-font | -!(-*)[eM@]) # expect string like "dejavu.ttf/12" - if [[ "$cur" == */* ]]; then # expect integer value - COMPREPLY=( $(compgen -P "$cur" -W '{0..9}') ) + if [[ $cur == */* ]]; then # expect integer value + COMPREPLY=($(compgen -P "$cur" -W '{0..9}')) compopt -o nospace return fi @@ -29,69 +29,72 @@ _feh() # font_path="$(imlib2-config --prefix 2>/dev/null)/share/imlib2/data/fonts" # COMPREPLY=( $(cd "$font_path" 2>/dev/null; compgen -f \ # -X "!*.@([tT][tT][fF])" -S / -- "$cur") ) - for (( i=${#words[@]}-1; i>0; i-- )); do + for ((i = ${#words[@]} - 1; i > 0; i--)); do if [[ ${words[i]} == -@(C|-fontpath) ]]; then - font_path="${words[i+1]}" - COMPREPLY+=( $(cd "$font_path" 2>/dev/null; compgen -f \ - -X "!*.@([tT][tT][fF])" -S / -- "$cur") ) + font_path="${words[i + 1]}" + COMPREPLY+=($( + cd "$font_path" 2>/dev/null + compgen -f \ + -X "!*.@([tT][tT][fF])" -S / -- "$cur" + )) fi done compopt -o nospace return ;; - --theme|-!(-*)T) + --theme | -!(-*)T) local conf_path=~/.config/feh/themes local theme_name theme_opts [[ -r $conf_path ]] || return while read theme_name theme_opts; do - if [[ "$theme_name" == '#'* || "$theme_name" == "" ]]; then + if [[ $theme_name == '#'* || $theme_name == "" ]]; then continue fi - COMPREPLY+=( $(compgen -W "$theme_name" -- "$cur") ) + COMPREPLY+=($(compgen -W "$theme_name" -- "$cur")) done <"$conf_path" return ;; - --sort|-!(-*)S) - COMPREPLY=( $(compgen -W 'name filename mtime width height - pixels size format' -- "$cur") ) + --sort | -!(-*)S) + COMPREPLY=($(compgen -W 'name filename mtime width height + pixels size format' -- "$cur")) return ;; - --reload|--limit-height|--limit-width|--thumb-height|--thumb-width|\ - --thumb-redraw|--magick-timeout|-!(-*)[RHWEyJ]) + --reload | --limit-height | --limit-width | --thumb-height | --thumb-width | \ + --thumb-redraw | --magick-timeout | -!(-*)[RHWEyJ]) # expect integer value - COMPREPLY+=( $(compgen -W '{0..9}') ) + COMPREPLY+=($(compgen -W '{0..9}')) compopt -o nospace return ;; --zoom) # expect integer value or "max", "fill" - COMPREPLY=( $(compgen -W 'max fill' -- "$cur") ) - if [[ ! $cur || ! $COMPREPLY ]]; then - COMPREPLY+=( $(compgen -W '{0..9}') ) + COMPREPLY=($(compgen -W 'max fill' -- "$cur")) + if [[ ! $cur || ! ${COMPREPLY-} ]]; then + COMPREPLY+=($(compgen -W '{0..9}')) compopt -o nospace fi return ;; - --alpha|-!(-*)a) - COMPREPLY=( $(compgen -W '{0..255}' -- "$cur") ) + --alpha | -!(-*)a) + COMPREPLY=($(compgen -W '{0..255}' -- "$cur")) return ;; - --bg|-!(-*)b) + --bg | -!(-*)b) _filedir - COMPREPLY+=( $(compgen -W 'trans' -- "$cur") ) + COMPREPLY+=($(compgen -W 'trans' -- "$cur")) return ;; - --geometry|--max-dimension|--min-dimension|-!(-*)g) + --geometry | --max-dimension | --min-dimension | -!(-*)g) # expect string like 640x480 - if [[ $cur && "$cur" != *x* ]]; then - COMPREPLY=( x ) + if [[ $cur && $cur != *x* ]]; then + COMPREPLY=(x) fi - COMPREPLY+=( $(compgen -W "{0..9}") ) + COMPREPLY+=($(compgen -W "{0..9}")) compopt -o nospace return ;; - --customlist|--index-info|--info|--slideshow-delay|--thumb-title|\ - --title|-!(-*)[LD~^]) + --customlist | --index-info | --info | --slideshow-delay | --thumb-title | \ + --title | -!(-*)[LD~^]) # argument required but no completions available return ;; @@ -99,17 +102,19 @@ _feh() $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # Some versions of feh just output "See 'man feh'" for --help :( - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - [[ $COMPREPLY ]] && return + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + if [[ ${COMPREPLY-} ]]; then + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi fi # FIXME: It is hard to determine correct supported extensions. # feh can handle any format that imagemagick can plus some others _filedir 'xpm|tif?(f)|png|p[npgba]m|iff|?(i)lbm|jp?(e)g|jfi?(f)|gif|bmp|arg?(b)|tga|xcf|ani|ico|?(e)ps|pdf|dvi|txt|svg?(z)|cdr|[ot]tf' } && -complete -F _feh feh + complete -F _feh feh # ex: filetype=sh diff --git a/completions/file b/completions/file index 494c7866..21fbd161 100644 --- a/completions/file +++ b/completions/file @@ -6,27 +6,27 @@ _file() _init_completion || return case $prev in - --help|--version|--separator|-!(-*)[vF]) + --help | --version | --separator | -!(-*)[vF]) return ;; - --magic-file|--files-from|-!(-*)[mf]) + --magic-file | --files-from | -!(-*)[mf]) _filedir return ;; - --exclude|-!(-*)e) - COMPREPLY=( $(compgen -W 'apptype ascii cdf compress elf encoding - soft tar text tokens troff' -- "$cur") ) + --exclude | -!(-*)e) + COMPREPLY=($(compgen -W 'apptype ascii cdf compress elf encoding + soft tar text tokens troff' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir } && -complete -F _file file + complete -F _file file # ex: filetype=sh diff --git a/completions/file-roller b/completions/file-roller index bebf04ee..1d223fd4 100644 --- a/completions/file-roller +++ b/completions/file-roller @@ -8,19 +8,19 @@ _file_roller() 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|-!(-*)'?') + --help | --help-all | --help-gtk | --help-sm-client | -!(-*)'?') return ;; --sm-client-state-file) _filedir return ;; - --add-to|-!(-*)a) + --add-to | -!(-*)a) _filedir_xspec unzip _filedir "$exts" return ;; - --extract-to|--default-dir|-!(-*)e) + --extract-to | --default-dir | -!(-*)e) _filedir -d return ;; @@ -29,14 +29,14 @@ _file_roller() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir_xspec unzip _filedir "$exts" } && -complete -F _file_roller file-roller + complete -F _file_roller file-roller # ex: filetype=sh diff --git a/completions/filefrag b/completions/filefrag index b8b51e3c..d26e8c8a 100644 --- a/completions/filefrag +++ b/completions/filefrag @@ -5,13 +5,13 @@ _filefrag() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi _filedir } && -complete -F _filefrag filefrag + complete -F _filefrag filefrag # ex: filetype=sh diff --git a/completions/filesnarf b/completions/filesnarf index 01766555..f959d80f 100644 --- a/completions/filesnarf +++ b/completions/filesnarf @@ -12,11 +12,11 @@ _snarf() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) fi } && -complete -F _snarf filesnarf mailsnarf msgsnarf + complete -F _snarf filesnarf mailsnarf msgsnarf # ex: filetype=sh diff --git a/completions/find b/completions/find index 80fbe8c0..64121eda 100644 --- a/completions/find +++ b/completions/find @@ -7,20 +7,28 @@ _find() local cur prev words cword _init_completion || return + local i + for i in ${!words[*]}; do + if [[ ${words[i]} == -@(exec|ok)?(dir) ]]; then + _command_offset $((i + 1)) + return + fi + done + case $prev in - -maxdepth|-mindepth) - COMPREPLY=( $(compgen -W '{0..9}' -- "$cur") ) + -maxdepth | -mindepth) + COMPREPLY=($(compgen -W '{0..9}' -- "$cur")) return ;; - -newer|-anewer|-cnewer|-fls|-fprint|-fprint0|-fprintf|-name|-iname|\ - -lname|-ilname|-wholename|-iwholename|-samefile) + -newer | -anewer | -cnewer | -fls | -fprint | -fprint0 | -fprintf | -name | -[il]name | \ + -ilname | -wholename | -[il]wholename | -samefile) _filedir return ;; -fstype) _fstypes - [[ $OSTYPE == *bsd* ]] && \ - COMPREPLY+=( $(compgen -W 'local rdonly' -- "$cur") ) + [[ $OSTYPE == *bsd* ]] && + COMPREPLY+=($(compgen -W 'local rdonly' -- "$cur")) return ;; -gid) @@ -28,11 +36,11 @@ _find() return ;; -group) - COMPREPLY=( $(compgen -g -- "$cur" 2>/dev/null) ) + COMPREPLY=($(compgen -g -- "$cur" 2>/dev/null)) return ;; - -xtype|-type) - COMPREPLY=( $(compgen -W 'b c d p f l s' -- "$cur") ) + -xtype | -type) + COMPREPLY=($(compgen -W 'b c d p f l s' -- "$cur")) return ;; -uid) @@ -40,24 +48,17 @@ _find() return ;; -user) - COMPREPLY=( $(compgen -u -- "$cur") ) - return - ;; - -exec|-execdir|-ok|-okdir) - words=(words[0] "$cur") - cword=1 - _command + COMPREPLY=($(compgen -u -- "$cur")) return ;; - -[acm]min|-[acm]time|-iname|-lname|-wholename|-iwholename|-lwholename|\ - -ilwholename|-inum|-path|-ipath|-regex|-iregex|-links|-perm|-size|\ - -used|-printf|-context) + -[acm]min | -[acm]time | -inum | -path | -ipath | -regex | -iregex | -links | -perm | \ + -size | -used | -printf | -context) # do nothing, just wait for a parameter to be given return ;; -regextype) - COMPREPLY=( $(compgen -W 'emacs posix-awk posix-basic posix-egrep - posix-extended' -- "$cur") ) + COMPREPLY=($(compgen -W 'emacs posix-awk posix-basic posix-egrep + posix-extended' -- "$cur")) return ;; esac @@ -65,17 +66,17 @@ _find() local i exprfound=false # set exprfound to true if there is already an expression present for i in "${words[@]}"; do - [[ "$i" == [-\(\),\!]* ]] && exprfound=true && break + [[ $i == [-\(\),\!]* ]] && exprfound=true && break done # handle case where first parameter is not a dash option - if ! $exprfound && [[ "$cur" != [-\(\),\!]* ]]; then + if ! $exprfound && [[ $cur != [-\(\),\!]* ]]; then _filedir -d return fi # complete using basic options - COMPREPLY=( $(compgen -W '-daystart -depth -follow -help + COMPREPLY=($(compgen -W '-daystart -depth -follow -help -ignore_readdir_race -maxdepth -mindepth -mindepth -mount -noignore_readdir_race -noleaf -regextype -version -warn -nowarn -xdev -amin -anewer -atime -cmin -cnewer -ctime -empty -executable -false @@ -84,22 +85,22 @@ _find() -readable -regex -samefile -size -true -type -uid -used -user -wholename -writable -xtype -context -delete -exec -execdir -fls -fprint -fprint0 -fprintf -ls -ok -okdir -print -print0 -printf -prune - -quit' -- "$cur") ) + -quit' -- "$cur")) - if [[ ${#COMPREPLY[@]} -ne 0 ]]; then + if ((${#COMPREPLY[@]} != 0)); then # this removes any options from the list of completions that have # already been specified somewhere on the command line, as long as # these options can only be used once (in a word, "options", in # opposition to "tests" and "actions", as in the find(1) manpage). - local -A onlyonce=( [-daystart]=1 [-depth]=1 [-follow]=1 [-help]=1 + local -A onlyonce=([-daystart]=1 [-depth]=1 [-follow]=1 [-help]=1 [-ignore_readdir_race]=1 [-maxdepth]=1 [-mindepth]=1 [-mount]=1 [-noignore_readdir_race]=1 [-noleaf]=1 [-nowarn]=1 [-regextype]=1 - [-version]=1 [-warn]=1 [-xdev]=1 ) + [-version]=1 [-warn]=1 [-xdev]=1) local j for i in "${words[@]}"; do - [[ $i && ${onlyonce[$i]} ]] || continue + [[ $i && -v onlyonce["$i"] ]] || continue for j in "${!COMPREPLY[@]}"; do - [[ ${COMPREPLY[j]} == $i ]] && unset 'COMPREPLY[j]' + [[ ${COMPREPLY[j]} == "$i" ]] && unset 'COMPREPLY[j]' done done fi @@ -107,6 +108,6 @@ _find() _filedir } && -complete -F _find find + complete -F _find find # ex: filetype=sh diff --git a/completions/find_member b/completions/find_member index 720e3074..cf30c70d 100644 --- a/completions/find_member +++ b/completions/find_member @@ -6,7 +6,7 @@ _find_member() _init_completion -s || return case $prev in - -l|-x|--listname|--exclude) + -l | -x | --listname | --exclude) _xfunc list_lists _mailman_lists return ;; @@ -14,12 +14,12 @@ _find_member() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--listname --exclude --owners --help' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--listname --exclude --owners --help' \ + -- "$cur")) fi } && -complete -F _find_member find_member + complete -F _find_member find_member # ex: filetype=sh diff --git a/completions/fio b/completions/fio index 7710cf6b..f81a4da7 100644 --- a/completions/fio +++ b/completions/fio @@ -6,28 +6,29 @@ _fio() _init_completion -s || return case $prev in - --help|--version) + --help | --version) return ;; --debug) - local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $(compgen -W "process file io mem blktrace verify + local prefix= + [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=($(compgen -W "process file io mem blktrace verify random parse diskutil job mutex profile time net rate compress - steadystate helperthread" -- "${cur##*,}") ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + steadystate helperthread" -- "${cur##*,}")) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) return ;; --output-format) - COMPREPLY=( $(compgen -W "terse json json+ normal" -- "$cur") ) + COMPREPLY=($(compgen -W "terse json json+ normal" -- "$cur")) return ;; --terse-version) - COMPREPLY=( $(compgen -W "2 3" -- "$cur") ) + COMPREPLY=($(compgen -W "2 3" -- "$cur")) return ;; --cmdhelp) # TODO more commands? - COMPREPLY=( $(compgen -W "all" -- "$cur") ) + COMPREPLY=($(compgen -W "all" -- "$cur")) return ;; --enghelp) @@ -36,7 +37,7 @@ _fio() return ;; --eta) - COMPREPLY=( $(compgen -W "always never auto" -- "$cur") ) + COMPREPLY=($(compgen -W "always never auto" -- "$cur")) return ;; --daemonize) @@ -52,7 +53,7 @@ _fio() return ;; --idle-prof) - COMPREPLY=( $(compgen -W "system percpu calibrate" -- "$cur") ) + COMPREPLY=($(compgen -W "system percpu calibrate" -- "$cur")) return ;; --inflate-log) @@ -63,9 +64,9 @@ _fio() _filedir return ;; - --trigger|--trigger-remote) + --trigger | --trigger-remote) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; --aux-path) @@ -77,13 +78,13 @@ _fio() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir job } && -complete -F _fio fio + complete -F _fio fio # ex: filetype=sh diff --git a/completions/firefox b/completions/firefox index eeaca9f6..4656f8df 100644 --- a/completions/firefox +++ b/completions/firefox @@ -8,12 +8,12 @@ _firefox() [[ $cur == -MOZ_LOG*=* ]] && prev=${cur%%=*} cur=${cur#*=} case $prev in - --help|--version|--display|--UILocale|-MOZ_LOG|--new-window|--new-tab|\ - --private-window|--window-size|--search|--start-debugger-server|\ - --recording|--debugger-args|-[hvPa]) + --help | --version | --display | --UILocale | -MOZ_LOG | --new-window | --new-tab | \ + --private-window | --window-size | --search | --start-debugger-server | \ + --recording | --debugger-args | -[hvPa]) return ;; - --profile|--screenshot) + --profile | --screenshot) _filedir -d return ;; @@ -25,8 +25,8 @@ _firefox() _filedir return ;; - --debugger|-d) - COMPREPLY=( $(compgen -c -- "$cur") ) + --debugger | -d) + COMPREPLY=($(compgen -c -- "$cur")) return ;; esac @@ -34,13 +34,13 @@ _firefox() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - _filedir "@(?([xs])htm?(l)|pdf)" + _filedir "@(?([xs])htm?(l)|pdf|txt)" } && -complete -F _firefox firefox mozilla-firefox iceweasel + complete -F _firefox firefox mozilla-firefox iceweasel # ex: filetype=sh diff --git a/completions/flake8 b/completions/flake8 index f18351e8..045c4095 100644 --- a/completions/flake8 +++ b/completions/flake8 @@ -6,22 +6,22 @@ _flake8() _init_completion -s || return case $prev in - --help|--version|-!(-*)h) + --help | --version | -!(-*)h) return ;; --format) - COMPREPLY=( $(compgen -W 'default pylint' -- "$cur") ) + COMPREPLY=($(compgen -W 'default pylint' -- "$cur")) return ;; - --jobs|-!(-*)j) - COMPREPLY=( $(compgen -W "auto {1..$(_ncpus)}" -- "$cur") ) + --jobs | -!(-*)j) + COMPREPLY=($(compgen -W "auto {1..$(_ncpus)}" -- "$cur")) return ;; - --output-file|--append-config|--config) + --output-file | --append-config | --config) _filedir return ;; - --include-in-doctest|--exclude-from-doctest) + --include-in-doctest | --exclude-from-doctest) _filedir py return ;; @@ -30,13 +30,13 @@ _flake8() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir py } && -complete -F _flake8 flake8 + complete -F _flake8 flake8 # ex: filetype=sh diff --git a/completions/freebsd-update b/completions/freebsd-update index 6ee2438b..d5be8612 100644 --- a/completions/freebsd-update +++ b/completions/freebsd-update @@ -8,7 +8,7 @@ _freebsd_update() _init_completion || return case $prev in - -b|-d) + -b | -d) _filedir -d return ;; @@ -16,14 +16,14 @@ _freebsd_update() _filedir return ;; - -k|-r|-s|-t) + -k | -r | -s | -t) return ;; esac - COMPREPLY=( $(compgen -W "fetch cron upgrade install rollback IDS" -- \ - $cur) ) + COMPREPLY=($(compgen -W "fetch cron upgrade install rollback IDS" -- \ + $cur)) } && -complete -F _freebsd_update freebsd-update + complete -F _freebsd_update freebsd-update # ex: filetype=sh diff --git a/completions/freeciv b/completions/freeciv index 0f475482..01af3118 100644 --- a/completions/freeciv +++ b/completions/freeciv @@ -6,36 +6,36 @@ _freeciv() _init_completion || return case $prev in - --help|--version|--name|--port|-[hvnp]) + --help | --version | --name | --port | -[hvnp]) return ;; - --file|--log|--music|--read|--Sound|--tiles|-[flmrSt]) + --file | --log | --music | --read | --Sound | --tiles | -[flmrSt]) _filedir return ;; - --Announce|-A) - COMPREPLY=( $(compgen -W 'IPv4 IPv6 none' -- "$cur") ) + --Announce | -A) + COMPREPLY=($(compgen -W 'IPv4 IPv6 none' -- "$cur")) return ;; - --debug|-d) - COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) + --debug | -d) + COMPREPLY=($(compgen -W '{0..3}' -- "$cur")) return ;; - --Meta|--server|-[Ms]) + --Meta | --server | -[Ms]) _known_hosts_real -- "$cur" return ;; - --Plugin|-P) - COMPREPLY=( $(compgen -W 'none esd sdl' -- "$cur") ) + --Plugin | -P) + COMPREPLY=($(compgen -W 'none esd sdl' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _freeciv freeciv{,-{gtk{2,3},sdl,xaw}} civclient + complete -F _freeciv freeciv{,-{gtk{2,3},sdl,xaw}} civclient # ex: filetype=sh diff --git a/completions/freeciv-server b/completions/freeciv-server index 08f63158..a34b5a29 100644 --- a/completions/freeciv-server +++ b/completions/freeciv-server @@ -6,17 +6,17 @@ _civserver() _init_completion || return case $prev in - -f|-g|-l|-r|--file|--log|--gamelog|--read) + -f | -g | -l | -r | --file | --log | --gamelog | --read) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _civserver civserver freeciv-server + complete -F _civserver civserver freeciv-server # ex: filetype=sh diff --git a/completions/function b/completions/function index a97b5255..6ae52718 100644 --- a/completions/function +++ b/completions/function @@ -8,30 +8,30 @@ _function() if [[ $1 == @(declare|typeset) ]]; then if [[ $cur == [-+]* ]]; then local opts - opts=( $(_parse_usage "$1") ) + opts=($(_parse_usage "$1")) # Most options also have a '+' form. We'll exclude the ones that don't with compgen. - opts+=( ${opts[*]/-/+} ) - COMPREPLY=( $(compgen -W "${opts[*]}" -X '+[Ffgp]' -- "$cur") ) + opts+=(${opts[*]/-/+}) + COMPREPLY=($(compgen -W "${opts[*]}" -X '+[Ffgp]' -- "$cur")) else local i=1 while [[ ${words[i]} == [-+]* ]]; do if [[ ${words[i]} == -*[fF]* ]]; then - COMPREPLY=( $(compgen -A function -- "$cur") ) + COMPREPLY=($(compgen -A function -- "$cur")) return fi ((i++)) done - if [[ $i -gt 1 ]]; then + if ((i > 1)); then # There was at least one option and it was not one that limited operations to functions - COMPREPLY=( $(compgen -A variable -- "$cur") ) + COMPREPLY=($(compgen -A variable -- "$cur")) fi fi - elif [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -A function -- "$cur") ) + elif ((cword == 1)); then + COMPREPLY=($(compgen -A function -- "$cur")) else - COMPREPLY=( "() $(type -- ${words[1]} | command sed -e 1,2d)" ) + COMPREPLY=("() $(type -- ${words[1]} | command sed -e 1,2d)") fi } && -complete -F _function function declare typeset + complete -F _function function declare typeset # ex: filetype=sh diff --git a/completions/fusermount b/completions/fusermount index c40c18ce..7e489225 100644 --- a/completions/fusermount +++ b/completions/fusermount @@ -10,19 +10,19 @@ _fusermount() return ;; -*u) - COMPREPLY=( $(compgen -W "$(awk \ + COMPREPLY=($(compgen -W "$(awk \ '{ if ($3 ~ /^fuse(\.|$)/) print $2 }' /etc/mtab \ - 2>/dev/null)" -- "$cur") ) + 2>/dev/null)" -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) else _filedir -d fi } && -complete -F _fusermount fusermount + complete -F _fusermount fusermount # ex: filetype=sh diff --git a/completions/gcc b/completions/gcc index 86d0d095..fa952741 100644 --- a/completions/gcc +++ b/completions/gcc @@ -8,13 +8,13 @@ _gcc() # Test that GCC is recent enough and if not fallback to # parsing of --completion option. if ! $1 --completion=" " 2>/dev/null; then - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local cc=$($1 -print-prog-name=cc1 2>/dev/null) [[ $cc ]] || return - COMPREPLY=($( compgen -W "$($cc --help 2>/dev/null | tr '\t' ' ' |\ + COMPREPLY=($(compgen -W "$($cc --help 2>/dev/null | tr '\t' ' ' | command sed -e '/^ *-/!d' -e 's/ *-\([^][ <>]*\).*/-\1/')" \ - -- "$cur" )) - [[ $COMPREPLY == *= ]] && compopt -o nospace + -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir fi @@ -22,54 +22,54 @@ _gcc() fi # extract also for situations like: -fsanitize=add - if [[ $cword -gt 2 ]]; then - prev2="${COMP_WORDS[$cword - 2]}" + if ((cword > 2)); then + prev2="${COMP_WORDS[cword - 2]}" fi # sample: -fsan - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then argument=$cur prefix="" # sample: -fsanitize= - elif [[ "$cur" == "=" && $prev == -* ]]; then + elif [[ $cur == "=" && $prev == -* ]]; then argument=$prev$cur prefix=$prev$cur # sample: -fsanitize=add - elif [[ "$prev" == "=" && $prev2 == -* ]]; then + elif [[ $prev == "=" && $prev2 == -* ]]; then argument=$prev2$prev$cur prefix=$prev2$prev # sample: --param lto- - elif [[ "$prev" == --param ]]; then + elif [[ $prev == --param ]]; then argument="$prev $cur" prefix="$prev " fi - if [[ -z $argument ]]; then + if [[ ! -v argument ]]; then _filedir else # In situation like '-fsanitize=add' $cur is equal to last token. # Thus we need to strip the beginning of suggested option. - prefix_length=$((${#prefix}+1)) + prefix_length=$((${#prefix} + 1)) local flags=$($1 --completion="$argument" | cut -c $prefix_length-) - [[ "${flags}" == "=*" ]] && compopt -o nospace 2>/dev/null - COMPREPLY=( $(compgen -W "$flags" -- "") ) + [[ ${flags} == "=*" ]] && compopt -o nospace 2>/dev/null + COMPREPLY=($(compgen -W "$flags" -- "")) fi } && -complete -F _gcc gcc{,-5,-6,-7,-8} g++{,-5,-6,-7,-8} g77 g95 \ - gccgo{,-5,-6,-7,-8} gcj gfortran{,-5,-6,-7,-8} gpc && -{ - cc --version 2>/dev/null | command grep -q GCC || \ - [[ $(_realcommand cc) == *gcc* ]] && \ - complete -F _gcc cc || complete -F _minimal cc - c++ --version 2>/dev/null | command grep -q GCC || \ - [[ $(_realcommand c++) == *g++* ]] && \ - complete -F _gcc c++ || complete -F _minimal c++ - f77 --version 2>/dev/null | command grep -q GCC || \ - [[ $(_realcommand f77) == *gfortran* ]] && \ - complete -F _gcc f77 || complete -F _minimal f77 - f95 --version 2>/dev/null | command grep -q GCC || \ - [[ $(_realcommand f95) == *gfortran* ]] && \ - complete -F _gcc f95 || complete -F _minimal f95 -} + complete -F _gcc gcc{,-5,-6,-7,-8} g++{,-5,-6,-7,-8} g77 g95 \ + gccgo{,-5,-6,-7,-8} gcj gfortran{,-5,-6,-7,-8} gpc && + { + cc --version 2>/dev/null | command grep -q GCC || + [[ $(_realcommand cc) == *gcc* ]] && + complete -F _gcc cc || complete -F _minimal cc + c++ --version 2>/dev/null | command grep -q GCC || + [[ $(_realcommand c++) == *g++* ]] && + complete -F _gcc c++ || complete -F _minimal c++ + f77 --version 2>/dev/null | command grep -q GCC || + [[ $(_realcommand f77) == *gfortran* ]] && + complete -F _gcc f77 || complete -F _minimal f77 + f95 --version 2>/dev/null | command grep -q GCC || + [[ $(_realcommand f95) == *gfortran* ]] && + complete -F _gcc f95 || complete -F _minimal f95 + } # ex: filetype=sh diff --git a/completions/gcl b/completions/gcl index 9acc813d..73a18b2d 100644 --- a/completions/gcl +++ b/completions/gcl @@ -8,14 +8,14 @@ _gcl() _init_completion || return # completing an option (may or may not be separated by a space) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-eval -load -f -batch -dir -libdir -compile - -o-file -c-file -h-file -data-file -system-p' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-eval -load -f -batch -dir -libdir -compile + -o-file -c-file -h-file -data-file -system-p' -- "$cur")) else _filedir fi } && -complete -F _gcl -o default gcl + complete -F _gcl -o default gcl # ex: filetype=sh diff --git a/completions/gdb b/completions/gdb index b37387e1..f78f8a57 100644 --- a/completions/gdb +++ b/completions/gdb @@ -6,41 +6,42 @@ _gdb() _init_completion || return # gdb [options] --args executable-file [inferior-arguments ...] - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == --args ]]; then - _command_offset $((i+1)) + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == --args ]]; then + _command_offset $((i + 1)) return $? fi done # gdb [options] [executable-file [core-file or process-id]] - if [[ $cword -eq 1 ]]; then + if ((cword == 1)); then local IFS compopt -o filenames - if [[ "$cur" == */* ]]; then + if [[ $cur == */* ]]; then # compgen -c works as expected if $cur contains any slashes. IFS=$'\n' - COMPREPLY=( $(PATH="$PATH:." compgen -d -c -- "$cur") ) + COMPREPLY=($(PATH="$PATH:." compgen -d -c -- "$cur")) else # otherwise compgen -c contains Bash's built-in commands, # functions and aliases. Thus we need to retrieve the program # names manually. IFS=":" - local path_array=( $(\ - command sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH") ) + local path_array=($( + command sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH" + )) IFS=$'\n' - COMPREPLY=( $(compgen -d -W '$(find "${path_array[@]}" . \ + COMPREPLY=($(compgen -d -W '$(find "${path_array[@]}" . \ -mindepth 1 -maxdepth 1 -not -type d -executable \ - -printf "%f\\n" 2>/dev/null)' -- "$cur") ) + -printf "%f\\n" 2>/dev/null)' -- "$cur")) fi - elif [[ $cword -eq 2 ]]; then - COMPREPLY=( $(compgen -W "$(command ps axo comm,pid | \ - awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}')" -- "$cur") ) + elif ((cword == 2)); then + COMPREPLY=($(compgen -W "$(command ps axo comm,pid | + awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}')" -- "$cur")) compopt -o filenames - COMPREPLY+=( $(compgen -f -X '!?(*/)core?(.?*)' -o plusdirs \ - -- "$cur") ) + COMPREPLY+=($(compgen -f -X '!?(*/)core?(.?*)' -o plusdirs \ + -- "$cur")) fi } && -complete -F _gdb gdb + complete -F _gdb gdb # ex: filetype=sh diff --git a/completions/genaliases b/completions/genaliases index 3bad5c7e..5953b9ef 100644 --- a/completions/genaliases +++ b/completions/genaliases @@ -5,11 +5,11 @@ _genaliases() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--quiet --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--quiet --help' -- "$cur")) fi } && -complete -F _genaliases genaliases + complete -F _genaliases genaliases # ex: filetype=sh diff --git a/completions/gendiff b/completions/gendiff index cb9bab39..d37793f6 100644 --- a/completions/gendiff +++ b/completions/gendiff @@ -5,8 +5,8 @@ _gendiff() local cur prev words cword _init_completion -o '@(diff|patch)' || return - [[ $cword -eq 1 ]] && _filedir -d + ((cword == 1)) && _filedir -d } && -complete -F _gendiff gendiff + complete -F _gendiff gendiff # ex: filetype=sh diff --git a/completions/genisoimage b/completions/genisoimage index 52b66bbe..dfa39c0a 100644 --- a/completions/genisoimage +++ b/completions/genisoimage @@ -6,14 +6,14 @@ _mkisofs() _init_completion || return case $prev in - -o|-abstract|-biblio|-check-session|-copyright|-log-file| \ - -root-info|-prep-boot|-*-list) + -o | -abstract | -biblio | -check-session | -copyright | -log-file | \ + -root-info | -prep-boot | -*-list) _filedir return ;; -*-charset) - COMPREPLY=( $(compgen -W '$(mkisofs -input-charset \ - help 2>&1 | tail -n +3)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(mkisofs -input-charset \ + help 2>&1 | tail -n +3)' -- "$cur")) return ;; -uid) @@ -26,13 +26,13 @@ _mkisofs() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) else _filedir fi } && -complete -F _mkisofs mkisofs genisoimage + complete -F _mkisofs mkisofs genisoimage # ex: filetype=sh diff --git a/completions/geoiplookup b/completions/geoiplookup index 8347728f..c60be898 100644 --- a/completions/geoiplookup +++ b/completions/geoiplookup @@ -6,7 +6,7 @@ _geoiplookup() _init_completion || return case $prev in - -h|-'?'|-v) + -h | -'?' | -v) return ;; -d) @@ -20,7 +20,7 @@ _geoiplookup() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" -h)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h)' -- "$cur")) return fi @@ -28,6 +28,6 @@ _geoiplookup() [[ $1 == *6 ]] && ipvx=-6 || ipvx=-4 _known_hosts_real $ipvx -- "$cur" } && -complete -F _geoiplookup geoiplookup geoiplookup6 + complete -F _geoiplookup geoiplookup geoiplookup6 # ex: filetype=sh diff --git a/completions/getconf b/completions/getconf index 6e86e9de..de1ad2d6 100644 --- a/completions/getconf +++ b/completions/getconf @@ -11,22 +11,22 @@ _getconf() return ;; -v) - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ '$("$1" -a 2>/dev/null | awk "{ print \$1 }")' -- \ - "${cur:-POSIX_V}") ) + "${cur:-POSIX_V}")) return ;; esac - if [[ $prev == PATH_MAX ]]; then # TODO more path vars, better handling + if [[ $prev == PATH_MAX ]]; then # TODO more path vars, better handling _filedir elif [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-a -v' -- "$cur") ) + COMPREPLY=($(compgen -W '-a -v' -- "$cur")) else - COMPREPLY=( $(compgen -W \ - '$("$1" -a 2>/dev/null | awk "{ print \$1 }")' -- "$cur") ) + COMPREPLY=($(compgen -W \ + '$("$1" -a 2>/dev/null | awk "{ print \$1 }")' -- "$cur")) fi } && -complete -F _getconf getconf + complete -F _getconf getconf # ex: filetype=sh diff --git a/completions/getent b/completions/getent index 9a181f60..4c54a242 100644 --- a/completions/getent +++ b/completions/getent @@ -6,16 +6,16 @@ _getent() _init_completion -s || return local i db - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in - --version|--usage|--help|-!(-*)[V?]) + --version | --usage | --help | -!(-*)[V?]) return ;; - --service|-!(-*)s) - (( i++ )) - ;; - -*) + --service | -!(-*)s) + ((i++)) ;; + -*) ;; + *) # First non-option value is the db db=${words[i]} @@ -24,39 +24,39 @@ _getent() esac done - case $db in + case ${db-} in passwd) - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) return ;; group) - COMPREPLY=( $(compgen -g -- "$cur") ) + COMPREPLY=($(compgen -g -- "$cur")) return ;; services) - COMPREPLY=( $(compgen -s -- "$cur") ) + COMPREPLY=($(compgen -s -- "$cur")) return ;; hosts) - COMPREPLY=( $(compgen -A hostname -- "$cur") ) + COMPREPLY=($(compgen -A hostname -- "$cur")) return ;; - protocols|networks|ahosts|ahostsv4|ahostsv6|rpc) - COMPREPLY=( $(compgen -W "$($1 $db | \ - awk '{ print $1 }')" -- "$cur") ) + protocols | networks | ahosts | ahostsv4 | ahostsv6 | rpc) + COMPREPLY=($(compgen -W "$($1 $db | + awk '{ print $1 }')" -- "$cur")) return ;; - aliases|shadow|gshadow) - COMPREPLY=( $(compgen -W "$($1 $db | cut -d: -f1)" -- "$cur") ) + aliases | shadow | gshadow) + COMPREPLY=($(compgen -W "$($1 $db | cut -d: -f1)" -- "$cur")) return ;; - ethers|netgroup) + ethers | netgroup) return ;; esac case $prev in - -s|--service) + -s | --service) return ;; esac @@ -64,14 +64,14 @@ _getent() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - elif [[ -z $db ]]; then - COMPREPLY=( $(compgen -W 'passwd group hosts services protocols + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace + elif [[ ! -v db ]]; then + COMPREPLY=($(compgen -W 'passwd group hosts services protocols networks ahosts ahostsv4 ahostsv6 aliases ethers netgroup rpc - shadow gshadow' -- "$cur") ) + shadow gshadow' -- "$cur")) fi } && -complete -F _getent getent + complete -F _getent getent # ex: filetype=sh diff --git a/completions/gkrellm b/completions/gkrellm index 9eb76bcb..c38c5ae1 100644 --- a/completions/gkrellm +++ b/completions/gkrellm @@ -6,34 +6,34 @@ _gkrellm() _init_completion || return case $prev in - -t|--theme) + -t | --theme) _filedir -d return ;; - -p|--plugin) + -p | --plugin) _filedir so return ;; - -s|--server) + -s | --server) _known_hosts_real -- "$cur" return ;; - -l|--logfile) + -l | --logfile) _filedir return ;; - -g|--geometry|-c|--config|-P|--port|-d|--debug-level) + -g | --geometry | -c | --config | -P | --port | -d | --debug-level) # Argument required but no completions available return ;; - -h|--help|-v|--version) + -h | --help | -v | --version) # All other options are noop with these return ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _gkrellm gkrellm gkrellm2 + complete -F _gkrellm gkrellm gkrellm2 # ex: filetype=sh diff --git a/completions/gm b/completions/gm index 4ea4f3e9..b86c9cc3 100644 --- a/completions/gm +++ b/completions/gm @@ -2,8 +2,8 @@ _gm_commands() { - COMPREPLY+=( $(compgen -W '$("$1" help | - awk "/^ +[^ ]+ +- / { print \$1 }")' -- "$cur") ) + COMPREPLY+=($(compgen -W '$("$1" help | + awk "/^ +[^ ]+ +- / { print \$1 }")' -- "$cur")) } _gm() @@ -11,7 +11,7 @@ _gm() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then + if ((cword == 1)); then _gm_commands "$1" return elif [[ $cword -eq 2 && ${words[1]} == time ]]; then @@ -35,6 +35,6 @@ _gm() # TODO... defer some commnds to the imagemagick "gm"less completions etc? compopt -o default } && -complete -F _gm gm + complete -F _gm gm # ex: filetype=sh diff --git a/completions/gnatmake b/completions/gnatmake index 383bb9b4..5f4b9639 100644 --- a/completions/gnatmake +++ b/completions/gnatmake @@ -6,21 +6,21 @@ _gnatmake() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # relevant (and less relevant ;-) )options completion - COMPREPLY=( $(compgen -W '-a -c -f -i -j -k -m -M -n -o -q -s -v -z + COMPREPLY=($(compgen -W '-a -c -f -i -j -k -m -M -n -o -q -s -v -z -aL -A -aO -aI -I -I- -L -nostdinc -nostdlib -cargs -bargs -largs -fstack-check -fno-inline -g -O1 -O0 -O2 -O3 -gnata -gnatA -gnatb -gnatc -gnatd -gnatD -gnate -gnatE -gnatf -gnatF -gnatg -gnatG -gnath -gnati -gnatk -gnatl -gnatL -gnatm -gnatn -gnato -gnatO -gnatp -gnatP -gnatq -gnatR -gnats -gnatt -gnatT -gnatu -gnatU -gnatv -gnatws -gnatwe -gnatwl -gnatwu -gnatW -gnatx -gnatX -gnaty - -gnatz -gnatZ -gnat83' -- "$cur") ) + -gnatz -gnatZ -gnat83' -- "$cur")) else # source file completion _filedir '@(adb|ads)' fi } && -complete -F _gnatmake gnatmake + complete -F _gnatmake gnatmake # ex: filetype=sh diff --git a/completions/gnokii b/completions/gnokii index ff43c3d1..039141ae 100644 --- a/completions/gnokii +++ b/completions/gnokii @@ -3,7 +3,7 @@ _gnokii_memory_type() { # TODO: reduce the number of choices - COMPREPLY=( $(compgen -W "IN OU SM ME MT" -- "$cur") ) + COMPREPLY=($(compgen -W "IN OU SM ME MT" -- "$cur")) } _gnokii() @@ -20,123 +20,123 @@ _gnokii() local config_file for config_file in "$XDG_CONFIG_HOME/gnokii/config" \ "$HOME/.config/gnokii/config" "$HOME/.gnokiirc" \ - "$XDG_CONFIG_DIRS/gnokii/config" /etc/gnokiirc ; do + "$XDG_CONFIG_DIRS/gnokii/config" /etc/gnokiirc; do [[ -f $config_file ]] && break done [[ ! -f $config_file ]] && return - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ "$(command sed -n 's/^\[phone_\(.*\)\]/\1/p' $config_file)" \ - -- "$cur") ) + -- "$cur")) return ;; --help) - COMPREPLY=( $(compgen -W 'all monitor sms mms phonebook calendar + COMPREPLY=($(compgen -W 'all monitor sms mms phonebook calendar todo dial profile settings wap logo ringtone security file - other' -- "$cur") ) + other' -- "$cur")) return ;; - --version|--shell|ping) + --version | --shell | ping) return ;; # MONITOR --monitor) - COMPREPLY=( $(compgen -W 'delay once' -- "$cur") ) + COMPREPLY=($(compgen -W 'delay once' -- "$cur")) return ;; - --getdisplaystatus|--displayoutput) + --getdisplaystatus | --displayoutput) return ;; --netmonitor) - COMPREPLY=( $(compgen -W 'reset off field devel next nr' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'reset off field devel next nr' \ + -- "$cur")) return ;; # SMS --sendsms) - # (how)TODO ? + # (how)TODO ? return ;; --savesms) - COMPREPLY=( $(compgen -W '--sender --smsc --smscno --folder - --location --sent --read --deliver --datetime' -- "$cur") ) + COMPREPLY=($(compgen -W '--sender --smsc --smscno --folder + --location --sent --read --deliver --datetime' -- "$cur")) return ;; - --memory-type|--memory|--getsms|--deletesms|--getmms|--deletemms|\ - --getphonebook|--deletephonebook) + --memory-type | --memory | --getsms | --deletesms | --getmms | --deletemms | \ + --getphonebook | --deletephonebook) _gnokii_memory_type return ;; - --getsmsc|--getcalendarnote|--deletecalendarnote|--gettodo|\ - --getspeeddial) + --getsmsc | --getcalendarnote | --deletecalendarnote | --gettodo | \ + --getspeeddial) # TODO: grab a specific entry ID return ;; - --setsmsc|--smsreader|--createsmsfolder|--deletealltodos|\ - --showsmsfolderstatus) + --setsmsc | --smsreader | --createsmsfolder | --deletealltodos | \ + --showsmsfolderstatus) return ;; - --deletesmsfolder|--folder) + --deletesmsfolder | --folder) # TODO: folderid return ;; --writephonebook) - COMPREPLY=( $(compgen -W '--overwrite --find-free --memory-type - --location --vcard --ldif' -- "$cur") ) + COMPREPLY=($(compgen -W '--overwrite --find-free --memory-type + --location --vcard --ldif' -- "$cur")) return ;; - --writecalendarnote|--writetodo) + --writecalendarnote | --writetodo) _filedir vcf return ;; # DIAL - --setspeeddial|--dialvoice|--senddtmf|--answercall|--hangup) + --setspeeddial | --dialvoice | --senddtmf | --answercall | --hangup) # TODO return ;; --divert) - COMPREPLY=( $(compgen -W '--op' -- "$cur") ) + COMPREPLY=($(compgen -W '--op' -- "$cur")) return ;; # PROFILE - --getprofile|--setactiveprofile) + --getprofile | --setactiveprofile) # TODO return ;; - --setprofile|--getactiveprofile) + --setprofile | --getactiveprofile) return ;; # SETTINGS --reset) - COMPREPLY=( $(compgen -W 'soft hard' -- "$cur") ) + COMPREPLY=($(compgen -W 'soft hard' -- "$cur")) return ;; - --setdatetime|--setalarm) + --setdatetime | --setalarm) # TODO return ;; - --getdatetime|--getalarm) + --getdatetime | --getalarm) return ;; # WAP - --getwapbookmark|--writewapbookmark|--deletewapbookmark|\ - --getwapsetting|--writewapsetting|--activatewapsetting) + --getwapbookmark | --writewapbookmark | --deletewapbookmark | \ + --getwapsetting | --writewapsetting | --activatewapsetting) return ;; # LOGOS --sendlogo) - COMPREPLY=( $(compgen -W 'caller op picture' -- "$cur") ) + COMPREPLY=($(compgen -W 'caller op picture' -- "$cur")) return ;; - --setlogo|--getlogo) - COMPREPLY=( $(compgen -W 'op startup caller dealer text' \ - -- "$cur") ) + --setlogo | --getlogo) + COMPREPLY=($(compgen -W 'op startup caller dealer text' \ + -- "$cur")) return ;; --viewlogo) @@ -145,77 +145,79 @@ _gnokii() ;; --entersecuritycode) - COMPREPLY=( $(compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur") ) + COMPREPLY=($(compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur")) return ;; - # TODO: RINGTONES + # TODO: RINGTONES esac # second level completion - if [[ $((cword-2)) -ge 1 && ${words[cword-2]} =~ --* ]]; then - pprev=${words[cword-2]} + if [[ $((cword - 2)) -ge 1 && ${words[cword - 2]} =~ --* ]]; then + pprev=${words[cword - 2]} case $pprev in --setspeeddial) _gnokii_memory_type return ;; - --getsms|--deletesms|--getmms|--deletemms|--getphonebook|\ - --writetodo|--writecalendarnote) + --getsms | --deletesms | --getmms | --deletemms | --getphonebook | \ + --writetodo | --writecalendarnote) # TODO: start number return ;; - --gettodo|--getcalendarnote) - COMPREPLY=( $(compgen -W '{1..9} end --vCal' -- "$cur") ) + --gettodo | --getcalendarnote) + COMPREPLY=($(compgen -W '{1..9} end --vCal' -- "$cur")) return ;; --deletecalendarnote) - COMPREPLY=( $(compgen -W '{1..9} end' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..9} end' -- "$cur")) return ;; --divert) - COMPREPLY=( $(compgen -W 'register enable query disable - erasure' -- "$cur") ) + COMPREPLY=($(compgen -W 'register enable query disable + erasure' -- "$cur")) return ;; esac fi # third level completion - if [[ $((cword-3)) -ge 1 && ${words[cword-3]} =~ --* ]]; then - tprev=${words[cword-3]} + if [[ $((cword - 3)) -ge 1 && ${words[cword - 3]} =~ --* ]]; then + tprev=${words[cword - 3]} case $tprev in - --deletesms|--deletemms) - COMPREPLY=( $(compgen -W 'end' -- "$cur") ) + --deletesms | --deletemms) + COMPREPLY=($(compgen -W 'end' -- "$cur")) return ;; - --getphonebook|--writetodo|--writecalendarnote) - COMPREPLY=( $(compgen -W '{1..9} end' -- "$cur") ) + --getphonebook | --writetodo | --writecalendarnote) + COMPREPLY=($(compgen -W '{1..9} end' -- "$cur")) return ;; - --gettodo|--getcalendarnote) - [[ ${words[cword-1]} == end ]] && \ - COMPREPLY=( $(compgen -W '--vCal' -- "$cur") ) + --gettodo | --getcalendarnote) + [[ ${words[cword - 1]} == end ]] && + COMPREPLY=($(compgen -W '--vCal' -- "$cur")) return ;; --divert) - COMPREPLY=( $(compgen -W '--type' -- "$cur") ) + COMPREPLY=($(compgen -W '--type' -- "$cur")) return + ;; esac fi # fourth level completion - if [[ $((cword-4)) -ge 1 && ${words[cword-4]} =~ --* ]]; then - fprev=${words[cword-4]} + if [[ $((cword - 4)) -ge 1 && ${words[cword - 4]} =~ --* ]]; then + fprev=${words[cword - 4]} case $fprev in --getphonebook) - COMPREPLY=( $(compgen -W '--raw --vcard --ldif' -- "$cur") ) + COMPREPLY=($(compgen -W '--raw --vcard --ldif' -- "$cur")) return ;; --divert) - COMPREPLY=( $(compgen -W 'all busy noans outofreach notavail' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'all busy noans outofreach notavail' \ + -- "$cur")) return + ;; esac fi @@ -226,10 +228,10 @@ _gnokii() # don't provide main command completions if one is # already on the command line - [[ $COMP_LINE =~ $(tr ' ' '\b|'<<<$main_cmd) ]] && return + [[ $COMP_LINE =~ $(tr ' ' '\b|' <<<$main_cmd) ]] && return - COMPREPLY=( $(compgen -W "$all_cmd" -- "$cur") ) + COMPREPLY=($(compgen -W "$all_cmd" -- "$cur")) } && -complete -F _gnokii gnokii + complete -F _gnokii gnokii # ex: filetype=sh diff --git a/completions/gnome-mplayer b/completions/gnome-mplayer index fa4361df..32d93fc3 100644 --- a/completions/gnome-mplayer +++ b/completions/gnome-mplayer @@ -6,11 +6,11 @@ _gnome_mplayer() _init_completion -s || return case $prev in - -'?'|--help|--help-all|--help-gtk) + -'?' | --help | --help-all | --help-gtk) return ;; - --showcontrols|--showsubtitles|--autostart) - COMPREPLY=( $(compgen -w '0 1' -- "$cur") ) + --showcontrols | --showsubtitles | --autostart) + COMPREPLY=($(compgen -w '0 1' -- "$cur")) return ;; --subtitle) @@ -18,7 +18,7 @@ _gnome_mplayer() return ;; --tvdriver) - COMPREPLY=( $(compgen -W 'v4l v4l2' -- "$cur") ) + COMPREPLY=($(compgen -W 'v4l v4l2' -- "$cur")) return ;; esac @@ -26,13 +26,13 @@ _gnome_mplayer() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _gnome_mplayer gnome-mplayer + complete -F _gnome_mplayer gnome-mplayer # ex: filetype=sh diff --git a/completions/gnome-screenshot b/completions/gnome-screenshot index d0270c38..b3594d20 100644 --- a/completions/gnome-screenshot +++ b/completions/gnome-screenshot @@ -6,14 +6,14 @@ _gnome_screenshot() _init_completion -s || return case $prev in - --help|--help-*|--version|--delay|--display|-!(-*)[hd]) + --help | --help-* | --version | --delay | --display | -!(-*)[hd]) return ;; - --border-effect|-!(-*)e) - COMPREPLY=( $(compgen -W 'shadow border vintage none' -- "$cur") ) + --border-effect | -!(-*)e) + COMPREPLY=($(compgen -W 'shadow border vintage none' -- "$cur")) return ;; - --file|-!(-*)f) + --file | -!(-*)f) _filedir '@(jp?(e)|pn)g' return ;; @@ -22,10 +22,10 @@ _gnome_screenshot() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _gnome_screenshot gnome-screenshot + complete -F _gnome_screenshot gnome-screenshot # ex: filetype=sh diff --git a/completions/gpasswd b/completions/gpasswd index 8f27cfec..f1f22003 100644 --- a/completions/gpasswd +++ b/completions/gpasswd @@ -6,20 +6,20 @@ _gpasswd() _init_completion || return case $prev in - --add|--delete|--administrators|--members|-!(-*)[adAM]) - COMPREPLY=( $(compgen -u -- "$cur") ) + --add | --delete | --administrators | --members | -!(-*)[adAM]) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # TODO: only -A and -M can be combined - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -g -- "$cur") ) + COMPREPLY=($(compgen -g -- "$cur")) } && -complete -F _gpasswd gpasswd + complete -F _gpasswd gpasswd # ex: filetype=sh diff --git a/completions/gpg b/completions/gpg index cb00fa66..f0ca8845 100644 --- a/completions/gpg +++ b/completions/gpg @@ -6,33 +6,33 @@ _gpg() _init_completion || return case $prev in - --sign|--clearsign|--decrypt-files|--load-extension|-!(-*)s) + --sign | --clearsign | --decrypt-files | --load-extension | -!(-*)s) _filedir return ;; - --export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key) + --export | --sign-key | --lsign-key | --nrsign-key | --nrlsign-key | --edit-key) # return list of public keys - COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ + COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \ - 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur") ) + 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur")) return ;; - --recipient|-!(-*)r) - COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ - 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur") ) + --recipient | -!(-*)r) + COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ + 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur")) if [[ -e ~/.gnupg/gpg.conf ]]; then - COMPREPLY+=( $(compgen -W "$(command sed -ne \ + COMPREPLY+=($(compgen -W "$(command sed -ne \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ - ~/.gnupg/gpg.conf)" -- "$cur") ) + ~/.gnupg/gpg.conf)" -- "$cur")) fi return - ;; + ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$($1 --dump-options)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$($1 --dump-options)' -- "$cur")) fi } && -complete -F _gpg -o default gpg + complete -F _gpg -o default gpg # ex: filetype=sh diff --git a/completions/gpg2 b/completions/gpg2 index 45014922..cfa40231 100644 --- a/completions/gpg2 +++ b/completions/gpg2 @@ -10,33 +10,33 @@ _gpg2() _filedir -d return ;; - --sign|--clearsign|--options|--decrypt|-!(-*)s) + --sign | --clearsign | --options | --decrypt | -!(-*)s) _filedir return ;; - --export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key) + --export | --sign-key | --lsign-key | --nrsign-key | --nrlsign-key | --edit-key) # return list of public keys - COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ + COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \ - 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur") ) + 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur")) return ;; - --recipient|-!(-*)r) - COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | \ - command sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur") ) + --recipient | -!(-*)r) + COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | + command sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur")) if [[ -e ~/.gnupg/gpg.conf ]]; then - COMPREPLY+=( $(compgen -W "$(command sed -ne \ + COMPREPLY+=($(compgen -W "$(command sed -ne \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ - ~/.gnupg/gpg.conf)" -- "$cur") ) + ~/.gnupg/gpg.conf)" -- "$cur")) fi - return - ;; + return + ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$($1 --dump-options)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$($1 --dump-options)' -- "$cur")) fi } && -complete -F _gpg2 -o default gpg2 + complete -F _gpg2 -o default gpg2 # ex: filetype=sh diff --git a/completions/gpgv b/completions/gpgv index a3221afc..29315c9c 100644 --- a/completions/gpgv +++ b/completions/gpgv @@ -6,7 +6,7 @@ _gpgv() _init_completion || return case $prev in - --help|--version|--weak-digest|--*-fd|-!(-*)[?h]*) + --help | --version | --weak-digest | --*-fd | -!(-*)[?h]*) return ;; --keyring) @@ -23,15 +23,15 @@ _gpgv() _count_args "" "--@(weak-digest|*-fd|keyring|homedir)" if [[ $cur == -* && $args -eq 1 ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - if [[ $args -gt 1 ]]; then + if ((args > 1)); then if [[ ${COMP_LINE,,} == *.@(asc|sig|sign)\ * ]]; then # Detached signature, only complete one arbitrary file arg and - - if [[ $args -eq 2 ]]; then - COMPREPLY=( $(compgen -W '-' -- "$cur") ) + if ((args == 2)); then + COMPREPLY=($(compgen -W '-' -- "$cur")) _filedir fi else @@ -41,6 +41,6 @@ _gpgv() _filedir "@(asc|gpg|sig|sign)" fi } && -complete -F _gpgv gpgv gpgv2 + complete -F _gpgv gpgv gpgv2 # ex: filetype=sh diff --git a/completions/gphoto2 b/completions/gphoto2 index 89277a95..cbf84c0a 100644 --- a/completions/gphoto2 +++ b/completions/gphoto2 @@ -18,37 +18,38 @@ _gphoto2() _filedir return ;; - -u|--upload-file) + -u | --upload-file) _filedir return ;; --port) - COMPREPLY=( $(compgen -W "$($1 --list-ports 2>/dev/null | \ - awk 'NR>3 { print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 --list-ports 2>/dev/null | + awk 'NR>3 { print $1 }')" -- "$cur")) __ltrim_colon_completions "$cur" return ;; --camera) local IFS=$'\n' - COMPREPLY=( $(compgen -W "$($1 --list-cameras 2>/dev/null | \ - awk -F'"' 'NR>2 { print $2 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 --list-cameras 2>/dev/null | + awk -F'"' 'NR>2 { print $2 }')" -- "$cur")) return ;; - --get-config|--set-config|--set-config-index|--set-config-value) - COMPREPLY=( $(compgen -W "$($1 --list-config 2>/dev/null \ - )" -- "$cur") ) + --get-config | --set-config | --set-config-index | --set-config-value) + COMPREPLY=($(compgen -W "$( + $1 --list-config 2>/dev/null + )" -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _gphoto2 gphoto2 + complete -F _gphoto2 gphoto2 # ex: filetype=sh diff --git a/completions/gprof b/completions/gprof index 40a74820..5a4ab2d4 100644 --- a/completions/gprof +++ b/completions/gprof @@ -6,37 +6,37 @@ _gprof() _init_completion -s || return case $cur in - -A*|-C*|-J*|-p*|-P*|-q*|-Q*|-n*|-N*|-d*) + -A* | -C* | -J* | -p* | -P* | -q* | -Q* | -n* | -N* | -d*) return ;; -S*) cur=${cur:2} _filedir - COMPREPLY=( "${COMPREPLY[@]/#/-S}" ) + COMPREPLY=("${COMPREPLY[@]/#/-S}") return ;; -O*) cur=${cur:2} - COMPREPLY=( $(compgen -P -O -W 'auto bsd 4.4bsd magic prof' \ - -- "$cur") ) + COMPREPLY=($(compgen -P -O -W 'auto bsd 4.4bsd magic prof' \ + -- "$cur")) return ;; esac case $prev in - -I|--directory-path) + -I | --directory-path) _filedir -d return ;; - -R|--file-ordering|--external-symbol-table) + -R | --file-ordering | --external-symbol-table) _filedir return ;; - -w|--width|-k|-m|--min-count|-h|--help|-e|-E|-f|-F) + -w | --width | -k | -m | --min-count | -h | --help | -e | -E | -f | -F) return ;; --file-format) - COMPREPLY=( $(compgen -W 'auto bsd 4.4bsd magic prof' -- "$cur") ) + COMPREPLY=($(compgen -W 'auto bsd 4.4bsd magic prof' -- "$cur")) return ;; esac @@ -44,13 +44,13 @@ _gprof() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _gprof gprof + complete -F _gprof gprof # ex: filetype=sh diff --git a/completions/groupadd b/completions/groupadd index 013feaa4..5f67f299 100644 --- a/completions/groupadd +++ b/completions/groupadd @@ -9,18 +9,18 @@ _groupadd() # with -g/--gid case $prev in - --gid|--key|--password|-!(-*)[gKp]) + --gid | --key | --password | -!(-*)[gKp]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _groupadd groupadd + complete -F _groupadd groupadd # ex: filetype=sh diff --git a/completions/groupdel b/completions/groupdel index fcdd14c1..4d8ca7f7 100644 --- a/completions/groupdel +++ b/completions/groupdel @@ -6,22 +6,22 @@ _groupdel() _init_completion || return case $prev in - -h|--help) + -h | --help) return ;; - -R|--root) + -R | --root) _filedir -d return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -g -- "$cur") ) + COMPREPLY=($(compgen -g -- "$cur")) } && -complete -F _groupdel groupdel + complete -F _groupdel groupdel # ex: filetype=sh diff --git a/completions/groupmems b/completions/groupmems index 6e599a24..2e89a5ab 100644 --- a/completions/groupmems +++ b/completions/groupmems @@ -6,22 +6,22 @@ _groupmems() _init_completion || return case $prev in - -a|--add|-d|--delete) - COMPREPLY=( $(compgen -u -- "$cur") ) + -a | --add | -d | --delete) + COMPREPLY=($(compgen -u -- "$cur")) return ;; - -g|--group) - COMPREPLY=( $(compgen -g -- "$cur") ) + -g | --group) + COMPREPLY=($(compgen -g -- "$cur")) return ;; - -R|--root) + -R | --root) _filedir -d return ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _groupmems groupmems + complete -F _groupmems groupmems # ex: filetype=sh diff --git a/completions/groupmod b/completions/groupmod index 2ac62ea3..5516d31c 100644 --- a/completions/groupmod +++ b/completions/groupmod @@ -9,21 +9,21 @@ _groupmod() # with -g/--gid case $prev in - --gid|--help|--new-name|--password|-!(-*)[ghnp]) + --gid | --help | --new-name | --password | -!(-*)[ghnp]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - COMPREPLY=( $(compgen -g -- "$cur") ) + COMPREPLY=($(compgen -g -- "$cur")) } && -complete -F _groupmod groupmod + complete -F _groupmod groupmod # ex: filetype=sh diff --git a/completions/growisofs b/completions/growisofs index a0c6de3f..ee09fe6c 100644 --- a/completions/growisofs +++ b/completions/growisofs @@ -6,10 +6,10 @@ _growisofs() _init_completion || return case $prev in - -version|-speed) + -version | -speed) return ;; - -Z|-M) + -Z | -M) compopt -o nospace _dvd_devices return @@ -24,16 +24,16 @@ _growisofs() ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # TODO: mkisofs options - COMPREPLY=( $(compgen -W '-dvd-compat -overburn -speed= -Z -M' \ - -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '-dvd-compat -overburn -speed= -Z -M' \ + -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _growisofs growisofs + complete -F _growisofs growisofs # ex: filetype=sh diff --git a/completions/grpck b/completions/grpck index 9f5eac7b..0fadbedc 100644 --- a/completions/grpck +++ b/completions/grpck @@ -6,20 +6,20 @@ _grpck() _init_completion || return case $prev in - --root|-!(-*)R) + --root | -!(-*)R) _filedir return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) return fi _filedir } && -complete -F _grpck grpck + complete -F _grpck grpck # ex: filetype=sh diff --git a/completions/gssdp-discover b/completions/gssdp-discover index f0fa6955..8454f52a 100644 --- a/completions/gssdp-discover +++ b/completions/gssdp-discover @@ -6,26 +6,29 @@ _gssdp_discover() _init_completion -s || return case $prev in - --help|--target|--timeout|--rescan-interval|-[htnr]) + --help | --target | --timeout | --rescan-interval | -[htnr]) return ;; - --interface|-i) + --interface | -i) _available_interfaces -a return ;; - --message-type|-m) - local types=$($1 --help 2>&1 | \ + --message-type | -m) + local types=$($1 --help 2>&1 | command sed -ne 's/^.*--message-type=.*(\([^)]*\))$/\1/p') - COMPREPLY=( $(IFS+=,; compgen -W "$types" -- "$cur") ) + COMPREPLY=($( + IFS+=, + compgen -W "$types" -- "$cur" + )) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _gssdp_discover gssdp-discover + complete -F _gssdp_discover gssdp-discover # ex: filetype=sh diff --git a/completions/gzip b/completions/gzip index d3bce282..0144c3a3 100644 --- a/completions/gzip +++ b/completions/gzip @@ -6,38 +6,38 @@ _gzip() _init_completion || return case $prev in - --blocksize|--suffix|--help|--version|-!(-*)[bShV]) + --blocksize | --suffix | --help | --version | -!(-*)[bShV]) return ;; - --processes|-!(-*)p) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + --processes | -!(-*)p) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi local IFS=$'\n' xspec="*.@(gz|t[ag]z)" [[ ${1##*/} == pigz ]] && xspec="*.@([gz]z|t[ag]z)" - if [[ "$prev" == --* ]]; then - [[ "$prev" == --@(decompress|list|test) ]] && xspec="!"$xspec - [[ "$prev" == --force ]] && xspec= - elif [[ "$prev" == -* ]]; then - [[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec - [[ "$prev" == -*f* ]] && xspec= + if [[ $prev == --* ]]; then + [[ $prev == --@(decompress|list|test) ]] && xspec="!"$xspec + [[ $prev == --force ]] && xspec= + elif [[ $prev == -* ]]; then + [[ $prev == -*[dlt]* ]] && xspec="!"$xspec + [[ $prev == -*f* ]] && xspec= fi _tilde "$cur" || return compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") \ - $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") + $(compgen -d -- "$cur")) } && -complete -F _gzip gzip pigz + complete -F _gzip gzip pigz # ex: filetype=sh diff --git a/completions/hcitool b/completions/hcitool index ccc64f18..58bf5a7a 100644 --- a/completions/hcitool +++ b/completions/hcitool @@ -3,28 +3,28 @@ _bluetooth_addresses() { if [[ -n ${COMP_BLUETOOTH_SCAN:-} ]]; then - COMPREPLY+=( $(compgen -W "$(hcitool scan | \ - awk '/^\t/{print $1}')" -- "$cur") ) + COMPREPLY+=($(compgen -W "$(hcitool scan | + awk '/^\t/{print $1}')" -- "$cur")) fi } _bluetooth_devices() { - COMPREPLY+=( $(compgen -W "$(hcitool dev | \ - awk '/^\t/{print $1}')" -- "$cur") ) + COMPREPLY+=($(compgen -W "$(hcitool dev | + awk '/^\t/{print $1}')" -- "$cur")) } _bluetooth_services() { - COMPREPLY=( $(compgen -W 'DID SP DUN LAN FAX OPUSH FTP HS HF HFAG SAP NAP + COMPREPLY=($(compgen -W 'DID SP DUN LAN FAX OPUSH FTP HS HF HFAG SAP NAP GN PANU HCRP HID CIP A2SRC A2SNK AVRCT AVRTG UDIUE UDITE SYNCML' \ - -- "$cur") ) + -- "$cur")) } _bluetooth_packet_types() { - COMPREPLY=( $(compgen -W 'DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3' \ + -- "$cur")) } _hcitool() @@ -38,7 +38,7 @@ _hcitool() return ;; --role) - COMPREPLY=( $(compgen -W 'm s' -- "$cur") ) + COMPREPLY=($(compgen -W 'm s' -- "$cur")) return ;; --pkt-type) @@ -52,60 +52,60 @@ _hcitool() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - COMPREPLY=( $(compgen -W 'dev inq scan name info spinq epinq cmd + COMPREPLY=($(compgen -W 'dev inq scan name info spinq epinq cmd con cc dc sr cpt rssi lq tpl afh lst auth enc key clkoff - clock' -- "$cur") ) + clock' -- "$cur")) fi else local args case $arg in - name|info|dc|rssi|lq|afh|auth|key|clkoff|lst) + name | info | dc | rssi | lq | afh | auth | key | clkoff | lst) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses fi ;; cc) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--role --pkt-type' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--role --pkt-type' -- "$cur")) else _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses fi fi ;; sr) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses else - COMPREPLY=( $(compgen -W 'master slave' -- "$cur") ) + COMPREPLY=($(compgen -W 'master slave' -- "$cur")) fi ;; cpt) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses else _bluetooth_packet_types fi ;; - tpl|enc|clock) + tpl | enc | clock) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses else - COMPREPLY=( $(compgen -W '0 1' -- "$cur") ) + COMPREPLY=($(compgen -W '0 1' -- "$cur")) fi ;; esac fi } && -complete -F _hcitool hcitool + complete -F _hcitool hcitool _sdptool() { @@ -124,46 +124,46 @@ _sdptool() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - COMPREPLY=( $(compgen -W 'search browse records add del get - setattr setseq' -- "$cur") ) + COMPREPLY=($(compgen -W 'search browse records add del get + setattr setseq' -- "$cur")) fi else case $arg in search) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--bdaddr --tree --raw --xml' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--bdaddr --tree --raw --xml' \ + -- "$cur")) else _bluetooth_services fi ;; - browse|records) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--tree --raw --xml' -- "$cur") ) + browse | records) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--tree --raw --xml' -- "$cur")) else _bluetooth_addresses fi ;; add) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--handle --channel' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--handle --channel' -- "$cur")) else _bluetooth_services fi ;; get) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--bdaddr --tree --raw --xml' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--bdaddr --tree --raw --xml' \ + -- "$cur")) fi ;; esac fi } && -complete -F _sdptool sdptool + complete -F _sdptool sdptool _l2ping() { @@ -175,18 +175,18 @@ _l2ping() _bluetooth_devices return ;; - -s|-c|-t|-d) + -s | -c | -t | -d) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) else _bluetooth_addresses fi } && -complete -F _l2ping l2ping + complete -F _l2ping l2ping _rfcomm() { @@ -194,7 +194,7 @@ _rfcomm() _init_completion || return case $prev in - -f|--config) + -f | --config) _filedir return ;; @@ -208,21 +208,21 @@ _rfcomm() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - COMPREPLY=( $(compgen -W 'show connect listen watch bind - release' -- "$cur") ) + COMPREPLY=($(compgen -W 'show connect listen watch bind + release' -- "$cur")) fi else local args _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_devices else case $arg in - connect|bind) - if [[ $args -eq 3 ]]; then + connect | bind) + if ((args == 3)); then _bluetooth_addresses fi ;; @@ -230,7 +230,7 @@ _rfcomm() fi fi } && -complete -F _rfcomm rfcomm + complete -F _rfcomm rfcomm _ciptool() { @@ -248,25 +248,25 @@ _ciptool() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - COMPREPLY=( $(compgen -W 'show search connect release loopback' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'show search connect release loopback' \ + -- "$cur")) fi else local args case $arg in - connect|release|loopback) + connect | release | loopback) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses fi ;; esac fi } && -complete -F _ciptool ciptool + complete -F _ciptool ciptool _dfutool() { @@ -274,21 +274,21 @@ _dfutool() _init_completion || return case $prev in - -d|--device) + -d | --device) _bluetooth_devices return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else local args _count_args case $args in 1) - COMPREPLY=( $(compgen -W 'verify modify upgrade archive' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'verify modify upgrade archive' \ + -- "$cur")) ;; 2) _filedir @@ -296,7 +296,7 @@ _dfutool() esac fi } && -complete -F _dfutool dfutool + complete -F _dfutool dfutool _hciconfig() { @@ -306,68 +306,68 @@ _hciconfig() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --all' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --all' -- "$cur")) else - COMPREPLY=( $(compgen -W 'up down reset rstat auth noauth encrypt + COMPREPLY=($(compgen -W 'up down reset rstat auth noauth encrypt noencrypt secmgr nosecmgr piscan noscan iscan pscan ptype name class voice iac inqmode inqdata inqtype inqparams pageparms pageto afhmode aclmtu scomtu putkey delkey commands features - version revision lm' -- "$cur") ) + version revision lm' -- "$cur")) fi else local args case $arg in - putkey|delkey) + putkey | delkey) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses fi ;; lm) _count_args - if [[ $args -eq 2 ]]; then - COMPREPLY=( $(compgen -W 'MASTER SLAVE NONE ACCEPT' \ - -- "$cur") ) + if ((args == 2)); then + COMPREPLY=($(compgen -W 'MASTER SLAVE NONE ACCEPT' \ + -- "$cur")) fi ;; ptype) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_packet_types fi ;; esac fi } && -complete -F _hciconfig hciconfig + complete -F _hciconfig hciconfig _hciattach() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-n -p -t -b -s -l' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-n -p -t -b -s -l' -- "$cur")) else local args _count_args case $args in 1) - COMPREPLY=( $(printf '%s\n' /dev/tty*) ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]} - ${COMPREPLY[@]#/dev/}' -- "$cur") ) + COMPREPLY=($(printf '%s\n' /dev/tty*)) + COMPREPLY=($(compgen -W '${COMPREPLY[@]} + ${COMPREPLY[@]#/dev/}' -- "$cur")) ;; 2) - COMPREPLY=( $(compgen -W 'any ericsson digi xircom csr bboxes - swave bcsp 0x0105 0x080a 0x0160 0x0002' -- "$cur") ) + COMPREPLY=($(compgen -W 'any ericsson digi xircom csr bboxes + swave bcsp 0x0105 0x080a 0x0160 0x0002' -- "$cur")) ;; 3) - COMPREPLY=( $(compgen -W '9600 19200 38400 57600 115200 230400 - 460800 921600' -- "$cur") ) + COMPREPLY=($(compgen -W '9600 19200 38400 57600 115200 230400 + 460800 921600' -- "$cur")) ;; 4) - COMPREPLY=( $(compgen -W 'flow noflow' -- "$cur") ) + COMPREPLY=($(compgen -W 'flow noflow' -- "$cur")) ;; 5) _bluetooth_addresses @@ -375,6 +375,6 @@ _hciattach() esac fi } && -complete -F _hciattach hciattach + complete -F _hciattach hciattach # ex: filetype=sh diff --git a/completions/hddtemp b/completions/hddtemp index b7487cc9..7b95f0ee 100644 --- a/completions/hddtemp +++ b/completions/hddtemp @@ -6,19 +6,19 @@ _hddtemp() _init_completion -s || return case $prev in - --file|-!(-*)f) + --file | -!(-*)f) _filedir db return ;; - --listen|-!(-*)l) + --listen | -!(-*)l) _ip_addresses return ;; - --unit|-!(-*)u) - COMPREPLY=( $(compgen -W 'C F' -- "$cur") ) + --unit | -!(-*)u) + COMPREPLY=($(compgen -W 'C F' -- "$cur")) return ;; - --port|--separator|--syslog|--version|--help|-!(-*)[psSvh?]) + --port | --separator | --syslog | --version | --help | -!(-*)[psSvh?]) return ;; esac @@ -26,13 +26,13 @@ _hddtemp() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") --help' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1") --help' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else cur=${cur:=/dev/} _filedir fi } && -complete -F _hddtemp hddtemp + complete -F _hddtemp hddtemp # ex: filetype=sh diff --git a/completions/hid2hci b/completions/hid2hci index 9e3305d0..f33a4957 100644 --- a/completions/hid2hci +++ b/completions/hid2hci @@ -5,11 +5,11 @@ _hid2hci() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --quiet -0 --tohci -1 --tohid' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --quiet -0 --tohci -1 --tohid' \ + -- "$cur")) fi } && -complete -F _hid2hci hid2hci + complete -F _hid2hci hid2hci # ex: filetype=sh diff --git a/completions/hostname b/completions/hostname index 68f9b4ed..ce1b32e2 100644 --- a/completions/hostname +++ b/completions/hostname @@ -6,18 +6,18 @@ _hostname() _init_completion || return case $prev in - --help|--version|-!(-*)[hV]) + --help | --version | -!(-*)[hV]) return ;; - --file|-!(-*)F) + --file | -!(-*)F) _filedir return ;; esac - [[ $cur == -* ]] && \ - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $cur == -* ]] && + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _hostname hostname + complete -F _hostname hostname # ex: filetype=sh diff --git a/completions/hping2 b/completions/hping2 index 78d35b05..666838b1 100644 --- a/completions/hping2 +++ b/completions/hping2 @@ -6,30 +6,30 @@ _hping2() _init_completion || return case $prev in - --interface|-!(-*)I) + --interface | -!(-*)I) _available_interfaces return ;; - --spoof|-!(-*)a) + --spoof | -!(-*)a) _known_hosts_real -- "$cur" return ;; - --tos|-!(-*)o) - COMPREPLY=( $(compgen -W '02 04 08 10') ) + --tos | -!(-*)o) + COMPREPLY=($(compgen -W '02 04 08 10')) return ;; - --file|-!(-*)E) + --file | -!(-*)E) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else _known_hosts_real -- "$cur" fi } && -complete -F _hping2 hping hping2 hping3 + complete -F _hping2 hping hping2 hping3 # ex: filetype=sh diff --git a/completions/htop b/completions/htop index 3f1680b5..b4916d5b 100644 --- a/completions/htop +++ b/completions/htop @@ -6,15 +6,15 @@ _htop() _init_completion -s || return case "$prev" in - --sort-key|-!(-*)s) - COMPREPLY=( $(compgen -W '$("$1" -s help)' -- "$cur") ) + --sort-key | -!(-*)s) + COMPREPLY=($(compgen -W '$("$1" -s help)' -- "$cur")) return ;; - --user|-!(-*)u) - COMPREPLY=( $(compgen -u -- "$cur") ) + --user | -!(-*)u) + COMPREPLY=($(compgen -u -- "$cur")) return ;; - --delay|-!(-*)d) + --delay | -!(-*)d) # argument required but no completions available return ;; @@ -22,12 +22,12 @@ _htop() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi } && -complete -F _htop htop + complete -F _htop htop # ex: filetype=sh diff --git a/completions/htpasswd b/completions/htpasswd index 827e6dcc..527684bf 100644 --- a/completions/htpasswd +++ b/completions/htpasswd @@ -6,28 +6,31 @@ _htpasswd() _init_completion || return local i o=0 # $o is index of first non-option argument - for (( i=1; i <= cword; i++ )); do + for ((i = 1; i <= cword; i++)); do case ${words[i]} in - -*n*) return ;; - -*) ;; - *) o=$i ; break ;; + -*n*) return ;; + -*) ;; + *) + o=$i + break + ;; esac done - if [[ $o -eq 0 || $o -eq $cword ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if ((o == 0 || o == cword)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi # Password file (first non-option argument) _filedir - elif [[ $o -eq $cword-1 ]]; then + elif ((o == cword - 1)); then # Username (second non-option argument) - COMPREPLY=( $(compgen -W \ - '$(cut -d: -f1 "${words[o]}" 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W \ + '$(cut -d: -f1 "${words[o]}" 2>/dev/null)' -- "$cur")) fi } && -complete -F _htpasswd htpasswd + complete -F _htpasswd htpasswd # ex: filetype=sh diff --git a/completions/hunspell b/completions/hunspell index 627f3e4b..92b4fe84 100644 --- a/completions/hunspell +++ b/completions/hunspell @@ -6,18 +6,19 @@ _hunspell() _init_completion || return case $prev in - --help|--version|-vv|-[hPv]) + --help | --version | -vv | -[hPv]) return ;; -d) - local IFS=$' \t\n' reset=$(shopt -p nullglob); shopt -s nullglob - local -a dicts=( /usr/share/hunspell/*.dic - /usr/local/share/hunspell/*.dic ) - dicts=( "${dicts[@]##*/}" ) - dicts=( "${dicts[@]%.dic}" ) + local IFS=$' \t\n' reset=$(shopt -p nullglob) + shopt -s nullglob + local -a dicts=(/usr/share/hunspell/*.dic + /usr/local/share/hunspell/*.dic) + dicts=("${dicts[@]##*/}") + dicts=("${dicts[@]%.dic}") $reset IFS=$'\n' - COMPREPLY=( $(compgen -W '${dicts[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${dicts[@]}' -- "$cur")) return ;; -i) @@ -31,12 +32,12 @@ _hunspell() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir } && -complete -F _hunspell hunspell + complete -F _hunspell hunspell # ex: filetype=sh diff --git a/completions/iconv b/completions/iconv index 372c525b..81ae01ba 100644 --- a/completions/iconv +++ b/completions/iconv @@ -2,8 +2,8 @@ _iconv_charsets() { - COMPREPLY+=( $(compgen -X ... -W '$(${1:-iconv} -l | \ - command sed -e "s@/*\$@@" -e "s/[,()]//g")' -- "$cur") ) + COMPREPLY+=($(compgen -X ... -W '$(${1:-iconv} -l | \ + command sed -e "s@/*\$@@" -e "s/[,()]//g")' -- "$cur")) } _iconv() @@ -12,15 +12,15 @@ _iconv() _init_completion -s || return case $prev in - --help|--usage|--version|--unicode-subst|--byte-subst|\ - --widechar-subst|-!(-*)[?V]) + --help | --usage | --version | --unicode-subst | --byte-subst | \ + --widechar-subst | -!(-*)[?V]) return ;; - --from-code|--to-code|-!(-*)[ft]) + --from-code | --to-code | -!(-*)[ft]) _iconv_charsets $1 return ;; - --output|-!(-*)o) + --output | -!(-*)o) _filedir return ;; @@ -28,11 +28,11 @@ _iconv() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _iconv -o default iconv + complete -F _iconv -o default iconv # ex: filetype=sh diff --git a/completions/id b/completions/id index 3f3087cb..a07e51dc 100644 --- a/completions/id +++ b/completions/id @@ -5,14 +5,14 @@ _id() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") [[ $opts ]] || opts="-G -g -u" # POSIX fallback - COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) + COMPREPLY=($(compgen -W "$opts" -- "$cur")) else - COMPREPLY=( $(compgen -u "$cur") ) + COMPREPLY=($(compgen -u "$cur")) fi } && -complete -F _id id + complete -F _id id # ex: filetype=sh diff --git a/completions/idn b/completions/idn index 39d13021..8023f8fd 100644 --- a/completions/idn +++ b/completions/idn @@ -6,21 +6,21 @@ _idn() _init_completion -s || return case $prev in - --help|--version|-!(-*)[hV]) + --help | --version | -!(-*)[hV]) return ;; - --profile|-!(-*)p) - COMPREPLY=( $(compgen -W 'Nameprep iSCSI Nodeprep Resourceprep - trace SASLprep' -- "$cur") ) + --profile | -!(-*)p) + COMPREPLY=($(compgen -W 'Nameprep iSCSI Nodeprep Resourceprep + trace SASLprep' -- "$cur")) return ;; esac if ! $split && [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _idn idn + complete -F _idn idn # ex: filetype=sh diff --git a/completions/ifstat b/completions/ifstat index 9fac3d30..629786e4 100644 --- a/completions/ifstat +++ b/completions/ifstat @@ -6,7 +6,7 @@ _ifstat() _init_completion -s || return case $prev in - --help|--version|--scan|--interval|-!(-*)[hvV]) + --help | --version | --scan | --interval | -!(-*)[hvV]) return ;; -!(-*)i) @@ -17,18 +17,22 @@ _ifstat() -!(-*)d) # iproute2: no completion (scan delay) # traditional: parse driver - if ! { "$1" --help 2>&1 || :; } | \ - command grep -q -- '-d.*--scan'; then - COMPREPLY=( $(compgen -W '$("$1" -v | command \ - sed -e "s/[,.]//g" -ne "s/^.*drivers://p")' -- "$cur") ) + if ! { + "$1" --help 2>&1 || : + } | + command grep -q -- '-d.*--scan'; then + COMPREPLY=($(compgen -W '$("$1" -v | command \ + sed -e "s/[,.]//g" -ne "s/^.*drivers://p")' -- "$cur")) fi return ;; - --noupdate|-!(-*)s) + --noupdate | -!(-*)s) # iproute2: pass through (skip history update) # traditional: hostnames (snmp) - if ! { "$1" --help 2>&1 || :; } | \ - command grep -q -- '-s.*--noupdate'; then + if ! { + "$1" --help 2>&1 || : + } | + command grep -q -- '-s.*--noupdate'; then _known_hosts_real -- "$cur" return fi @@ -36,27 +40,29 @@ _ifstat() -!(-*)t) # iproute2: no completion (interval) # traditional: pass through (add timestamp) - ! { "$1" --help 2>&1 || :; } | \ + ! { + "$1" --help 2>&1 || : + } | command grep -q -- '-t.*--interval' || return ;; - --extended|-!(-*)x) + --extended | -!(-*)x) # iproute2: parse xstat types - COMPREPLY=( $(compgen -W '$("$1" -x nonexistent-xstat 2>&1 | + COMPREPLY=($(compgen -W '$("$1" -x nonexistent-xstat 2>&1 | awk "found { print \$1 } /supported xstats:/ { found=1 }")' \ - -- "$cur") ) + -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi } && -complete -F _ifstat ifstat + complete -F _ifstat ifstat # ex: filetype=sh diff --git a/completions/iftop b/completions/iftop index 6320316d..b73f4b6b 100644 --- a/completions/iftop +++ b/completions/iftop @@ -6,7 +6,7 @@ _iftop() _init_completion || return case $prev in - -h|-f|-F|-m) + -h | -f | -F | -m) return ;; -i) @@ -19,8 +19,8 @@ _iftop() ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) } && -complete -F _iftop iftop + complete -F _iftop iftop # ex: filetype=sh diff --git a/completions/ifup b/completions/ifup index db8de8e0..5b35bfb2 100644 --- a/completions/ifup +++ b/completions/ifup @@ -8,10 +8,10 @@ _ifupdown() _init_completion || return case $prev in - --help|--version|--allow|--exclude|--option|-!(-*)[hVXo]) + --help | --version | --allow | --exclude | --option | -!(-*)[hVXo]) return ;; - --interfaces|-!(-*)i) + --interfaces | -!(-*)i) _filedir return ;; @@ -22,18 +22,18 @@ _ifupdown() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi local args _count_args "" "@(--allow|-i|--interfaces|--state-dir|-X|--exclude|-o)" - if [[ $args -eq 1 ]]; then + if ((args == 1)); then _configured_interfaces - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) fi } && -complete -F _ifupdown ifup ifdown ifquery ifstatus + complete -F _ifupdown ifup ifdown ifquery ifstatus # ex: filetype=sh diff --git a/completions/influx b/completions/influx index bbedf10f..e9362e7e 100644 --- a/completions/influx +++ b/completions/influx @@ -6,27 +6,30 @@ _influx() _init_completion || return case $prev in - -version|-port|-database|-password|-username|-execute|-pps) + -version | -port | -database | -password | -username | -execute | -pps) return ;; -host) _known_hosts_real -- "$cur" return ;; - -format|-precision|-consistency) + -format | -precision | -consistency) local args=$($1 --help 2>&1 | awk "\$1 == \"$prev\" { print \$2 }") - COMPREPLY=( $(IFS+="\"'|"; compgen -W "$args" -- "$cur") ) + COMPREPLY=($( + IFS+="\"'|" + compgen -W "$args" -- "$cur" + )) return ;; - -import|-path) + -import | -path) _filedir return ;; esac - [[ "$cur" == -* ]] && - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $cur == -* ]] && + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _influx influx + complete -F _influx influx # ex: filetype=sh diff --git a/completions/info b/completions/info index 87179ac8..f50f8424 100644 --- a/completions/info +++ b/completions/info @@ -6,13 +6,13 @@ _info() _init_completion -s || return # default completion if parameter looks like a path - if [[ "$cur" == @(*/|[.~])* ]]; then + if [[ $cur == @(*/|[.~])* ]]; then _filedir return fi case $prev in - --apropos|--index-search|--node|--help|--version|-!(-*)[knhv]) + --apropos | --index-search | --node | --help | --version | -!(-*)[knhv]) return ;; -!(-*)d) @@ -25,7 +25,7 @@ _info() _filedir -d return ;; - --dribble|--file|--output|--restore|--raw-filename|--rcfile|-!(-*)[for]) + --dribble | --file | --output | --restore | --raw-filename | --rcfile | -!(-*)[for]) _filedir return ;; @@ -34,14 +34,14 @@ _info() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi local i infopath=/usr/share/info - if [[ $INFOPATH == *: ]]; then + if [[ ${INFOPATH-} == *: ]]; then infopath=${INFOPATH}${infopath} elif [[ ${INFOPATH:+set} ]]; then infopath=$INFOPATH @@ -57,18 +57,18 @@ _info() fi # redirect stderr for when path doesn't exist - COMPREPLY=( $(eval command ls "$infopath" 2>/dev/null) ) + COMPREPLY=($(eval command ls "$infopath" 2>/dev/null)) # weed out directory path names and paths to info pages - COMPREPLY=( ${COMPREPLY[@]##*/?(:)} ) + COMPREPLY=(${COMPREPLY[@]##*/?(:)}) # weed out info dir file - for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do - [[ ${COMPREPLY[$i]} == dir ]] && unset "COMPREPLY[$i]" + for i in ${!COMPREPLY[*]}; do + [[ ${COMPREPLY[i]} == dir ]] && unset "COMPREPLY[i]" done # strip suffix from info pages - COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|xz|lzma)} ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}") ) + COMPREPLY=(${COMPREPLY[@]%.@(gz|bz2|xz|lzma)}) + COMPREPLY=($(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}")) } && -complete -F _info info pinfo + complete -F _info info pinfo # ex: filetype=sh diff --git a/completions/inject b/completions/inject index 8becf274..fad73a19 100644 --- a/completions/inject +++ b/completions/inject @@ -6,7 +6,7 @@ _inject() _init_completion -s || return case $prev in - -l|--listname) + -l | --listname) _xfunc list_lists _mailman_lists return ;; @@ -14,13 +14,13 @@ _inject() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--listname --queue --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--listname --queue --help' -- "$cur")) else _filedir fi } && -complete -F _inject inject + complete -F _inject inject # ex: filetype=sh diff --git a/completions/inotifywait b/completions/inotifywait index 637d4742..e5608fc6 100644 --- a/completions/inotifywait +++ b/completions/inotifywait @@ -5,10 +5,10 @@ _inotifywait_events() # Expecting line with "Events:", followed by ones starting with one # tab. Word following the tab is event name, others are line # wrapped explanations. - COMPREPLY+=( $(compgen -W "$($1 --help 2>/dev/null | \ + COMPREPLY+=($(compgen -W "$($1 --help 2>/dev/null | command sed -e '/^Events:/,/^[^'$'\t'']/!d' \ - -ne 's/^'$'\t''\([^ '$'\t'']\{1,\}\)[ '$'\t''].*/\1/p')" \ - -- "$cur") ) + -ne 's/^'$'\t''\([^ '$'\t'']\{1,\}\)[ '$'\t''].*/\1/p')" \ + -- "$cur")) } _inotifywait() @@ -17,31 +17,31 @@ _inotifywait() _init_completion || return case $prev in - --help|--exclude|--excludei|--format|--timefmt|--timeout|-!(-*)[ht]) + --help | --exclude | --excludei | --format | --timefmt | --timeout | -!(-*)[ht]) return ;; - --fromfile|--outfile|-!(-*)o) + --fromfile | --outfile | -!(-*)o) _filedir return ;; - --event|-!(-*)e) + --event | -!(-*)e) _inotifywait_events "$1" return ;; - --ascending|--descending) - COMPREPLY=( $(compgen -W 'total' -- "$cur") ) + --ascending | --descending) + COMPREPLY=($(compgen -W 'total' -- "$cur")) _inotifywait_events "$1" return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir } && -complete -F _inotifywait inotifywait inotifywatch + complete -F _inotifywait inotifywait inotifywatch # ex: filetype=sh diff --git a/completions/insmod b/completions/insmod index 36c29dc4..a59e7535 100644 --- a/completions/insmod +++ b/completions/insmod @@ -6,13 +6,13 @@ _insmod() _init_completion || return # do filename completion for first argument - if [[ $cword -eq 1 ]]; then - _filedir '@(?(k)o?(.gz))' + if ((cword == 1)); then + _filedir '@(?(k)o?(.[gx]z))' else # do module parameter completion - COMPREPLY=( $(compgen -W "$(PATH="$PATH:/sbin" modinfo \ - -p ${words[1]} 2>/dev/null | cut -d: -f1)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(PATH="$PATH:/sbin" modinfo \ + -p ${words[1]} 2>/dev/null | cut -d: -f1)" -- "$cur")) fi } && -complete -F _insmod insmod insmod.static + complete -F _insmod insmod insmod.static # ex: filetype=sh diff --git a/completions/installpkg b/completions/installpkg index 3ebf1dfc..7455eb10 100644 --- a/completions/installpkg +++ b/completions/installpkg @@ -11,7 +11,7 @@ _installpkg() return ;; --priority) - COMPREPLY=( $(compgen -W 'ADD REC OPT SKP' -- "$cur") ) + COMPREPLY=($(compgen -W 'ADD REC OPT SKP' -- "$cur")) return ;; --tagfile) @@ -20,14 +20,14 @@ _installpkg() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--warn --md5sum --root --infobox --terse - --menu --ask --priority --tagfile' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--warn --md5sum --root --infobox --terse + --menu --ask --priority --tagfile' -- "$cur")) return fi _filedir 't[bglx]z' } && -complete -F _installpkg installpkg + complete -F _installpkg installpkg # ex: filetype=sh diff --git a/completions/interdiff b/completions/interdiff index e7923751..9933d15d 100644 --- a/completions/interdiff +++ b/completions/interdiff @@ -6,7 +6,7 @@ _interdiff() _init_completion -s || return case $prev in - --unified|--strip-match|--drop-context|-!(-*)[Upd]) + --unified | --strip-match | --drop-context | -!(-*)[Upd]) return ;; esac @@ -14,8 +14,8 @@ _interdiff() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -28,6 +28,6 @@ _interdiff() done _filedir "$exts" } && -complete -F _interdiff interdiff + complete -F _interdiff interdiff # ex: filetype=sh diff --git a/completions/invoke-rc.d b/completions/invoke-rc.d index e4b2afc9..4a5045a8 100644 --- a/completions/invoke-rc.d +++ b/completions/invoke-rc.d @@ -9,30 +9,30 @@ _invoke_rc_d() local sysvdir services options valid_options - [[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d \ - || sysvdir=/etc/init.d + [[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d || + sysvdir=/etc/init.d - services=( $(printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob)) ) - services=( ${services[@]#$sysvdir/} ) - options=( --help --quiet --force --try-anyway --disclose-deny --query \ - --no-fallback ) + services=($(printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob))) + services=(${services[@]#$sysvdir/}) + options=(--help --quiet --force --try-anyway --disclose-deny --query + --no-fallback) - if [[ ($cword -eq 1) || ("$prev" == --* ) ]]; then - valid_options=( $(\ - tr " " "\n" <<<"${words[*]} ${options[*]}" \ - | command sed -ne "/$(command sed "s/ /\\\\|/g" <<<"${options[*]}")/p" \ - | sort | uniq -u \ - ) ) - COMPREPLY=( $(compgen -W '${valid_options[@]} ${services[@]}' -- "$cur") ) + if [[ $cword -eq 1 || $prev == --* ]]; then + valid_options=($( + tr " " "\n" <<<"${words[*]} ${options[*]}" | + command sed -ne "/$(command sed 's/ /\\|/g' <<<"${options[*]}")/p" | + sort | uniq -u + )) + COMPREPLY=($(compgen -W '${valid_options[@]} ${services[@]}' -- "$cur")) elif [[ -x $sysvdir/$prev ]]; then - COMPREPLY=( $(compgen -W '`command sed -e "y/|/ /" \ + COMPREPLY=($(compgen -W '`command sed -e "y/|/ /" \ -ne "s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \ - $sysvdir/$prev`' -- "$cur") ) + $sysvdir/$prev`' -- "$cur")) else COMPREPLY=() fi } && -complete -F _invoke_rc_d invoke-rc.d + complete -F _invoke_rc_d invoke-rc.d # ex: filetype=sh diff --git a/completions/ip b/completions/ip index f7e6e7c2..12ad9aa3 100644 --- a/completions/ip +++ b/completions/ip @@ -2,9 +2,9 @@ _iproute2_etc() { - COMPREPLY+=( $(compgen -W \ + COMPREPLY+=($(compgen -W \ "$(awk '!/#/ { print $2 }' /etc/iproute2/$1 2>/dev/null)" \ - -- "$cur") ) + -- "$cur")) } _ip() @@ -13,100 +13,99 @@ _ip() _init_completion || return case $prev in - -V|-Version|-rc|-rcvbuf) + -V | -Version | -rc | -rcvbuf) return ;; - -f|-family) - COMPREPLY=( $(compgen -W 'inet inet6 ipx dnet link' -- "$cur") ) + -f | -family) + COMPREPLY=($(compgen -W 'inet inet6 ipx dnet link' -- "$cur")) return ;; - -b|-batch) + -b | -batch) _filedir return ;; -force) - COMPREPLY=( $(compgen -W '-batch' -- "$cur") ) + COMPREPLY=($(compgen -W '-batch' -- "$cur")) return ;; esac - local subcword cmd subcmd - for (( subcword=1; subcword < ${#words[@]}-1; subcword++ )); do + local subcword cmd subcmd="" + for ((subcword = 1; subcword < ${#words[@]} - 1; subcword++)); do [[ ${words[subcword]} == -b?(atch) ]] && return - [[ -n $cmd ]] && subcmd=${words[subcword]} && break + [[ -v cmd ]] && subcmd=${words[subcword]} && break [[ ${words[subcword]} != -* && \ - ${words[subcword-1]} != -@(f?(amily)|rc?(vbuf)) ]] && \ + ${words[subcword - 1]} != -@(f?(amily)|rc?(vbuf)) ]] && cmd=${words[subcword]} done - if [[ -z $cmd ]]; then + if [[ ! -v cmd ]]; then case $cur in -*) local c="-Version -statistics -details -resolve -family -oneline -timestamp -batch -rcvbuf" - [[ $cword -eq 1 ]] && c+=" -force" - COMPREPLY=( $(compgen -W "$c" -- "$cur") ) - return + ((cword == 1)) && c+=" -force" + COMPREPLY=($(compgen -W "$c" -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W "help $($1 help 2>&1 | command sed -e \ + COMPREPLY=($(compgen -W "help $($1 help 2>&1 | command sed -e \ '/OBJECT := /,/}/!d' -e \ 's/.*{//' -e \ 's/}.*//' -e \ - 's/|//g')" -- "$cur") ) - return + 's/|//g')" -- "$cur")) ;; esac + return fi [[ $subcmd == help ]] && return case $cmd in - l|link) + l | link) case $subcmd in add) # TODO ;; delete) - case $(($cword-$subcword)) in + case $((cword - subcword)) in 1) _available_interfaces ;; 2) - COMPREPLY=( $(compgen -W 'type' -- "$cur") ) + COMPREPLY=($(compgen -W 'type' -- "$cur")) ;; 3) - [[ $prev == type ]] && \ - COMPREPLY=( $(compgen -W 'vlan veth vcan dummy - ifb macvlan can' -- "$cur") ) + [[ $prev == type ]] && + COMPREPLY=($(compgen -W 'vlan veth vcan dummy + ifb macvlan can' -- "$cur")) ;; esac ;; set) - if [[ $cword-$subcword -eq 1 ]]; then + if ((cword - subcword == 1)); then _available_interfaces else case $prev in - arp|dynamic|multicast|allmulticast|promisc|\ - trailers) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) - ;; - txqueuelen|name|address|broadcast|mtu|netns|alias) + arp | dynamic | multicast | allmulticast | promisc | \ + trailers) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) ;; + txqueuelen | name | address | broadcast | mtu | netns | alias) ;; + *) local c="arp dynamic multicast allmulticast promisc trailers txqueuelen name address broadcast mtu netns alias" [[ $prev != @(up|down) ]] && c+=" up down" - COMPREPLY=( $(compgen -W "$c" -- "$cur") ) + COMPREPLY=($(compgen -W "$c" -- "$cur")) ;; esac fi ;; show) - if [[ $cword -eq $subcword+1 ]]; then + if ((cword == subcword + 1)); then _available_interfaces - COMPREPLY+=( $(compgen -W 'dev group up' -- "$cur") ) + COMPREPLY+=($(compgen -W 'dev group up' -- "$cur")) elif [[ $prev == dev ]]; then _available_interfaces elif [[ $prev == group ]]; then @@ -114,16 +113,16 @@ _ip() fi ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help add delete set show' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add delete set show' \ + -- "$cur")) ;; esac ;; - a|addr|address) + a | addr | address) case $subcmd in - add|change|replace) + add | change | replace) if [[ $prev == dev ]]; then _available_interfaces elif [[ $prev == scope ]]; then @@ -141,12 +140,12 @@ _ip() : # TODO fi ;; - show|flush) - if [[ $cword -eq $subcword+1 ]]; then + show | flush) + if ((cword == subcword + 1)); then _available_interfaces - COMPREPLY+=( $(compgen -W 'dev scope to label dynamic + COMPREPLY+=($(compgen -W 'dev scope to label dynamic permanent tentative deprecated dadfailed temporary - primary secondary up' -- "$cur") ) + primary secondary up' -- "$cur")) elif [[ $prev == dev ]]; then _available_interfaces elif [[ $prev == scope ]]; then @@ -154,16 +153,16 @@ _ip() fi ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help add change replace del - show flush' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add change replace del + show flush' -- "$cur")) ;; esac ;; addrlabel) case $subcmd in - list|add|del|flush) + list | add | del | flush) if [[ $prev == dev ]]; then _available_interfaces else @@ -171,16 +170,16 @@ _ip() fi ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help list add del flush' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help list add del flush' \ + -- "$cur")) ;; esac ;; - route) + r | route) case $subcmd in - list|flush) + list | flush) if [[ $prev == proto ]]; then _iproute2_etc rt_protos else @@ -190,44 +189,79 @@ _ip() get) # TODO ;; - add|del|change|append|replace|monitor) - # TODO + a | add | d | del | change | append | r | replace | monitor) + if [[ $prev == via ]]; then + COMPREPLY=($(compgen -W "$($1 r | command sed -ne \ + 's/.*via \([0-9.]*\).*/\1/p')" -- "$cur")) + elif [[ $prev == "$subcmd" ]]; then + COMPREPLY=($(compgen -W "table default \ + $($1 r | cut -d ' ' -f 1)" -- "$cur")) + elif [[ $prev == dev ]]; then + _available_interfaces -a + elif [[ $prev == table ]]; then + COMPREPLY=($(compgen -W 'local main default' -- "$cur")) + else + COMPREPLY=($(compgen -W 'via dev weight' -- "$cur")) + fi ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help list flush get add del - change append replace monitor' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help list flush get add del + change append replace monitor' -- "$cur")) ;; esac ;; rule) case $subcmd in - add|del) - # TODO + add | del | list | lst) + case $prev in + from | to | tos | dsfield | fwmark | uidrange | ipproto | sport | \ + dport | priority | protocol | suppress_prefixlength | \ + suppress_ifgroup | realms | nat | goto) ;; + + iif | oif) + _available_interfaces -a + ;; + table | lookup) + COMPREPLY=($(compgen -W 'local main default' -- "$cur")) + ;; + *) + COMPREPLY=($(compgen -W 'from to tos dsfield fwmark + uidrange ipproto sport dport priority table lookup + protocol suppress_prefixlength suppress_ifgroup realms + nat goto iif oif not' -- "$cur")) + ;; + esac ;; - flush|show|list|lst) + flush | save) + if [[ $prev == protocol ]]; then + : + else + COMPREPLY=($(compgen -W 'protocol' -- "$cur")) + fi ;; + restore | show) ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help list add del flush' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add del list flush save + restore show' -- "$cur")) ;; esac ;; neigh) case $subcmd in - add|del|change|replace) + add | del | change | replace) # TODO ;; - show|flush) + show | flush) # TODO ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help add del change replace - show flush' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add del change replace + show flush' -- "$cur")) ;; esac ;; @@ -241,45 +275,45 @@ _ip() # TODO ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help change show' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help change show' \ + -- "$cur")) ;; esac ;; tunnel) case $subcmd in - show) - ;; - add|change|del|prl|6rd) + show) ;; + + add | change | del | prl | 6rd) # TODO ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help add change del show prl - 6rd' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add change del show prl + 6rd' -- "$cur")) ;; esac ;; maddr) case $subcmd in - add|del) + add | del) # TODO ;; show) if [[ $cword -eq $subcword+1 || $prev == dev ]]; then _available_interfaces - [[ $prev != dev ]] && \ - COMPREPLY=( $(compgen -W '${COMPREPLY[@]} dev' \ - -- "$cur") ) + [[ $prev != dev ]] && + COMPREPLY=($(compgen -W '${COMPREPLY[@]} dev' \ + -- "$cur")) fi ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help add del show' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add del show' \ + -- "$cur")) ;; esac ;; @@ -290,8 +324,8 @@ _ip() # TODO ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help show' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help show' -- "$cur")) ;; esac ;; @@ -300,26 +334,45 @@ _ip() case $subcmd in all) ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help all' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help all' -- "$cur")) + ;; + esac + ;; + + netns) + case $subcmd in + list | monitor) ;; + + add | identify | list-id) + # TODO + ;; + delete | exec | pids | set) + [[ $prev == "$subcmd" ]] && + COMPREPLY=($(compgen -W "$($1 netns list)" -- "$cur")) + ;; + *) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add delete exec + identify list list-id monitor pids set' -- "$cur")) ;; esac ;; xfrm) case $subcmd in - state|policy|monitor) + state | policy | monitor) # TODO ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'state policy monitor' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'state policy monitor' \ + -- "$cur")) ;; esac ;; esac } && -complete -F _ip ip + complete -F _ip ip # ex: filetype=sh diff --git a/completions/ipcalc b/completions/ipcalc new file mode 100644 index 00000000..5603c26c --- /dev/null +++ b/completions/ipcalc @@ -0,0 +1,25 @@ +# ipcalc(1) completion -*- shell-script -*- + +_ipcalc() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help | --version | --split | -[hs]) + return + ;; + esac + + # --split takes 3 args + local i + for i in {1..3}; do + [[ ${words[cword - i]} == -@(-split|s) ]] && return + done + + [[ $cur != -* ]] || + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) +} && + complete -F _ipcalc ipcalc + +# ex: filetype=sh diff --git a/completions/iperf b/completions/iperf index 43f9bcaf..6347fe00 100644 --- a/completions/iperf +++ b/completions/iperf @@ -6,36 +6,36 @@ _iperf() _init_completion -s -n : || return case $prev in - --help|--version|--interval|--len|--port|--window|--mss|--bandwidth|\ - --num|--time|--listenport|--parallel|--ttl|--linux-congestion|--omit|\ - --congestion|--bytes|--blockcount|--cport|--set-mss|--flowlabel|\ - --title|--tos|--affinity|-!(-*)[hvilpwMbntLPTZCkOSA]) + --help | --version | --interval | --len | --port | --window | --mss | --bandwidth | \ + --num | --time | --listenport | --parallel | --ttl | --linux-congestion | --omit | \ + --congestion | --bytes | --blockcount | --cport | --set-mss | --flowlabel | \ + --title | --tos | --affinity | -!(-*)[hvilpwMbntLPTZCkOSA]) return ;; - --format|-!(-*)f) - COMPREPLY=( $(compgen -W 'k m g K M G' -- "$cur") ) + --format | -!(-*)f) + COMPREPLY=($(compgen -W 'k m g K M G' -- "$cur")) return ;; - --output|--fileinput|-!(-*)[oF]) + --output | --fileinput | -!(-*)[oF]) _filedir return ;; - --bind|-!(-*)B) + --bind | -!(-*)B) _available_interfaces -a _ip_addresses -a __ltrim_colon_completions "$cur" return ;; - --client|-!(-*)c) + --client | -!(-*)c) _known_hosts_real -- "$cur" return ;; - --reportexclude|-!(-*)x) - COMPREPLY=( $(compgen -W 'C D M S V' -- "$cur") ) + --reportexclude | -!(-*)x) + COMPREPLY=($(compgen -W 'C D M S V' -- "$cur")) return ;; - --reportstyle|-!(-*)y) - COMPREPLY=( $(compgen -W 'C' -- "$cur") ) + --reportstyle | -!(-*)y) + COMPREPLY=($(compgen -W 'C' -- "$cur")) return ;; --logfile) @@ -50,20 +50,20 @@ _iperf() local i filter=cat for i in "${words[@]}"; do case $i in - -s|--server) + -s | --server) filter='command sed -e /^Client.specific/,/^\(Server.specific.*\)\?$/d' ;; - -c|--client) + -c | --client) filter='command sed -e /^Server.specific/,/^\(Client.specific.*\)\?$/d' ;; esac done [[ $filter != cat ]] && filter+=' -e /--client/d -e /--server/d' - COMPREPLY=( $(compgen -W \ - '$("$1" --help 2>&1 | $filter | _parse_help -)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W \ + '$("$1" --help 2>&1 | $filter | _parse_help -)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _iperf iperf iperf3 + complete -F _iperf iperf iperf3 # ex: filetype=sh diff --git a/completions/ipmitool b/completions/ipmitool index f6307cfa..920287dd 100644 --- a/completions/ipmitool +++ b/completions/ipmitool @@ -2,8 +2,8 @@ _ipmitool_singleline_help() { - COMPREPLY=( $(compgen -W "$($1 $2 2>&1 | \ - command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 $2 2>&1 | + command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p')" -- "$cur")) } _ipmitool() @@ -16,17 +16,18 @@ _ipmitool() return ;; -*d) - COMPREPLY=( $(compgen -W "$(\ + COMPREPLY=($(compgen -W "$( command ls -d /dev/ipmi* /dev/ipmi/* /dev/ipmidev/* \ - 2>/dev/null | command sed -ne 's/^[^0-9]*\([0-9]\{1,\}\)/\1/p')" \ - -- "$cur") ) + 2>/dev/null | command sed -ne 's/^[^0-9]*\([0-9]\{1,\}\)/\1/p' + )" \ + -- "$cur")) return ;; -*I) - COMPREPLY=( $(compgen -W "$($1 -h 2>&1 | \ + COMPREPLY=($(compgen -W "$($1 -h 2>&1 | command sed -e '/^Interfaces:/,/^[[:space:]]*$/!d' \ - -ne 's/^[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*/\1/p')" \ - -- "$cur") ) + -ne 's/^[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*/\1/p')" \ + -- "$cur")) return ;; -*H) @@ -38,45 +39,45 @@ _ipmitool() return ;; -*C) - COMPREPLY=( $(compgen -W '{0..14}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..14}' -- "$cur")) return ;; -*L) - COMPREPLY=( $(compgen -W 'CALLBACK USER OPERATOR ADMINISTRATOR' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'CALLBACK USER OPERATOR ADMINISTRATOR' \ + -- "$cur")) return ;; -*A) - COMPREPLY=( $(compgen -W 'NONE PASSWORD MD2 MD5 OEM' -- "$cur") ) + COMPREPLY=($(compgen -W 'NONE PASSWORD MD2 MD5 OEM' -- "$cur")) return ;; -*o) - COMPREPLY=( $(compgen -W "$($1 -o list 2>&1 | \ - awk '/^[ \t]+/ { print $1 }') list" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 -o list 2>&1 | + awk '/^[ \t]+/ { print $1 }') list" -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) return fi # Find out command and subcommand - local cmds=( raw i2c spd lan chassis power event mc sdr sensor fru gendev + local cmds=(raw i2c spd lan chassis power event mc sdr sensor fru gendev sel pef sol tsol isol user channel session sunoem kontronoem picmg fwum firewall shell exec set hpm ekanalyzer) local i c cmd subcmd - for (( i=1; i < ${#words[@]}-1; i++ )); do - [[ -n $cmd ]] && subcmd=${words[i]} && break + for ((i = 1; i < ${#words[@]} - 1; i++)); do + [[ -v cmd ]] && subcmd=${words[i]} && break for c in "${cmds[@]}"; do - [[ ${words[i]} == $c ]] && cmd=$c && break + [[ ${words[i]} == "$c" ]] && cmd=$c && break done done - if [[ -z $cmd ]]; then - COMPREPLY=( $(compgen -W '${cmds[@]}' -- "$cur") ) + if [[ ! -v cmd ]]; then + COMPREPLY=($(compgen -W '${cmds[@]}' -- "$cur")) return fi @@ -84,43 +85,43 @@ _ipmitool() case $cmd in - shell) - ;; + shell) ;; - exec) + \ + exec) _filedir ;; - chassis|power|kontronoem|fwum) + chassis | power | kontronoem | fwum) _ipmitool_singleline_help $1 $cmd ;; lan) case $subcmd in - print|set) - ;; + print | set) ;; + alert) - [[ $prev == alert ]] && \ - COMPREPLY=( $(compgen -W 'print set' -- "$cur") ) + [[ $prev == alert ]] && + COMPREPLY=($(compgen -W 'print set' -- "$cur")) ;; stats) - [[ $prev == stats ]] && \ - COMPREPLY=( $(compgen -W 'print set' -- "$cur") ) + [[ $prev == stats ]] && + COMPREPLY=($(compgen -W 'print set' -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W 'print set alert stats' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'print set alert stats' \ + -- "$cur")) ;; esac ;; sdr) case $subcmd in - get|info|type|list|entity) - ;; + get | info | type | list | entity) ;; + elist) - COMPREPLY=( $(compgen -W 'all full compact event mclog fru - generic' -- "$cur") ) + COMPREPLY=($(compgen -W 'all full compact event mclog fru + generic' -- "$cur")) ;; dump) _filedir @@ -128,7 +129,7 @@ _ipmitool() fill) case $prev in fill) - COMPREPLY=( $(compgen -W 'sensors file' -- "$cur") ) + COMPREPLY=($(compgen -W 'sensors file' -- "$cur")) ;; file) _filedir @@ -136,63 +137,63 @@ _ipmitool() esac ;; *) - COMPREPLY=( $(compgen -W 'get info type list elist entity - dump fill' -- "$cur") ) + COMPREPLY=($(compgen -W 'get info type list elist entity + dump fill' -- "$cur")) ;; esac ;; sensor) case $subcmd in - list|get|thresh) - ;; + list | get | thresh) ;; + *) - COMPREPLY=( $(compgen -W 'list get thresh' -- "$cur") ) + COMPREPLY=($(compgen -W 'list get thresh' -- "$cur")) ;; esac ;; sel) case $subcmd in - info|clear|list|elist|delete) - ;; - add|save|writeraw|readraw) + info | clear | list | elist | delete) ;; + + add | save | writeraw | readraw) _filedir ;; time) - [[ $prev == time ]] && \ - COMPREPLY=( $(compgen -W 'get set' -- "$cur") ) + [[ $prev == time ]] && + COMPREPLY=($(compgen -W 'get set' -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W 'info clear list elist delete add - get save writeraw readraw time' -- "$cur") ) + COMPREPLY=($(compgen -W 'info clear list elist delete add + get save writeraw readraw time' -- "$cur")) ;; esac ;; user) case $subcmd in - summary|list|disable|enable|priv|test) - ;; + summary | list | disable | enable | priv | test) ;; + set) - [[ $prev == set ]] && \ - COMPREPLY=( $(compgen -W 'name password' -- "$cur") ) + [[ $prev == set ]] && + COMPREPLY=($(compgen -W 'name password' -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W 'summary list set disable enable - priv test' -- "$cur") ) + COMPREPLY=($(compgen -W 'summary list set disable enable + priv test' -- "$cur")) ;; esac ;; set) - [[ $prev == set ]] && \ - COMPREPLY=( $(compgen -W 'hostname username password privlvl - authtype localaddr targetaddr port csv verbose' -- "$cur") ) + [[ $prev == set ]] && + COMPREPLY=($(compgen -W 'hostname username password privlvl + authtype localaddr targetaddr port csv verbose' -- "$cur")) ;; esac } && -complete -F _ipmitool ipmitool + complete -F _ipmitool ipmitool # ex: filetype=sh diff --git a/completions/ipsec b/completions/ipsec index 00e6b7ea..4bc8cdf3 100644 --- a/completions/ipsec +++ b/completions/ipsec @@ -8,9 +8,9 @@ _ipsec_connections() local keyword name while read -r keyword name; do if [[ $keyword == [#]* ]]; then continue; fi - [[ $keyword == conn && $name != '%default' ]] && COMPREPLY+=( "$name" ) + [[ $keyword == conn && $name != '%default' ]] && COMPREPLY+=("$name") done - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) } _ipsec_freeswan() @@ -18,31 +18,31 @@ _ipsec_freeswan() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'auto barf eroute klipsdebug look manual + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'auto barf eroute klipsdebug look manual pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp - tncfg whack' -- "$cur") ) + tncfg whack' -- "$cur")) return fi case ${words[1]} in auto) - COMPREPLY=( $(compgen -W '--asynchronous --up --add --delete + COMPREPLY=($(compgen -W '--asynchronous --up --add --delete --replace --down --route --unroute --ready --status - --rereadsecrets' -- "$cur") ) + --rereadsecrets' -- "$cur")) ;; manual) - COMPREPLY=( $(compgen -W '--up --down --route --unroute --union' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '--up --down --route --unroute --union' \ + -- "$cur")) ;; ranbits) - COMPREPLY=( $(compgen -W '--quick --continuous --bytes' -- "$cur") ) + COMPREPLY=($(compgen -W '--quick --continuous --bytes' -- "$cur")) ;; setup) - COMPREPLY=( $(compgen -W '--start --stop --restart' -- "$cur") ) - ;; - *) + COMPREPLY=($(compgen -W '--start --stop --restart' -- "$cur")) ;; + *) ;; + esac } @@ -51,8 +51,8 @@ _ipsec_strongswan() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'down irdumm leases listaacerts listacerts + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'down irdumm leases listaacerts listacerts listalgs listall listcacerts listcainfos listcards listcerts listcrls listgroups listocsp listocspcerts listpubkeys openac pki pluto pool purgecerts purgecrls purgeike purgeocsp ready reload @@ -60,33 +60,33 @@ _ipsec_strongswan() rereadgroups rereadocspcerts rereadsecrets restart route scdecrypt scencrypt scepclient secrets start starter status statusall stop stroke unroute uci up update version whack --confdir --copyright - --directory --help --version --versioncode' -- "$cur") ) + --directory --help --version --versioncode' -- "$cur")) return fi case ${words[1]} in - down|route|status|statusall|unroute|up) + down | route | status | statusall | unroute | up) local confdir=$(ipsec --confdir) _ipsec_connections <"$confdir/ipsec.conf" ;; list*) - COMPREPLY=( $(compgen -W '--utc' -- "$cur") ) + COMPREPLY=($(compgen -W '--utc' -- "$cur")) ;; - restart|start) - COMPREPLY=( $(compgen -W '--attach-gdb --auto-update --debug - --debug-all --debug-more --nofork' -- "$cur") ) + restart | start) + COMPREPLY=($(compgen -W '--attach-gdb --auto-update --debug + --debug-all --debug-more --nofork' -- "$cur")) ;; pki) - COMPREPLY=( $(compgen -W '--gen --issue --keyid --print --pub - --req --self --signcrl --verify' -- "$cur") ) - ;; - pool) + COMPREPLY=($(compgen -W '--gen --issue --keyid --print --pub + --req --self --signcrl --verify' -- "$cur")) ;; + pool) ;; + irdumm) _filedir 'rb' ;; - *) - ;; + *) ;; + esac } diff --git a/completions/iptables b/completions/iptables index 69072613..ffb905b8 100644 --- a/completions/iptables +++ b/completions/iptables @@ -7,45 +7,45 @@ _iptables() local table chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p' - [[ "${words[*]}" =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] \ - && table="-t ${BASH_REMATCH[2]}" + [[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] && + table="-t ${BASH_REMATCH[2]}" case $prev in - -*[AIDRPFXLZ]) - COMPREPLY=( $(compgen -W '`"$1" $table -nL 2>/dev/null | \ - command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur") ) - ;; - -*t) - COMPREPLY=( $(compgen -W 'nat filter mangle' -- "$cur") ) - ;; - -j) - if [[ "$table" == "-t filter" || -z "$table" ]]; then - COMPREPLY=( $(compgen -W 'ACCEPT DROP LOG ULOG REJECT + -*[AIDRPFXLZ]) + COMPREPLY=($(compgen -W '`"$1" $table -nL 2>/dev/null | \ + command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur")) + ;; + -*t) + COMPREPLY=($(compgen -W 'nat filter mangle' -- "$cur")) + ;; + -j) + if [[ $table == "-t filter" || -z $table ]]; then + COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT `"$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 + "$cur")) + elif [[ $table == "-t nat" ]]; then + COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT MIRROR SNAT 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 + -- "$cur")) + elif [[ $table == "-t mangle" ]]; then + COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT MARK TOS `"$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 '$("$1" --help 2>&1 | - command sed -e "s/^\[\!\]//" | _parse_help -)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - fi - ;; + "$cur")) + fi + ;; + *) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$("$1" --help 2>&1 | + command sed -e "s/^\[\!\]//" | _parse_help -)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace + fi + ;; esac } && -complete -F _iptables iptables + complete -F _iptables iptables # ex: filetype=sh diff --git a/completions/ipv6calc b/completions/ipv6calc index 6a5771ef..c452c155 100644 --- a/completions/ipv6calc +++ b/completions/ipv6calc @@ -6,33 +6,33 @@ _ipv6calc() _init_completion -s || return case "$prev" in - --debug|-!(-*)d) + --debug | -!(-*)d) return ;; - --in|--out|--action|-!(-*)[IOA]) + --in | --out | --action | -!(-*)[IOA]) # With ipv6calc < 0.73.0, -m does nothing here, so use sed instead. - COMPREPLY=( $(compgen -W "$($1 "$prev" -h 2>&1 | \ + COMPREPLY=($(compgen -W "$($1 "$prev" -h 2>&1 | command sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p')" \ - -- "$cur") ) + -- "$cur")) return ;; - --db-geoip|--db-ip2location-ipv4|--db-ip2location-ipv6) + --db-geoip | --db-ip2location-ipv4 | --db-ip2location-ipv6) _filedir return ;; - --printstart|--printend) + --printstart | --printend) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$("$1" -h 2>&1 | - command sed -e "s/[][]//g" | _parse_help -)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$("$1" -h 2>&1 | + command sed -e "s/[][]//g" | _parse_help -)' -- "$cur")) fi } && -complete -F _ipv6calc ipv6calc + complete -F _ipv6calc ipv6calc # ex: filetype=sh diff --git a/completions/iscsiadm b/completions/iscsiadm index 1fa30db6..7786ddcd 100644 --- a/completions/iscsiadm +++ b/completions/iscsiadm @@ -6,21 +6,21 @@ _iscsiadm() _init_completion -s || return case $prev in - --mode|-!(-*)m) - COMPREPLY=( $(compgen -W 'discovery node session iface fw host' \ - -- "$cur") ) + --mode | -!(-*)m) + COMPREPLY=($(compgen -W 'discovery node session iface fw host' \ + -- "$cur")) return ;; - --op|-!(-*)o) - COMPREPLY=( $(compgen -W 'new delete update show' -- "$cur") ) + --op | -!(-*)o) + COMPREPLY=($(compgen -W 'new delete update show' -- "$cur")) return ;; - --type|-!(-*)t) - COMPREPLY=( $(compgen -W 'sendtargets st slp isns fw' -- "$cur") ) + --type | -!(-*)t) + COMPREPLY=($(compgen -W 'sendtargets st slp isns fw' -- "$cur")) return ;; - --loginall|--logoutall|-!(-*)[LU]) - COMPREPLY=( $(compgen -W 'all manual automatic' -- "$cur") ) + --loginall | --logoutall | -!(-*)[LU]) + COMPREPLY=($(compgen -W 'all manual automatic' -- "$cur")) return ;; esac @@ -28,7 +28,7 @@ _iscsiadm() $split && return local options - if [[ $cword -gt 1 ]]; then + if ((cword > 1)); then case ${words[2]} in discovery) @@ -59,8 +59,8 @@ _iscsiadm() options='--mode' fi - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) } && -complete -F _iscsiadm iscsiadm + complete -F _iscsiadm iscsiadm # ex: filetype=sh diff --git a/completions/isort b/completions/isort index e4a028be..2a84e257 100644 --- a/completions/isort +++ b/completions/isort @@ -6,36 +6,36 @@ _isort() _init_completion || return case $prev in - --help|--add-import|--builtin|--future|--from-first|-ff|\ - --force-grid-wrap|-fgw|--indent|--lines|--lines-after-imports|-lai|\ - --lines-between-types|-lbt|--line-ending|-le|--no-lines-before|-nlb|\ - --dont-skip|-ns|--thirdparty|--project|--remove-import|--skip|\ - --skip-glob|-sg|--settings-path|-sp|--top|--virtual-env|--line-width|\ - --wrap-length|-wl|-[habfiloprstw]) + --help | --add-import | --builtin | --future | --from-first | -ff | \ + --force-grid-wrap | -fgw | --indent | --lines | --lines-after-imports | -lai | \ + --lines-between-types | -lbt | --line-ending | -le | --no-lines-before | -nlb | \ + --dont-skip | -ns | --thirdparty | --project | --remove-import | --skip | \ + --skip-glob | -sg | --settings-path | -sp | --top | --virtual-env | --line-width | \ + --wrap-length | -wl | -[habfiloprstw]) return ;; - --jobs|-j) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + --jobs | -j) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; - --multi-line|-m) - COMPREPLY=( $(compgen -W '{0..5}' -- "$cur") ) + --multi-line | -m) + COMPREPLY=($(compgen -W '{0..5}' -- "$cur")) return ;; - --section-default|-sd) - COMPREPLY=( $(compgen -W 'FUTURE STDLIB THIRDPARTY FIRSTPARTY - LOCALFOLDER' -- "$cur") ) + --section-default | -sd) + COMPREPLY=($(compgen -W 'FUTURE STDLIB THIRDPARTY FIRSTPARTY + LOCALFOLDER' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir '@(py|pyi)' } && -complete -F _isort isort + complete -F _isort isort # ex: filetype=sh diff --git a/completions/isql b/completions/isql index 4bd24c41..4258c519 100644 --- a/completions/isql +++ b/completions/isql @@ -6,9 +6,9 @@ _isql() local cur prev words cword _init_completion || return - [[ -f $ODBCINI ]] \ - && COMPREPLY=( $(command grep "\[$cur" "$ODBCINI" | tr -d \[\]) ) + [[ -f $ODBCINI ]] && + COMPREPLY=($(command grep "\[$cur" "$ODBCINI" | tr -d \[\])) } && -complete -F _isql isql + complete -F _isql isql # ex: filetype=sh diff --git a/completions/iwconfig b/completions/iwconfig index 762ec2ea..aa8fbf39 100644 --- a/completions/iwconfig +++ b/completions/iwconfig @@ -7,84 +7,84 @@ _iwconfig() case $prev in mode) - COMPREPLY=( $(compgen -W 'managed ad-hoc master repeater secondary - monitor' -- "$cur") ) + COMPREPLY=($(compgen -W 'managed ad-hoc master repeater secondary + monitor' -- "$cur")) return ;; essid) - COMPREPLY=( $(compgen -W 'on off any' -- "$cur") ) + COMPREPLY=($(compgen -W 'on off any' -- "$cur")) if [[ -n ${COMP_IWLIST_SCAN:-} ]]; then - COMPREPLY+=( $(compgen -W \ - "$(iwlist ${words[1]} scan | \ - awk -F'\"' '/ESSID/ {print $2}')" -- "$cur") ) + COMPREPLY+=($(compgen -W \ + "$(iwlist ${words[1]} scan | + awk -F'\"' '/ESSID/ {print $2}')" -- "$cur")) fi return ;; nwid) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; channel) - COMPREPLY=( $(compgen -W "$(iwlist ${words[1]} channel | \ - awk '/^[ \t]*Channel/ {print $2}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(iwlist ${words[1]} channel | + awk '/^[ \t]*Channel/ {print $2}')" -- "$cur")) return ;; freq) - COMPREPLY=( $(compgen -W "$(iwlist ${words[1]} channel | \ - awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(iwlist ${words[1]} channel | + awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur")) return ;; ap) - COMPREPLY=( $(compgen -W 'on off any' -- "$cur") ) + COMPREPLY=($(compgen -W 'on off any' -- "$cur")) if [[ -n ${COMP_IWLIST_SCAN:-} ]]; then - COMPREPLY+=( $(compgen -W \ - "$(iwlist ${words[1]} scan | \ - awk -F ': ' '/Address/ {print $2}')" -- "$cur") ) + COMPREPLY+=($(compgen -W \ + "$(iwlist ${words[1]} scan | + awk -F ': ' '/Address/ {print $2}')" -- "$cur")) fi return ;; rate) - COMPREPLY=( $(compgen -W 'auto fixed' -- "$cur") ) - COMPREPLY+=( $(compgen -W \ - "$(iwlist ${words[1]} rate | \ - awk '/^[ \t]*[0-9]/ {print $1"M"}')" -- "$cur") ) + COMPREPLY=($(compgen -W 'auto fixed' -- "$cur")) + COMPREPLY+=($(compgen -W \ + "$(iwlist ${words[1]} rate | + awk '/^[ \t]*[0-9]/ {print $1"M"}')" -- "$cur")) return ;; - rts|frag) - COMPREPLY=( $(compgen -W 'auto fixed off' -- "$cur") ) + rts | frag) + COMPREPLY=($(compgen -W 'auto fixed off' -- "$cur")) return ;; - key|enc) - COMPREPLY=( $(compgen -W 'off on open restricted' -- "$cur") ) + key | enc) + COMPREPLY=($(compgen -W 'off on open restricted' -- "$cur")) return ;; power) - COMPREPLY=( $(compgen -W 'period timeout off on' -- "$cur") ) + COMPREPLY=($(compgen -W 'period timeout off on' -- "$cur")) return ;; txpower) - COMPREPLY=( $(compgen -W 'off on auto' -- "$cur") ) + COMPREPLY=($(compgen -W 'off on auto' -- "$cur")) return ;; retry) - COMPREPLY=( $(compgen -W 'limit lifetime' -- "$cur") ) + COMPREPLY=($(compgen -W 'limit lifetime' -- "$cur")) return ;; esac - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --version' -- "$cur")) else _available_interfaces -w fi else - COMPREPLY=( $(compgen -W 'essid nwid mode freq channel sens mode ap - nick rate rts frag enc key power txpower commit' -- "$cur") ) + COMPREPLY=($(compgen -W 'essid nwid mode freq channel sens mode ap + nick rate rts frag enc key power txpower commit' -- "$cur")) fi } && -complete -F _iwconfig iwconfig + complete -F _iwconfig iwconfig # ex: filetype=sh diff --git a/completions/iwlist b/completions/iwlist index 65e0b2fb..16aa39c9 100644 --- a/completions/iwlist +++ b/completions/iwlist @@ -5,18 +5,18 @@ _iwlist() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --version' -- "$cur")) else _available_interfaces -w fi else - COMPREPLY=( $(compgen -W 'scan scanning freq frequency channel rate + COMPREPLY=($(compgen -W 'scan scanning freq frequency channel rate bit bitrate key enc encryption power txpower retry ap accesspoint - peers event' -- "$cur") ) + peers event' -- "$cur")) fi } && -complete -F _iwlist iwlist + complete -F _iwlist iwlist # ex: filetype=sh diff --git a/completions/iwpriv b/completions/iwpriv index 83673b4e..4e382463 100644 --- a/completions/iwpriv +++ b/completions/iwpriv @@ -7,25 +7,25 @@ _iwpriv() case $prev in roam) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; port) - COMPREPLY=( $(compgen -W 'ad-hoc managed' -- "$cur") ) + COMPREPLY=($(compgen -W 'ad-hoc managed' -- "$cur")) return ;; esac - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --version' -- "$cur")) else _available_interfaces -w fi else - COMPREPLY=( $(compgen -W '--all roam port' -- "$cur") ) + COMPREPLY=($(compgen -W '--all roam port' -- "$cur")) fi } && -complete -F _iwpriv iwpriv + complete -F _iwpriv iwpriv # ex: filetype=sh diff --git a/completions/iwspy b/completions/iwspy index e4805116..38b7868e 100644 --- a/completions/iwspy +++ b/completions/iwspy @@ -5,16 +5,16 @@ _iwspy() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --version' -- "$cur")) else _available_interfaces -w fi else - COMPREPLY=( $(compgen -W 'setthr getthr off' -- "$cur") ) + COMPREPLY=($(compgen -W 'setthr getthr off' -- "$cur")) fi } && -complete -F _iwspy iwspy + complete -F _iwspy iwspy # ex: filetype=sh diff --git a/completions/jar b/completions/jar index c839aa85..22894917 100644 --- a/completions/jar +++ b/completions/jar @@ -5,8 +5,8 @@ _jar() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'c t x u' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'c t x u' -- "$cur")) return fi @@ -22,6 +22,6 @@ _jar() ;; esac } && -complete -F _jar jar + complete -F _jar jar # ex: filetype=sh diff --git a/completions/jarsigner b/completions/jarsigner index 171865b2..1f26c9c2 100644 --- a/completions/jarsigner +++ b/completions/jarsigner @@ -7,51 +7,51 @@ _jarsigner() case $prev in -keystore) - COMPREPLY=( $(compgen -W 'NONE' -- "$cur") ) + COMPREPLY=($(compgen -W 'NONE' -- "$cur")) _filedir '@(jks|ks|p12|pfx)' return ;; - -storepass|-keypass|-sigfile|-digestalg|-sigalg|-tsacert|-tsapolicyid|\ - -tsadigestalg|-altsigner|-altsignerpath|-providerName|-providerClass|\ - -providerArg) + -storepass | -keypass | -sigfile | -digestalg | -sigalg | -tsacert | -tsapolicyid | \ + -tsadigestalg | -altsigner | -altsignerpath | -providerName | -providerClass | \ + -providerArg) return ;; - -certchain|-sigfile|-tsa) + -certchain | -tsa) _filedir return ;; -storetype) - COMPREPLY=( $(compgen -W 'JKS PKCS11 PKCS12' -- "$cur") ) + COMPREPLY=($(compgen -W 'JKS PKCS11 PKCS12' -- "$cur")) return ;; -signedjar) - _filedir jar + _filedir '@(jar|apk)' return ;; esac # Check if a jar was already given. local i jar=false - for (( i=0; i < ${#words[@]}-1; i++ )) ; do - if [[ "${words[i]}" == *.jar && \ - "${words[i-1]}" != -signedjar ]]; then + for ((i = 1; i < ${#words[@]} - 1; i++)); do + if [[ ${words[i]} == *.@(jar|apk) && \ + ${words[i - 1]} != -signedjar ]]; then jar=true break fi done - if ! $jar ; then - if [[ "$cur" == -* ]]; then + if ! $jar; then + if [[ $cur == -* ]]; then # Documented as "should not be used": -internalsf, -sectionsonly - COMPREPLY=( $(compgen -W '-keystore -storepass -storetype + COMPREPLY=($(compgen -W '-keystore -storepass -storetype -keypass -sigfile -signedjar -digestalg -sigalg -verify -verbose -certs -tsa -tsacert -altsigner -altsignerpath -protected -providerName -providerClass -providerArg' \ - -- "$cur") ) + -- "$cur")) fi - _filedir jar + _filedir '@(jar|apk)' fi } && -complete -F _jarsigner jarsigner + complete -F _jarsigner jarsigner # ex: filetype=sh diff --git a/completions/java b/completions/java index 89d207d2..d0f70ae6 100644 --- a/completions/java +++ b/completions/java @@ -13,15 +13,15 @@ _java_find_classpath() local i # search first in current options - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -@(cp|classpath) ]]; then - classpath=${words[i+1]} + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -@(cp|classpath) ]]; then + classpath=${words[i + 1]} break fi done # default to environment - [[ -z $classpath ]] && classpath=$CLASSPATH + [[ ! -v classpath ]] && classpath=${CLASSPATH-} # default to current directory [[ -z $classpath ]] && classpath=. @@ -33,15 +33,15 @@ _java_find_sourcepath() local i # search first in current options - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -sourcepath ]]; then - sourcepath=${words[i+1]} + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -sourcepath ]]; then + sourcepath=${words[i + 1]} break fi done # default to classpath - if [[ -z $sourcepath ]]; then + if [[ ! -v sourcepath ]]; then local classpath _java_find_classpath sourcepath=$classpath @@ -60,27 +60,27 @@ _java_classes() cur=${cur//.//} # parse each classpath element for classes for i in ${classpath//:/ }; do - if [[ "$i" == *.@(jar|zip) && -r $i ]]; then + if [[ $i == *.@(jar|zip) && -r $i ]]; then if type zipinfo &>/dev/null; then - COMPREPLY+=( $(zipinfo -1 "$i" "$cur*" 2>/dev/null | \ - command grep '^[^$]*\.class$') ) + COMPREPLY+=($(zipinfo -1 "$i" "$cur*" 2>/dev/null | + command grep '^[^$]*\.class$')) elif type unzip &>/dev/null; then # Last column, between entries consisting entirely of dashes - COMPREPLY+=( $(unzip -lq "$i" "$cur*" 2>/dev/null | \ + COMPREPLY+=($(unzip -lq "$i" "$cur*" 2>/dev/null | awk '$NF ~ /^-+$/ { flag=!flag; next }; - flag && $NF ~ /^[^$]*\.class/ { print $NF }') ) + flag && $NF ~ /^[^$]*\.class/ { print $NF }')) elif type jar &>/dev/null; then - COMPREPLY+=( $(jar tf "$i" "$cur" | \ - command grep '^[^$]*\.class$') ) + COMPREPLY+=($(jar tf "$i" "$cur" | + command grep '^[^$]*\.class$')) fi elif [[ -d $i ]]; then COMPREPLY+=( $(compgen -d -- "$i/$cur" | command sed -e "s|^$i/\(.*\)|\1.|") - $(compgen -f -X '!*.class' -- "$i/$cur" | \ - command sed -e '/\$/d' -e "s|^$i/||") + $(compgen -f -X '!*.class' -- "$i/$cur" | + command sed -e '/\$/d' -e "s|^$i/||") ) - [[ $COMPREPLY == *.class ]] || compopt -o nospace + [[ ${COMPREPLY-} == *.class ]] || compopt -o nospace # FIXME: if we have foo.class and foo/, the completion # returns "foo/"... how to give precedence to files @@ -88,10 +88,12 @@ _java_classes() fi done - # remove class extension - COMPREPLY=( ${COMPREPLY[@]%.class} ) - # convert path syntax to package syntax - COMPREPLY=( ${COMPREPLY[@]//\//.} ) + if ((${#COMPREPLY[@]} != 0)); then + # remove class extension + COMPREPLY=(${COMPREPLY[@]%.class}) + # convert path syntax to package syntax + COMPREPLY=(${COMPREPLY[@]//\//.}) + fi } # available packages completion @@ -107,16 +109,18 @@ _java_packages() # parse each sourcepath element for packages for i in ${sourcepath//:/ }; do if [[ -d $i ]]; then - COMPREPLY+=( $(command ls -F -d $i/$cur* 2>/dev/null | \ - command sed -e 's|^'$i'/||') ) + COMPREPLY+=($(command ls -F -d $i/$cur* 2>/dev/null | + command sed -e 's|^'$i'/||')) fi done - # keep only packages - COMPREPLY=( $(tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$") ) - # remove packages extension - COMPREPLY=( ${COMPREPLY[@]%/} ) - # convert path syntax to package syntax - cur=${COMPREPLY[@]//\//.} + if ((${#COMPREPLY[@]} != 0)); then + # keep only packages + COMPREPLY=($(tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$")) + # remove packages extension + COMPREPLY=(${COMPREPLY[@]%/}) + # convert path syntax to package syntax + cur="${COMPREPLY[*]//\//.}" + fi } # java completion @@ -128,9 +132,9 @@ _java() local i - for ((i=1; i < $cword; i++)); do - case ${words[$i]} in - -cp|-classpath) + for ((i = 1; i < cword; i++)); do + case ${words[i]} in + -cp | -classpath) ((i++)) # skip the classpath string. ;; -*) @@ -147,7 +151,7 @@ _java() case $cur in # standard option completions -verbose:*) - COMPREPLY=( $(compgen -W 'class gc jni' -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'class gc jni' -- "${cur#*:}")) return ;; -javaagent:*) @@ -171,56 +175,56 @@ _java() return ;; -Xcheck:*) - COMPREPLY=( $(compgen -W 'jni' -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'jni' -- "${cur#*:}")) return ;; -Xgc:*) - COMPREPLY=( $(compgen -W 'singlecon gencon singlepar genpar' \ - -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'singlecon gencon singlepar genpar' \ + -- "${cur#*:}")) return ;; -Xgcprio:*) - COMPREPLY=( $(compgen -W 'throughput pausetime deterministic' \ - -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'throughput pausetime deterministic' \ + -- "${cur#*:}")) return ;; - -Xloggc:*|-Xverboselog:*) + -Xloggc:* | -Xverboselog:*) cur=${cur#*:} _filedir return ;; -Xshare:*) - COMPREPLY=( $(compgen -W 'auto off on' -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'auto off on' -- "${cur#*:}")) return ;; -Xverbose:*) - COMPREPLY=( $(compgen -W 'memory load jni cpuinfo codegen opt - gcpause gcreport' -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'memory load jni cpuinfo codegen opt + gcpause gcreport' -- "${cur#*:}")) return ;; -Xverify:*) - COMPREPLY=( $(compgen -W 'all none remote' -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'all none remote' -- "${cur#*:}")) return ;; # the rest that we have no completions for - -D*|-*:*) + -D* | -*:*) return ;; esac case $prev in - -cp|-classpath) + -cp | -classpath) _java_path return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - [[ $cur == -X* ]] && \ - COMPREPLY+=( $(compgen -W '$(_parse_help "$1" -X)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + [[ $cur == -X* ]] && + COMPREPLY+=($(compgen -W '$(_parse_help "$1" -X)' -- "$cur")) else - if [[ "$prev" == -jar ]]; then + if [[ $prev == -jar ]]; then # jar file completion _filedir '[jw]ar' else @@ -229,11 +233,11 @@ _java() fi fi - [[ $COMPREPLY == -*[:=] ]] && compopt -o nospace + [[ ${COMPREPLY-} == -*[:=] ]] && compopt -o nospace __ltrim_colon_completions "$cur" } && -complete -F _java java + complete -F _java java _javadoc() { @@ -241,42 +245,38 @@ _javadoc() _init_completion || return case $prev in - -overview|-helpfile) + -overview | -helpfile) _filedir '?(x)htm?(l)' return ;; - -doclet|-exclude|-subpackages|-source|-locale|-encoding|-windowtitle|\ - -doctitle|-header|-footer|-top|-bottom|-group|-noqualifier|-tag|\ - -charset|-sourcetab|-docencoding) + -doclet | -exclude | -subpackages | -source | -locale | -encoding | -windowtitle | \ + -doctitle | -header | -footer | -top | -bottom | -group | -noqualifier | -tag | \ + -charset | -sourcetab | -docencoding) return ;; -stylesheetfile) _filedir css return ;; - -d|-link|-linkoffline) + -d | -link | -linkoffline) _filedir -d return ;; - -classpath|-cp|-bootclasspath|-docletpath|-sourcepath|-extdirs|\ - -excludedocfilessubdir) + -classpath | -cp | -bootclasspath | -docletpath | -sourcepath | -extdirs | \ + -excludedocfilessubdir) _java_path return ;; - -helpfile) - _filedir - return - ;; esac # -linkoffline takes two arguments - if [[ $cword -gt 2 && ${words[$cword-2]} == -linkoffline ]]; then + if [[ $cword -gt 2 && ${words[cword - 2]} == -linkoffline ]]; then _filedir -d return fi - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) else # source files completion _filedir java @@ -284,7 +284,7 @@ _javadoc() _java_packages fi } && -complete -F _javadoc javadoc + complete -F _javadoc javadoc _javac() { @@ -296,13 +296,13 @@ _javac() _filedir -d return ;; - -cp|-classpath|-bootclasspath|-sourcepath|-extdirs) + -cp | -classpath | -bootclasspath | -sourcepath | -extdirs) _java_path return ;; esac - if [[ $cur == -+([a-zA-z0-9-_]):* ]]; then + if [[ $cur == -+([a-zA-Z0-9-_]):* ]]; then # Parse required options from -foo:{bar,quux,baz} local helpopt=-help [[ $cur == -X* ]] && helpopt=-X @@ -311,23 +311,23 @@ _javac() # the others. local opts=$("$1" $helpopt 2>&1 | command sed -e 's/-g:none/-g:{none}/' -ne \ "s/^[[:space:]]*${cur%%:*}:{\([^}]\{1,\}\)}.*/\1/p") - COMPREPLY=( $(compgen -W "${opts//,/ }" -- "${cur#*:}") ) + COMPREPLY=($(compgen -W "${opts//,/ }" -- "${cur#*:}")) return fi - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - [[ $cur == -X* ]] && \ - COMPREPLY+=( $(compgen -W '$(_parse_help "$1" -X)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + [[ $cur == -X* ]] && + COMPREPLY+=($(compgen -W '$(_parse_help "$1" -X)' -- "$cur")) else # source files completion _filedir java fi - [[ $COMPREPLY == -*[:=] ]] && compopt -o nospace + [[ ${COMPREPLY-} == -*[:=] ]] && compopt -o nospace __ltrim_colon_completions "$cur" } && -complete -F _javac javac + complete -F _javac javac # ex: filetype=sh diff --git a/completions/javaws b/completions/javaws index c21d3ac4..f42a1e55 100644 --- a/completions/javaws +++ b/completions/javaws @@ -6,14 +6,14 @@ _javaws() _init_completion -n = || return case $prev in - -help|-license|-about|-viewer|-arg|-param|-property|-update|-umask) + -help | -license | -about | -viewer | -arg | -param | -property | -update | -umask) return ;; - -basedir|-codebase) + -basedir | -codebase) _filedir -d return ;; - -uninstall|-import) + -uninstall | -import) _filedir jnlp return ;; @@ -22,13 +22,13 @@ _javaws() if [[ $cur == *= ]]; then return elif [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W "$(_parse_help "$1" -help) " -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W "$(_parse_help "$1" -help) " -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir jnlp } && -complete -F _javaws javaws + complete -F _javaws javaws # ex: filetype=sh diff --git a/completions/jpegoptim b/completions/jpegoptim index 044cc753..c3669721 100644 --- a/completions/jpegoptim +++ b/completions/jpegoptim @@ -6,19 +6,19 @@ _jpegoptim() _init_completion -s || return case $prev in - --help|--version|-!(-*)[hV]*) + --help | --version | -!(-*)[hV]*) return ;; - --dest|-!(-*)d) + --dest | -!(-*)d) _filedir -d return ;; - --max|--threshold|-!(-*)[mT]) - COMPREPLY=( $(compgen -W '{0..100}' -- "$cur") ) + --max | --threshold | -!(-*)[mT]) + COMPREPLY=($(compgen -W '{0..100}' -- "$cur")) return ;; - --size|-!(-*)S) - COMPREPLY=( $(compgen -W '{1..99}%' -- "$cur") ) + --size | -!(-*)S) + COMPREPLY=($(compgen -W '{1..99}%' -- "$cur")) return ;; esac @@ -26,13 +26,13 @@ _jpegoptim() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir 'jp?(e)g' } && -complete -F _jpegoptim jpegoptim + complete -F _jpegoptim jpegoptim # ex: filetype=sh diff --git a/completions/jps b/completions/jps index a6a60299..a451eec1 100644 --- a/completions/jps +++ b/completions/jps @@ -6,7 +6,7 @@ _jps() _init_completion || return case $prev in - -J*|-help) + -J* | -help) return ;; esac @@ -14,12 +14,12 @@ _jps() if [[ $cur == -* ]]; then # Not using _parse_usage because output has [-help] which does not # mean -h, -e, -l, -p... - COMPREPLY=( $(compgen -W "-q -m -l -v -V -J -help" -- "$cur") ) - [[ $COMPREPLY == -J* ]] && compopt -o nospace + COMPREPLY=($(compgen -W "-q -m -l -v -V -J -help" -- "$cur")) + [[ ${COMPREPLY-} == -J* ]] && compopt -o nospace else _known_hosts_real -- "$cur" fi } && -complete -F _jps jps + complete -F _jps jps # ex: filetype=sh diff --git a/completions/jq b/completions/jq index 3fdbfb0c..2d99c391 100644 --- a/completions/jq +++ b/completions/jq @@ -6,14 +6,14 @@ _jq() _init_completion || return case $prev in - --help|--version|--arg|--argjson|--slurpfile|--argfile) + --help | --version | --arg | --argjson | --slurpfile | --argfile) return ;; --indent) - COMPREPLY=( $(compgen -W '{1..8}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..8}' -- "$cur")) return ;; - --from-file|--run-tests|-!(-*)f) + --from-file | --run-tests | -!(-*)f) _filedir return ;; @@ -23,19 +23,19 @@ _jq() ;; esac - (( cword > 2 )) && \ - case ${words[cword-2]} in - --arg|--argjson) - return - ;; - --slurpfile|--argfile) - _filedir json - return - ;; - esac + ((cword > 2)) && + case ${words[cword - 2]} in + --arg | --argjson) + return + ;; + --slurpfile | --argfile) + _filedir json + return + ;; + esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi @@ -44,11 +44,11 @@ _jq() _count_args "" "@(--arg|--arg?(json|file)|--?(slurp|from-)file|--indent|--run-tests|-!(-*)[fL])" # 1st arg is filter - [[ $args -eq 1 ]] && return + ((args == 1)) && return # 2... are input files _filedir json } && -complete -F _jq jq + complete -F _jq jq # ex: filetype=sh diff --git a/completions/jshint b/completions/jshint index ee89070a..3622cecf 100644 --- a/completions/jshint +++ b/completions/jshint @@ -6,19 +6,19 @@ _jshint() _init_completion -s || return case $prev in - -v|--version|-h|--help|--exclude|--filename|-e|--extra-ext) + -v | --version | -h | --help | --exclude | --filename | -e | --extra-ext) return ;; - -c|--config) + -c | --config) _filedir return ;; --reporter) - COMPREPLY=( $(compgen -W "jslint checkstyle unix" -- "$cur") ) + COMPREPLY=($(compgen -W "jslint checkstyle unix" -- "$cur")) return ;; --extract) - COMPREPLY=( $(compgen -W "auto always never" -- "$cur") ) + COMPREPLY=($(compgen -W "auto always never" -- "$cur")) return ;; esac @@ -26,13 +26,13 @@ _jshint() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir js } && -complete -F _jshint jshint + complete -F _jshint jshint # ex: filetype=sh diff --git a/completions/json_xs b/completions/json_xs index 98d0ba63..c93ba864 100644 --- a/completions/json_xs +++ b/completions/json_xs @@ -7,15 +7,15 @@ _json_xs() case $prev in -*f) - COMPREPLY=( $(compgen -W 'json cbor storable storable-file bencode - clzf eval yaml string none' -- "$cur") ) + COMPREPLY=($(compgen -W 'json cbor storable storable-file bencode + clzf eval yaml string none' -- "$cur")) return ;; -*t) - COMPREPLY=( $(compgen -W 'json json-utf-8 json-pretty + COMPREPLY=($(compgen -W 'json json-utf-8 json-pretty json-utf-16le json-utf-16be json-utf-32le json-utf-32be cbor storable storable-file bencode clzf yaml dump dumper - string none' -- "$cur") ) + string none' -- "$cur")) return ;; -*e) @@ -24,8 +24,8 @@ _json_xs() esac [[ $cur == -* ]] && - COMPREPLY=( $(compgen -W '$(_parse_usage "$1") -f' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1") -f' -- "$cur")) } && -complete -F _json_xs json_xs + complete -F _json_xs json_xs # ex: filetype=sh diff --git a/completions/jsonschema b/completions/jsonschema index 441977e4..8a36ed36 100644 --- a/completions/jsonschema +++ b/completions/jsonschema @@ -6,24 +6,25 @@ _jsonschema() _init_completion || return case $prev in - --help|--error-format|--validator|-[hFV]) + --help | --error-format | --validator | -[hFV]) return ;; - --instance|-i) + --instance | -i) _filedir json return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - local args; _count_args "" "-*" - [[ $args -eq 1 ]] || return + local args + _count_args "" "-*" + ((args == 1)) || return _filedir '@(json|schema)' } && -complete -F _jsonschema jsonschema + complete -F _jsonschema jsonschema # ex: filetype=sh diff --git a/completions/k3b b/completions/k3b index b52e6de0..87d26cdc 100644 --- a/completions/k3b +++ b/completions/k3b @@ -6,23 +6,23 @@ _k3b() _init_completion || return case $prev in - --help*|--author|-v|--version|--license|--lang) + --help* | --author | -v | --version | --license | --lang) return ;; - --datacd|--audiocd|--videocd|--mixedcd|--emovixcd|--videodvd) + --datacd | --audiocd | --videocd | --mixedcd | --emovixcd | --videodvd) _filedir return ;; - --copydvd|--formatdvd|--videodvdrip) + --copydvd | --formatdvd | --videodvdrip) _dvd_devices return ;; - --copycd|--erasecd|--cddarip|--videocdrip) + --copycd | --erasecd | --cddarip | --videocdrip) _cd_devices _dvd_devices return ;; - --cdimage|--image) + --cdimage | --image) _filedir '@(cue|iso|toc)' return ;; @@ -31,18 +31,18 @@ _k3b() return ;; --ao) - COMPREPLY=( $(compgen -W 'alsa arts' -- "$cur") ) + COMPREPLY=($(compgen -W 'alsa arts' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$(_parse_help "$1")" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir fi } && -complete -F _k3b k3b + complete -F _k3b k3b # ex: filetype=sh diff --git a/completions/kcov b/completions/kcov index 8490a969..672967af 100644 --- a/completions/kcov +++ b/completions/kcov @@ -6,21 +6,21 @@ _kcov() _init_completion -s -n : || return case "$prev" in - --pid|-p) + --pid | -p) _pids return ;; - --sort-type|-s) - COMPREPLY=( $(compgen -W 'filename percent reverse lines - uncovered' -- "$cur") ) + --sort-type | -s) + COMPREPLY=($(compgen -W 'filename percent reverse lines + uncovered' -- "$cur")) return ;; - --include-path|--exclude-path) + --include-path | --exclude-path) _filedir return ;; --replace-src-path) - if [[ "$cur" == ?*:* ]]; then + if [[ $cur == ?*:* ]]; then cur="${cur##*:}" _filedir else @@ -29,21 +29,21 @@ _kcov() fi return ;; - --limits|-l) - if [[ "$cur" == ?*,* ]]; then + --limits | -l) + if [[ $cur == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" - COMPREPLY=( $(compgen -W "{0..100}" -- "$cur") ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && \ - COMPREPLY=( ${COMPREPLY/#/$prev,} ) + COMPREPLY=($(compgen -W "{0..100}" -- "$cur")) + ((${#COMPREPLY[@]} == 1)) && + COMPREPLY=(${COMPREPLY/#/$prev,}) else - COMPREPLY=( $(compgen -W "{0..100}" -- "$cur") ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/%/,} ) + COMPREPLY=($(compgen -W "{0..100}" -- "$cur")) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/%/,}) compopt -o nospace fi return ;; - --title|-t|--include-pattern|--exclude-pattern|--path-strip-level) + --title | -t | --include-pattern | --exclude-pattern | --path-strip-level) # argument required but no completions available return ;; @@ -51,14 +51,14 @@ _kcov() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _kcov kcov + complete -F _kcov kcov # ex: filetype=sh diff --git a/completions/kill b/completions/kill index 4cd5f911..25cddbad 100644 --- a/completions/kill +++ b/completions/kill @@ -15,15 +15,15 @@ _kill() ;; esac - if [[ $cword -eq 1 && "$cur" == -* ]]; then + if [[ $cword -eq 1 && $cur == -* ]]; then # return list of available signals _signals - - COMPREPLY+=( $(compgen -W "-s -l" -- "$cur") ) + COMPREPLY+=($(compgen -W "-s -l" -- "$cur")) else # return list of available PIDs _pids fi } && -complete -F _kill kill + complete -F _kill kill # ex: filetype=sh diff --git a/completions/killall b/completions/killall index e1b56ce1..c7c0b0fc 100644 --- a/completions/killall +++ b/completions/killall @@ -8,14 +8,14 @@ _killall() _init_completion -s || return case $prev in - --context|--older-than|--younger-than|--version|-!(-*)@([Zoy]|V*)) + --context | --older-than | --younger-than | --version | -!(-*)@([Zoy]|V*)) return ;; - --signal|-!(-*)s) + --signal | -!(-*)s) _signals return ;; - --user|-!(-*)u) + --user | -!(-*)u) _allowed_users return ;; @@ -24,13 +24,13 @@ _killall() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $cword -eq 1 ]] && _signals - + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + ((cword == 1)) && _signals - return fi _pnames } && -complete -F _killall killall + complete -F _killall killall # ex: filetype=sh diff --git a/completions/kldload b/completions/kldload index 4817679e..f5111584 100644 --- a/completions/kldload +++ b/completions/kldload @@ -11,11 +11,11 @@ _kldload() [[ -d $moddir ]] || moddir=/boot/kernel/ compopt -o filenames - COMPREPLY=( $(compgen -f "$moddir$cur") ) - COMPREPLY=( ${COMPREPLY[@]#$moddir} ) - COMPREPLY=( ${COMPREPLY[@]%.ko} ) + COMPREPLY=($(compgen -f "$moddir$cur")) + COMPREPLY=(${COMPREPLY[@]#$moddir}) + COMPREPLY=(${COMPREPLY[@]%.ko}) } && -complete -F _kldload kldload + complete -F _kldload kldload # ex: filetype=sh diff --git a/completions/kldunload b/completions/kldunload index e1462677..2e12282c 100644 --- a/completions/kldunload +++ b/completions/kldunload @@ -7,9 +7,9 @@ _kldunload() local cur prev words cword _init_completion || return - COMPREPLY=( $(compgen -W '$(kldstat)' -X 'kernel' -X '!*.ko' -- "$cur") ) - COMPREPLY=( ${COMPREPLY[@]%.ko} ) + COMPREPLY=($(compgen -W '$(kldstat)' -X 'kernel' -X '!*.ko' -- "$cur")) + COMPREPLY=(${COMPREPLY[@]%.ko}) } && -complete -F _kldunload kldunload + complete -F _kldunload kldunload # ex: filetype=sh diff --git a/completions/koji b/completions/koji index be43f0a2..8efef9a7 100644 --- a/completions/koji +++ b/completions/koji @@ -2,8 +2,8 @@ _koji_search() { - COMPREPLY+=( $(compgen -W \ - '$("$1" -q search $2 "$cur*" 2>/dev/null)' -- "$cur") ) + COMPREPLY+=($(compgen -W \ + '$("$1" -q search $2 "$cur*" 2>/dev/null)' -- "$cur")) } _koji_build() @@ -23,13 +23,13 @@ _koji_user() _koji_tag() { - COMPREPLY+=( $(compgen -W '$("$1" -q list-tags 2>/dev/null)' -- "$cur") ) + COMPREPLY+=($(compgen -W '$("$1" -q list-tags 2>/dev/null)' -- "$cur")) } _koji_target() { - COMPREPLY+=( $(compgen -W '$("$1" -q list-targets 2>/dev/null | - awk "{ print \$1 }")' -- "$cur") ) + COMPREPLY+=($(compgen -W '$("$1" -q list-targets 2>/dev/null | + awk "{ print \$1 }")' -- "$cur")) } _koji() @@ -38,7 +38,7 @@ _koji() _init_completion -s || return local commandix command - for (( commandix=1; commandix < cword; commandix++ )); do + for ((commandix = 1; commandix < cword; commandix++)); do if [[ ${words[commandix]} != -* ]]; then command=${words[commandix]} break @@ -46,19 +46,19 @@ _koji() done case $prev in - --help|--help-commands|-!(-*)h*) + --help | --help-commands | -!(-*)h*) return ;; - --config|--keytab|-!(-*)[co]) + --config | --keytab | -!(-*)[co]) _filedir return ;; - --runas|--user|--editor|--by) + --runas | --user | --editor | --by) _koji_user "$1" return ;; --authtype) - COMPREPLY=( $(compgen -W 'noauth ssl password kerberos' -- "$cur") ) + COMPREPLY=($(compgen -W 'noauth ssl password kerberos' -- "$cur")) return ;; --topdir) @@ -66,15 +66,15 @@ _koji() return ;; --type) - case $command in - latest-pkg|list-tagged) - COMPREPLY=( $(compgen -W 'maven' -- "$cur") ) + case ${command-} in + latest-pkg | list-tagged) + COMPREPLY=($(compgen -W 'maven' -- "$cur")) ;; esac return ;; --name) - case $command in + case ${command-} in list-targets) _koji_target "$1" ;; @@ -85,7 +85,7 @@ _koji() _koji_user "$1" return ;; - --tag|--latestfrom) + --tag | --latestfrom) _koji_tag "$1" return ;; @@ -105,22 +105,22 @@ _koji() $split && return - if [[ $command ]]; then + if [[ -v command ]]; then if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W \ - '$(_parse_help "$1" "$command --help")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W \ + '$(_parse_help "$1" "$command --help")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi # How many'th non-option arg (1-based) for $command are we completing? local i nth=1 - for (( i=commandix+1; i < cword; i++ )); do - [[ ${words[i]} == -* ]] || (( nth++ )) + for ((i = commandix + 1; i < cword; i++)); do + [[ ${words[i]} == -* ]] || ((nth++)) done case $command in - build|maven-build|win-build) + build | maven-build | win-build) case $nth in 1) _koji_target "$1" @@ -160,7 +160,7 @@ _koji() latest-by-tag) _koji_package "$1" ;; - latest-pkg|list-groups|list-tag-inheritance|show-groups) + latest-pkg | list-groups | list-tag-inheritance | show-groups) case $nth in 1) _koji_tag "$1" @@ -186,7 +186,7 @@ _koji() ;; move-pkg) case $nth in - 1|2) + 1 | 2) _koji_tag "$1" ;; *) @@ -197,12 +197,12 @@ _koji() search) case $nth in 1) - COMPREPLY=( $(compgen -W 'package build tag target - user host rpm' -- "$cur") ) + COMPREPLY=($(compgen -W 'package build tag target + user host rpm' -- "$cur")) ;; esac ;; - tag-pkg|untag-pkg) + tag-pkg | untag-pkg) case $nth in 1) _koji_tag "$1" @@ -218,7 +218,7 @@ _koji() wait-repo) case $nth in 1) - for (( i=commandix+1; i < cword; i++ )); do + for ((i = commandix + 1; i < cword; i++)); do if [[ ${words[i]} == --target ]]; then _koji_target "$1" return @@ -233,13 +233,13 @@ _koji() fi if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - elif [[ ! $command ]]; then - COMPREPLY=( $(compgen -W '$("$1" --help-commands 2>/dev/null | \ - awk "/^( +|\t)/ { print \$1 }")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace + elif [[ ! -v command ]]; then + COMPREPLY=($(compgen -W '$("$1" --help-commands 2>/dev/null | \ + awk "/^( +|\t)/ { print \$1 }")' -- "$cur")) fi } && -complete -F _koji koji arm-koji ppc-koji s390-koji sparc-koji + complete -F _koji koji arm-koji ppc-koji s390-koji sparc-koji # ex: filetype=sh diff --git a/completions/ktutil b/completions/ktutil index 572a2ec4..6030a474 100644 --- a/completions/ktutil +++ b/completions/ktutil @@ -2,21 +2,21 @@ _heimdal_principals() { - COMPREPLY=( $(compgen -W "$(kadmin -l dump 2>/dev/null | \ - awk '{print $1}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(kadmin -l dump 2>/dev/null | + awk '{print $1}')" -- "$cur")) } _heimdal_realms() { - COMPREPLY=( $(compgen -W "$(kadmin -l dump 2>/dev/null | \ - awk '{print $1}' | awk -F@ '{print $2}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(kadmin -l dump 2>/dev/null | + awk '{print $1}' | awk -F@ '{print $2}')" -- "$cur")) } _heimdal_encodings() { - COMPREPLY=( $(compgen -W 'des-cbc-mcrc des-cbc-md4 des-cbc-md5 + COMPREPLY=($(compgen -W 'des-cbc-mcrc des-cbc-md4 des-cbc-md5 des3-cbc-sha1 arcfour-hmac-md5 aes128-cts-hmac-sha1-96 - aes256-cts-hmac-sha1-96' -- "$cur") ) + aes256-cts-hmac-sha1-96' -- "$cur")) } _ktutil() @@ -27,23 +27,23 @@ _ktutil() local command commands i options case $prev in - -p|--principal) + -p | --principal) _heimdal_principals return ;; - -e|--enctype) + -e | --enctype) _heimdal_encodings return ;; - -a|--admin-server) + -a | --admin-server) _known_hosts_real -- "$cur" return ;; - -r|--realm) + -r | --realm) _heimdal_realms return ;; - -s|-k|--srvtab|--keytab) + -s | -k | --srvtab | --keytab) _filedir return ;; @@ -54,13 +54,13 @@ _ktutil() commands='add change copy get list remove rename purge srvconvert srv2keytab srvcreate key2srvtab' - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in - -k|--keytab) - (( i++ )) - ;; - -*) + -k | --keytab) + ((i++)) ;; + -*) ;; + *) command=${words[i]} break @@ -68,15 +68,15 @@ _ktutil() esac done - if [[ "$cur" == -* ]]; then - case $command in + if [[ $cur == -* ]]; then + case ${command-} in add) options='-p --principal -V -e --enctype -w --password -r --random -s --no-salt -h --hex' - ;; + ;; change) options='-r --realm -a --admin-server -s --server-port' - ;; + ;; get) options='-p --principal -e --enctype -r --realm -a --admin-server -s server --server-port' @@ -90,16 +90,16 @@ _ktutil() purge) options='--age' ;; - srv2keytab|key2srvtab) + srv2keytab | key2srvtab) options='-s --srvtab' ;; *) options='-k --keytab -v --verbose --version -v --help' ;; esac - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) else - case $command in + case ${command-} in copy) _filedir ;; @@ -110,11 +110,11 @@ _ktutil() _heimdal_principals ;; *) - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + COMPREPLY=($(compgen -W "$commands" -- "$cur")) ;; esac fi } && -complete -F _ktutil ktutil + complete -F _ktutil ktutil # ex: filetype=sh diff --git a/completions/larch b/completions/larch index 0773c2da..7ed9ca20 100644 --- a/completions/larch +++ b/completions/larch @@ -6,8 +6,8 @@ _larch() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 || "$prev" == -* ]]; then - COMPREPLY=( $(compgen -W ' \ + if [[ $cword -eq 1 || $prev == -* ]]; then + COMPREPLY=($(compgen -W ' \ my-id my-default-archive register-archive whereis-archive archives \ init-tree tree-root tree-version set-tree-version inventory \ tagging-method tree-lint missing-tags add delete \ @@ -30,10 +30,10 @@ _larch() distribution-name notify my-notifier mail-new-categories \ mail-new-branches mail-new-versions mail-new-revisions \ notify-library notify-browser push-new-revisions sendmail-mailx' \ - "$cur") ) + "$cur")) fi } && -complete -F _larch -o default larch + complete -F _larch -o default larch # ex: filetype=sh diff --git a/completions/lastlog b/completions/lastlog index 19e928c2..214a174d 100644 --- a/completions/lastlog +++ b/completions/lastlog @@ -6,20 +6,20 @@ _lastlog() _init_completion -s || return case $prev in - --before|--help|--time|-!(-*)@([bt]|h*)) + --before | --help | --time | -!(-*)@([bt]|h*)) return ;; - --user|-!(-*)u) - COMPREPLY=( $(compgen -u -- "$cur") ) + --user | -!(-*)u) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _lastlog lastlog + complete -F _lastlog lastlog # ex: filetype=sh diff --git a/completions/ldapsearch b/completions/ldapsearch index a0bdcb9d..6dc415e6 100644 --- a/completions/ldapsearch +++ b/completions/ldapsearch @@ -2,12 +2,12 @@ _ldap_uris() { - COMPREPLY=( $(compgen -W 'ldap:// ldaps://' -- "$cur") ) + COMPREPLY=($(compgen -W 'ldap:// ldaps://' -- "$cur")) } _ldap_protocols() { - COMPREPLY=( $(compgen -W '2 3' -- "$cur") ) + COMPREPLY=($(compgen -W '2 3' -- "$cur")) } _ldapsearch() @@ -33,11 +33,11 @@ _ldapsearch() return ;; -*s) - COMPREPLY=( $(compgen -W 'base one sub children' -- "$cur") ) + COMPREPLY=($(compgen -W 'base one sub children' -- "$cur")) return ;; -*a) - COMPREPLY=( $(compgen -W 'never always search find' -- "$cur") ) + COMPREPLY=($(compgen -W 'never always search find' -- "$cur")) return ;; -*P) @@ -46,11 +46,11 @@ _ldapsearch() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldapsearch ldapsearch + complete -F _ldapsearch ldapsearch _ldapaddmodify() { @@ -76,11 +76,11 @@ _ldapaddmodify() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldapaddmodify ldapadd ldapmodify + complete -F _ldapaddmodify ldapadd ldapmodify _ldapdelete() { @@ -106,11 +106,11 @@ _ldapdelete() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldapdelete ldapdelete + complete -F _ldapdelete ldapdelete _ldapcompare() { @@ -136,11 +136,11 @@ _ldapcompare() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldapcompare ldapcompare + complete -F _ldapcompare ldapcompare _ldapmodrdn() { @@ -166,11 +166,11 @@ _ldapmodrdn() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -ZZ -MM' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -ZZ -MM' -- "$cur")) fi } && -complete -F _ldapmodrdn ldapmodrdn + complete -F _ldapmodrdn ldapmodrdn _ldapwhoami() { @@ -196,11 +196,11 @@ _ldapwhoami() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldapwhoami ldapwhoami + complete -F _ldapwhoami ldapwhoami _ldappasswd() { @@ -222,10 +222,10 @@ _ldappasswd() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldappasswd ldappasswd + complete -F _ldappasswd ldappasswd # ex: filetype=sh diff --git a/completions/ldapvi b/completions/ldapvi index a7b55fcc..cb01ac8d 100644 --- a/completions/ldapvi +++ b/completions/ldapvi @@ -6,46 +6,46 @@ _ldapvi() _init_completion || return case $prev in - --host|-!(-*)h) + --host | -!(-*)h) _known_hosts_real -- "$cur" return ;; - --sasl-mech|-!(-*)Y) - COMPREPLY=( $(compgen -W 'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 - PLAIN ANONYMOUS' -- "$cur") ) + --sasl-mech | -!(-*)Y) + COMPREPLY=($(compgen -W 'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 + PLAIN ANONYMOUS' -- "$cur")) return ;; --bind) - COMPREPLY=( $(compgen -W 'simple sasl' -- "$cur") ) + COMPREPLY=($(compgen -W 'simple sasl' -- "$cur")) return ;; --bind-dialog) - COMPREPLY=( $(compgen -W 'never auto always' -- "$cur") ) + COMPREPLY=($(compgen -W 'never auto always' -- "$cur")) return ;; --scope) - COMPREPLY=( $(compgen -W 'base one sub' -- "$cur") ) + COMPREPLY=($(compgen -W 'base one sub' -- "$cur")) return ;; --deref) - COMPREPLY=( $(compgen -W 'never searching finding always' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'never searching finding always' \ + -- "$cur")) return ;; --encoding) - COMPREPLY=( $(compgen -W 'ASCII UTF-8 binary' -- "$cur") ) + COMPREPLY=($(compgen -W 'ASCII UTF-8 binary' -- "$cur")) return ;; --tls) - COMPREPLY=( $(compgen -W 'never allow try strict' -- "$cur") ) + COMPREPLY=($(compgen -W 'never allow try strict' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _ldapvi ldapvi + complete -F _ldapvi ldapvi # ex: filetype=sh diff --git a/completions/lftp b/completions/lftp index 41fb1356..72dedb42 100644 --- a/completions/lftp +++ b/completions/lftp @@ -10,20 +10,19 @@ _lftp() _filedir return ;; - --help|--version|-!(-*)[chveups]) + --help | --version | -!(-*)[chveups]) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -W \ - '$(cut -f 1 -s ~/.lftp/bookmarks ${XDG_DATA_HOME:-$HOME/.local/share}/lftp/bookmarks 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W '$("$1" -c "bookmark list" 2>/dev/null)' -- "$cur")) _known_hosts_real -- "$cur" } && -complete -F _lftp lftp + complete -F _lftp lftp # ex: filetype=sh diff --git a/completions/lftpget b/completions/lftpget index 1583500c..d21622eb 100644 --- a/completions/lftpget +++ b/completions/lftpget @@ -5,10 +5,10 @@ _lftpget() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-c -d -v' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-c -d -v' -- "$cur")) fi } && -complete -F _lftpget lftpget + complete -F _lftpget lftpget # ex: filetype=sh diff --git a/completions/lilo b/completions/lilo index 03e3ee29..af8539aa 100644 --- a/completions/lilo +++ b/completions/lilo @@ -2,8 +2,9 @@ _lilo_labels() { - COMPREPLY=( $(compgen -W "$(awk -F'=' '/label/ {print $2}' \ - /etc/lilo.conf | command sed -e 's/\"//g')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(awk -F= '$1 ~ /^[ \t]*label$/ {print $2}' \ + ${1:-/etc/lilo.conf} 2>/dev/null | command sed -e 's/\"//g')" \ + -- "$cur")) } _lilo() @@ -12,7 +13,7 @@ _lilo() _init_completion || return case $prev in - -C|-i|-m|-s|-S) + -C | -i | -m | -s | -S) _filedir return ;; @@ -20,12 +21,19 @@ _lilo() _filedir -d return ;; - -I|-D|-R) + -I | -D | -R) # label completion - _lilo_labels + local i conf + for i in "${!words[@]}"; do + if [[ ${words[i]} == -C ]]; then + conf=${words[i + 1]} + break + fi + done + _lilo_labels $conf return ;; - -A|-b|-M|-u|-U) + -A | -b | -M | -u | -U) # device completion cur=${cur:=/dev/} _filedir @@ -33,18 +41,26 @@ _lilo() ;; -T) # topic completion - COMPREPLY=( $(compgen -W 'help ChRul EBDA geom geom= table= - video' -- "$cur") ) + COMPREPLY=($(compgen -W 'help ChRul EBDA geom geom= table= + video' -- "$cur")) + return + ;; + -B) + _filedir bmp + return + ;; + -E) + _filedir '@(bmp|dat)' return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # relevant options completion - COMPREPLY=( $(compgen -W '-A -b -c -C -d -f -g -i -I -l -L -m -M -p -P - -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- "$cur") ) + COMPREPLY=($(compgen -W '-A -B -b -c -C -d -E -f -g -i -I -l -L -m -M + -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- "$cur")) fi } && -complete -F _lilo lilo + complete -F _lilo lilo # ex: filetype=sh diff --git a/completions/links b/completions/links index 6bfee654..e0c28e21 100644 --- a/completions/links +++ b/completions/links @@ -6,20 +6,20 @@ _links() _init_completion -n : || return case $prev in - -html-t-text-color|-html-t-link-color) - COMPREPLY=( $(compgen -W '{0..15}' -- "$cur") ) + -html-t-text-color | -html-t-link-color) + COMPREPLY=($(compgen -W '{0..15}' -- "$cur")) return ;; - -http.fake-firefox|-html-[gt]-ignore-document-color) - COMPREPLY=( $(compgen -W '0 1' -- "$cur") ) + -http.fake-firefox | -html-[gt]-ignore-document-color) + COMPREPLY=($(compgen -W '0 1' -- "$cur")) return ;; - --help|-help|-mode|-display|-source|-dump|-width|-max-connections|\ - -max-connections-to-host|-retries|-receive-timeout|\ - -unrestartable-receive-timeout|-*-size|-*-proxy|\ - -append-text-to-dns-lookups|-ssl.client-cert-passwd|-http.fake-*|\ - -http.extra-header|-ftp.anonymous-passwd|-*-color|-*-gamma|\ - -bfu-aspect|-html-image-scale|-html-margin) + --help | -help | -mode | -display | -source | -dump | -width | -max-connections | \ + -max-connections-to-host | -retries | -receive-timeout | \ + -unrestartable-receive-timeout | -*-size | -*-proxy | \ + -append-text-to-dns-lookups | -ssl.client-cert-passwd | -http.fake-* | \ + -http.extra-header | -ftp.anonymous-passwd | -*-color | -*-gamma | \ + -bfu-aspect | -html-image-scale | -html-margin) return ;; -lookup) @@ -30,10 +30,10 @@ _links() local drivers=$("$1" -driver foo 2>&1 | command sed -ne '$!d' -e '/^[a-z0-9, ]\{1,\}$/s/,/ /gp') [[ $drivers ]] || drivers='x svgalib fb directfb pmshell atheos' - COMPREPLY=( $(compgen -W "$drivers" -- "$cur") ) + COMPREPLY=($(compgen -W "$drivers" -- "$cur")) return ;; - -codepage|-bookmarks-codepage|-http-assume-codepage) + -codepage | -bookmarks-codepage | -http-assume-codepage) _xfunc iconv _iconv_charsets return ;; @@ -50,19 +50,19 @@ _links() __ltrim_colon_completions "$cur" return ;; - -async-dns|-download-utime|-aggressive-cache|-only-proxies|\ - -http-bugs.*|-http.do-not-track|-ftp.use-*|-ftp.fast|-ftp.set-iptos|\ - -smb.allow-hyperlinks-to-smb|-save-url-history|-dither-letters|\ - -dither-images|-overwrite-instead-of-scroll|-html-*) - COMPREPLY=( $(compgen -W '0 1' -- "$cur") ) + -async-dns | -download-utime | -aggressive-cache | -only-proxies | \ + -http-bugs.* | -http.do-not-track | -ftp.use-* | -ftp.fast | -ftp.set-iptos | \ + -smb.allow-hyperlinks-to-smb | -save-url-history | -dither-letters | \ + -dither-images | -overwrite-instead-of-scroll | -html-*) + COMPREPLY=($(compgen -W '0 1' -- "$cur")) return ;; - -address-preference|-http.referer) - COMPREPLY=( $(compgen -W '{0..4}' -- "$cur") ) + -address-preference | -http.referer) + COMPREPLY=($(compgen -W '{0..4}' -- "$cur")) return ;; - -ssl-certificates|-display-optimize|-gamma-correction) - COMPREPLY=( $(compgen -W '{0..2}' -- "$cur") ) + -ssl-certificates | -display-optimize | -gamma-correction) + COMPREPLY=($(compgen -W '{0..2}' -- "$cur")) return ;; -ssl.client-cert-key) @@ -80,21 +80,21 @@ _links() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" | - command grep -vF -- "->")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" | + command grep -vF -- "->")' -- "$cur")) return fi local dir for dir in .links .links2; do if [[ -r ~/$dir/links.his ]]; then - COMPREPLY+=( $(compgen -W '$(cat ~/$dir/links.his)' -- "$cur") ) + COMPREPLY+=($(compgen -W '$(cat ~/$dir/links.his)' -- "$cur")) __ltrim_colon_completions "$cur" fi done _filedir '@(htm|html)' } && -complete -F _links links links2 + complete -F _links links links2 # ex: filetype=sh diff --git a/completions/lintian b/completions/lintian index d62d8373..93438325 100644 --- a/completions/lintian +++ b/completions/lintian @@ -5,18 +5,18 @@ _lintian_tags() local match search tags tags=$(awk '/^Tag/ { print $2 }' /usr/share/lintian/checks/*.desc) - if [[ "$cur" == *, ]]; then + if [[ $cur == *, ]]; then search=${cur//,/ } for item in $search; do match=$(command grep -nE "^Tag: $item$" \ /usr/share/lintian/checks/*.desc | cut -d: -f1) tags=$(command sed -e "s/\<$item\>//g" <<<$tags) done - COMPREPLY+=( $(compgen -W "$tags") ) - elif [[ "$cur" == *,* ]]; then - COMPREPLY+=( $(compgen -P "${cur%,*}," -W "$tags" -- "${cur##*,}") ) + COMPREPLY+=($(compgen -W "$tags")) + elif [[ $cur == *,* ]]; then + COMPREPLY+=($(compgen -P "${cur%,*}," -W "$tags" -- "${cur##*,}")) else - COMPREPLY+=( $(compgen -W "$tags" -- "$cur") ) + COMPREPLY+=($(compgen -W "$tags" -- "$cur")) fi } @@ -26,7 +26,7 @@ _lintian_checks() checks=$(awk '/^(Check-Script|Abbrev)/ { print $2 }' \ /usr/share/lintian/checks/*.desc) - if [[ "$cur" == *, ]]; then + if [[ $cur == *, ]]; then search=${cur//,/ } for item in $search; do match=$(command grep -nE "^(Check-Script|Abbrev): $item$" \ @@ -36,11 +36,11 @@ _lintian_checks() checks=$(command sed -e "s/\<$name\>//g" <<<$checks) done done - COMPREPLY+=( $(compgen -W "$checks") ) - elif [[ "$cur" == *,* ]]; then - COMPREPLY+=( $(compgen -P "${cur%,*}," -W "$checks" -- "${cur##*,}") ) + COMPREPLY+=($(compgen -W "$checks")) + elif [[ $cur == *,* ]]; then + COMPREPLY+=($(compgen -P "${cur%,*}," -W "$checks" -- "${cur##*,}")) else - COMPREPLY+=( $(compgen -W "$checks" -- "$cur") ) + COMPREPLY+=($(compgen -W "$checks" -- "$cur")) fi } @@ -50,18 +50,18 @@ _lintian_infos() infos=$(awk '/^Collector/ { print $2 }' \ /usr/share/lintian/collection/*.desc) - if [[ "$cur" == *, ]]; then + if [[ $cur == *, ]]; then search=${cur//,/ } for item in $search; do match=$(command grep -nE "^Collector: $item$" \ /usr/share/lintian/collection/*.desc | cut -d: -f1) infos=$(command sed -e "s/\<$item\>//g" <<<$infos) done - COMPREPLY+=( $(compgen -W "$infos") ) - elif [[ "$cur" == *,* ]]; then - COMPREPLY+=( $(compgen -P "${cur%,*}," -W "$infos" -- "${cur##*,}") ) + COMPREPLY+=($(compgen -W "$infos")) + elif [[ $cur == *,* ]]; then + COMPREPLY+=($(compgen -P "${cur%,*}," -W "$infos" -- "${cur##*,}")) else - COMPREPLY+=( $(compgen -W "$infos" -- "$cur") ) + COMPREPLY+=($(compgen -W "$infos" -- "$cur")) fi } @@ -70,8 +70,7 @@ _lintian() local cur prev words cword _init_completion || return - local action lint_actions general_opts behaviour_opts \ - configuration_opts selection_opts + local lint_actions general_opts behaviour_opts configuration_opts lint_actions="--setup-lab --remove-lab --check --check-part --tags --tags-from-file --ftp-master-rejects --dont-check-part --unpack @@ -83,34 +82,33 @@ _lintian() --allow-root --fail-on-warnings --keep-lab" configuration_opts="--cfg --lab --archivedir --dist --area --section --arch --root" - selection_opts="--all --binary --source --udeb --packages-file" - if [[ "$prev" == -* ]]; then + if [[ $prev == -* ]]; then case $prev in - -C|--check-part|-X|--dont-check-part) + -C | --check-part | -X | --dont-check-part) _lintian_checks ;; - -T|--tags|--suppress-tags) + -T | --tags | --suppress-tags) _lintian_tags ;; - --tags-from-file|--suppress-tags-from-file|--cfg|-p|\ - --packages-file) + --tags-from-file | --suppress-tags-from-file | --cfg | -p | \ + --packages-file) _filedir ;; - --lab|--archivedir|--dist|--root) + --lab | --archivedir | --dist | --root) _filedir -d ;; --color) COMPREPLY=($(compgen -W "never always auto html" -- "$cur")) ;; - -U|--unpack-info) + -U | --unpack-info) _lintian_infos ;; - --area|--section) + --area | --section) COMPREPLY=($(compgen -W "main contrib non-free" -- "$cur")) ;; - --arch) - ;; + --arch) ;; + esac fi @@ -124,24 +122,25 @@ _lintian() # --action tag,tag,<TAB> # Only few actions permit that, re-complete them now. case "$prev" in - -C|--check-part|-X|--dont-check-part) + -C | --check-part | -X | --dont-check-part) _lintian_checks ;; - -T|--tags|--suppress-tags) + -T | --tags | --suppress-tags) _lintian_tags ;; - -U|--unpack-info) + -U | --unpack-info) _lintian_infos ;; esac ;; *) - _filedir '@(?(u)deb|changes|dsc)' + # in Ubuntu, dbgsym packages end in .ddeb, lintian >= 2.57.0 groks + _filedir '@(?(u|d)deb|changes|dsc|buildinfo)' ;; esac return 0 } && -complete -F _lintian lintian + complete -F _lintian lintian _lintian_info() { @@ -149,10 +148,10 @@ _lintian_info() _init_completion || return case "$prev" in - --help|--profile) + --help | --profile) return ;; - -t|--tags) + -t | --tags) _lintian_tags return ;; @@ -164,7 +163,7 @@ _lintian_info() case "$cur" in --*) - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) ;; *) _filedir @@ -172,6 +171,6 @@ _lintian_info() esac return 0 } && -complete -F _lintian_info lintian-info + complete -F _lintian_info lintian-info # ex: filetype=sh diff --git a/completions/lisp b/completions/lisp index f9f68275..098567bc 100644 --- a/completions/lisp +++ b/completions/lisp @@ -8,15 +8,15 @@ _lisp() _init_completion || return # completing an option (may or may not be separated by a space) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-core -lib -batch -quit -edit -eval -init + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-core -lib -batch -quit -edit -eval -init -dynamic-space-size -hinit -noinit -nositeinit -load -slave' \ - -- "$cur") ) + -- "$cur")) else _filedir fi } && -complete -F _lisp -o default lisp + complete -F _lisp -o default lisp # ex: filetype=sh diff --git a/completions/list_admins b/completions/list_admins index 11f7414d..57081797 100644 --- a/completions/list_admins +++ b/completions/list_admins @@ -5,13 +5,13 @@ _list_admins() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--all-vhost --all --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--all-vhost --all --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _list_admins list_admins + complete -F _list_admins list_admins # ex: filetype=sh diff --git a/completions/list_lists b/completions/list_lists index c0807178..c5b9ba71 100644 --- a/completions/list_lists +++ b/completions/list_lists @@ -2,7 +2,7 @@ _mailman_lists() { - COMPREPLY=( $(compgen -W '$(list_lists -b 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(list_lists -b 2>/dev/null)' -- "$cur")) } _list_lists() @@ -10,12 +10,12 @@ _list_lists() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--advertised --virtual-host-overview --bare - --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--advertised --virtual-host-overview --bare + --help' -- "$cur")) fi } && -complete -F _list_lists list_lists + complete -F _list_lists list_lists # ex: filetype=sh diff --git a/completions/list_members b/completions/list_members index 90db5cba..639344c7 100644 --- a/completions/list_members +++ b/completions/list_members @@ -6,31 +6,31 @@ _list_members() _init_completion -s || return case $prev in - -o|--output) + -o | --output) _filedir return ;; - -d|--digest) - COMPREPLY=( $(compgen -W 'mime plain' -- "$cur") ) + -d | --digest) + COMPREPLY=($(compgen -W 'mime plain' -- "$cur")) return ;; - -n|--nomail) - COMPREPLY=( $(compgen -W 'byadmin byuser bybounce unknown' \ - -- "$cur") ) + -n | --nomail) + COMPREPLY=($(compgen -W 'byadmin byuser bybounce unknown' \ + -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--output --regular --digest --nomail - --fullnames --preserve --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--output --regular --digest --nomail + --fullnames --preserve --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _list_members list_members + complete -F _list_members list_members # ex: filetype=sh diff --git a/completions/list_owners b/completions/list_owners index 18b52476..445be0bd 100644 --- a/completions/list_owners +++ b/completions/list_owners @@ -5,14 +5,14 @@ _list_owners() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--with-listnames --moderators --help' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--with-listnames --moderators --help' \ + -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _list_owners list_owners + complete -F _list_owners list_owners # ex: filetype=sh diff --git a/completions/locale-gen b/completions/locale-gen index 3dae76ff..40682013 100644 --- a/completions/locale-gen +++ b/completions/locale-gen @@ -6,7 +6,7 @@ _locale_gen() _init_completion -s || return case $prev in - --help|-h) + --help | -h) return ;; --aliases) @@ -18,15 +18,15 @@ _locale_gen() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ '$(awk "{ print \$1 }" /usr/share/i18n/SUPPORTED 2>/dev/null)' \ - -- "$cur") ) + -- "$cur")) } && -complete -F _locale_gen locale-gen + complete -F _locale_gen locale-gen # ex: filetype=sh diff --git a/completions/lpq b/completions/lpq index a1223268..36729d22 100644 --- a/completions/lpq +++ b/completions/lpq @@ -7,22 +7,22 @@ _lpq() case $prev in -P) - COMPREPLY=( $(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur")) return ;; -U) - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac - if [[ "$cur" == - ]]; then - COMPREPLY=( $(compgen -W '-E -P -U -a -h -l' -- "$cur") ) + if [[ $cur == - ]]; then + COMPREPLY=($(compgen -W '-E -P -U -a -h -l' -- "$cur")) return fi _filedir } && -complete -F _lpq lpq + complete -F _lpq lpq # ex: filetype=sh diff --git a/completions/lpr b/completions/lpr index 9a9e8639..554f0534 100644 --- a/completions/lpr +++ b/completions/lpr @@ -7,27 +7,27 @@ _lpr() case $prev in -P) - COMPREPLY=( $(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur")) return ;; -U) - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) return ;; -o) - COMPREPLY=( $(compgen -W "media= landscape orientation-requested= sides= fitplot number-up= scaling= cpi= lpi= page-bottom= page-top= page-left= page-right=" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W "media= landscape orientation-requested= sides= fitplot number-up= scaling= cpi= lpi= page-bottom= page-top= page-left= page-right=" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return ;; esac - if [[ "$cur" == - ]]; then - COMPREPLY=( $(compgen -W '-E -H -C -J -T -P -U -h -l -m -o -p -q -r' -- "$cur") ) + if [[ $cur == - ]]; then + COMPREPLY=($(compgen -W '-E -H -C -J -T -P -U -h -l -m -o -p -q -r' -- "$cur")) return fi _filedir } && -complete -F _lpr lpr + complete -F _lpr lpr # ex: filetype=sh diff --git a/completions/lrzip b/completions/lrzip index 5eb2445b..eb2904c6 100644 --- a/completions/lrzip +++ b/completions/lrzip @@ -23,21 +23,21 @@ _lrzip() return ;; -*L) - COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..9}' -- "$cur")) return ;; -*N) - COMPREPLY=( $(compgen -W '{-20..19}' -- "$cur") ) + COMPREPLY=($(compgen -W '{-20..19}' -- "$cur")) return ;; -*p) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi @@ -45,8 +45,8 @@ _lrzip() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _lrzip lrzip + complete -F _lrzip lrzip # ex: filetype=sh diff --git a/completions/lsof b/completions/lsof index e904f406..eb1e967d 100644 --- a/completions/lsof +++ b/completions/lsof @@ -6,23 +6,23 @@ _lsof() _init_completion || return case $prev in - -'?'|-h|+c|-c|-d|-F|-i|+r|-r|-s|-S|-T) + -'?' | -h | +c | -c | -d | -F | -i | +r | -r | -s | -S | -T) return ;; - -A|-k|-m|+m|-o) + -A | -k | -m | +m | -o) _filedir return ;; - +d|+D) + +d | +D) _filedir -d return ;; -D) - COMPREPLY=( $(compgen -W '? b i r u' -- "$cur") ) + COMPREPLY=($(compgen -W '? b i r u' -- "$cur")) return ;; -f) - COMPREPLY=( $(compgen -W 'c f g G n' -- "$cur") ) + COMPREPLY=($(compgen -W 'c f g G n' -- "$cur")) return ;; -g) @@ -37,20 +37,20 @@ _lsof() ;; -u) # TODO: handle ^foo exclusions, comma separated lists - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac - if [[ "$cur" == [-+]* ]]; then - COMPREPLY=( $(compgen -W '-h -a -A -b -c +c -C +d -d +D -D +f -f -F -g + if [[ $cur == [-+]* ]]; then + COMPREPLY=($(compgen -W '-h -a -A -b -c +c -C +d -d +D -D +f -f -F -g -i -k -l +L -L +m -m +M -M -n -N -o -O -p -P +r -r -R -s -S -T -t - -u -U -v -V +w -w -x -X -z -Z' -- "$cur") ) + -u -U -v -V +w -w -x -X -z -Z' -- "$cur")) return fi _filedir } && -complete -F _lsof lsof + complete -F _lsof lsof # ex: filetype=sh diff --git a/completions/lspci b/completions/lspci index e31a5b57..d50783c9 100644 --- a/completions/lspci +++ b/completions/lspci @@ -18,12 +18,12 @@ _lspci() return ;; -*A) - COMPREPLY+=( $(compgen -W '$($1 -A help | command grep -vF :)' \ - -- "$cur") ) + COMPREPLY+=($(compgen -W '$($1 -A help | command grep -vF :)' \ + -- "$cur")) return ;; -*H) - COMPREPLY+=( $(compgen -W "1 2" -- "$cur") ) + COMPREPLY+=($(compgen -W "1 2" -- "$cur")) return ;; -*F) @@ -33,9 +33,9 @@ _lspci() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _lspci lspci + complete -F _lspci lspci # ex: filetype=sh diff --git a/completions/lsscsi b/completions/lsscsi index b401c8ab..bcbc430a 100644 --- a/completions/lsscsi +++ b/completions/lsscsi @@ -6,10 +6,10 @@ _lsscsi() _init_completion -s || return case $prev in - --help|--version|-!(-*)[hV]*) + --help | --version | -!(-*)[hV]*) return ;; - --sysfsroot|-!(-*)y) + --sysfsroot | -!(-*)y) _filedir -d return ;; @@ -18,10 +18,10 @@ _lsscsi() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _lsscsi lsscsi + complete -F _lsscsi lsscsi # ex: filetype=sh diff --git a/completions/lsusb b/completions/lsusb index c315abd1..63cff54c 100644 --- a/completions/lsusb +++ b/completions/lsusb @@ -6,15 +6,15 @@ _lsusb() _init_completion || return case $prev in - --help|--version|-!(-*)@([sD]|[hV]*)) + --help | --version | -!(-*)@([sD]|[hV]*)) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _lsusb lsusb + complete -F _lsusb lsusb # ex: filetype=sh diff --git a/completions/lua b/completions/lua index 775eae20..3c4df901 100644 --- a/completions/lua +++ b/completions/lua @@ -6,18 +6,18 @@ _lua() _init_completion || return case $prev in - -e|-l|-v|-) + -e | -l | -v | -) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W "$(_parse_help "$1")" -- "$cur") ) + COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur")) return fi _filedir 'l@(ua|?(ua)c)' } && -complete -F _lua lua + complete -F _lua lua # ex: filetype=sh diff --git a/completions/luac b/completions/luac index 15b562ae..c763deb2 100644 --- a/completions/luac +++ b/completions/luac @@ -6,7 +6,7 @@ _luac() _init_completion || return case $prev in - -v|-) + -v | -) return ;; -o) @@ -16,12 +16,12 @@ _luac() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W "$(_parse_help "$1")" -- "$cur") ) + COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur")) return fi _filedir lua } && -complete -F _luac luac + complete -F _luac luac # ex: filetype=sh diff --git a/completions/luseradd b/completions/luseradd index 2fa336db..4d66385b 100644 --- a/completions/luseradd +++ b/completions/luseradd @@ -6,20 +6,20 @@ _luseradd() _init_completion -s || return case $prev in - --help|--usage|--gecos|--uid|--login|--plainpassword|--password|\ - --commonname|--givenname|--surname|--roomnumber|--telephonenumber|\ - --homephone|-!(-*)@([culPp]|[?]*)) + --help | --usage | --gecos | --uid | --login | --plainpassword | --password | \ + --commonname | --givenname | --surname | --roomnumber | --telephonenumber | \ + --homephone | -!(-*)@([culPp]|[?]*)) return ;; - --directory|--skeleton|-!(-*)[dk]) + --directory | --skeleton | -!(-*)[dk]) _filedir -d return ;; - --shell|-!(-*)s) + --shell | -!(-*)s) _shells return ;; - --gid|-!(-*)g) + --gid | -!(-*)g) _gids return ;; @@ -27,14 +27,14 @@ _luseradd() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - [[ ${1##*/} == luseradd ]] || COMPREPLY=( $(compgen -u -- "$cur") ) + [[ ${1##*/} == luseradd ]] || COMPREPLY=($(compgen -u -- "$cur")) } && -complete -F _luseradd luseradd lusermod + complete -F _luseradd luseradd lusermod # ex: filetype=sh diff --git a/completions/luserdel b/completions/luserdel index ee2b4fdb..e36bda9f 100644 --- a/completions/luserdel +++ b/completions/luserdel @@ -6,18 +6,18 @@ _luserdel() _init_completion || return case $prev in - --help|--usage|-!(-*)[?]*) + --help | --usage | -!(-*)[?]*) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) } && -complete -F _luserdel luserdel + complete -F _luserdel luserdel # ex: filetype=sh diff --git a/completions/lvm b/completions/lvm index 712838c8..e70ecc3a 100644 --- a/completions/lvm +++ b/completions/lvm @@ -8,26 +8,26 @@ _lvm_filedir() _lvm_volumegroups() { - COMPREPLY=( $(compgen -W "$(vgscan 2>/dev/null | \ - command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur") ) + COMPREPLY=($(compgen -W "$(vgscan 2>/dev/null | + command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p')" -- "$cur")) } _lvm_physicalvolumes_all() { - COMPREPLY=( $(compgen -W "$(pvscan 2>/dev/null | \ - command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p' )" -- "$cur") ) + COMPREPLY=($(compgen -W "$(pvscan 2>/dev/null | + command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p')" -- "$cur")) } _lvm_physicalvolumes() { - COMPREPLY=( $(compgen -W "$(pvscan 2>/dev/null | \ - command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur") ) + COMPREPLY=($(compgen -W "$(pvscan 2>/dev/null | + command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p')" -- "$cur")) } _lvm_logicalvolumes() { - COMPREPLY=( $(compgen -W "$(lvscan 2>/dev/null | \ - command sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur") ) + COMPREPLY=($(compgen -W "$(lvscan 2>/dev/null | + command sed -n -e "s|^.*'\(.*\)'.*$|\1|p")" -- "$cur")) if [[ $cur == /dev/mapper/* ]]; then _filedir local i @@ -39,12 +39,12 @@ _lvm_logicalvolumes() _lvm_units() { - COMPREPLY=( $(compgen -W 'h s b k m g t H K M G T' -- "$cur") ) + COMPREPLY=($(compgen -W 'h s b k m g t H K M G T' -- "$cur")) } _lvm_sizes() { - COMPREPLY=( $(compgen -W 'k K m M g G t T' -- "$cur") ) + COMPREPLY=($(compgen -W 'k K m M g G t T' -- "$cur")) } # @param $1 glob matching args known to take an argument @@ -52,13 +52,14 @@ _lvm_count_args() { args=0 local offset=1 - if [[ "${words[0]}" == lvm ]]; then + if [[ ${words[0]} == lvm ]]; then offset=2 fi - local i prev=${words[$offset-1]} - for (( i=$offset; i < cword; i++ )); do - if [[ "${words[i]}" != -* && $prev != $1 ]]; then - (( args++ )) + local i prev=${words[offset - 1]} + for ((i = offset; i < cword; i++)); do + # shellcheck disable=SC2053 + if [[ ${words[i]} != -* && $prev != $1 ]]; then + ((args++)) fi prev=${words[i]} done @@ -69,22 +70,22 @@ _lvmdiskscan() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) fi } && -complete -F _lvmdiskscan lvmdiskscan + complete -F _lvmdiskscan lvmdiskscan _pvscan() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) fi } && -complete -F _pvscan pvscan + complete -F _pvscan pvscan _pvs() { @@ -92,9 +93,9 @@ _pvs() _init_completion || return case $prev in - --options|--sort|-!(-*)[oO]) - COMPREPLY=( $(compgen -W 'pv_fmt pv_uuid pv_size pv_free pv_used - pv_name pv_attr pv_pe_count pv_pe_alloc_count' -- "$cur") ) + --options | --sort | -!(-*)[oO]) + COMPREPLY=($(compgen -W 'pv_fmt pv_uuid pv_size pv_free pv_used + pv_name pv_attr pv_pe_count pv_pe_alloc_count' -- "$cur")) return ;; --units) @@ -103,13 +104,13 @@ _pvs() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_physicalvolumes_all fi } && -complete -F _pvs pvs + complete -F _pvs pvs _pvdisplay() { @@ -123,13 +124,13 @@ _pvdisplay() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_physicalvolumes_all fi } && -complete -F _pvdisplay pvdisplay + complete -F _pvdisplay pvdisplay _pvchange() { @@ -137,19 +138,19 @@ _pvchange() _init_completion || return case $prev in - --autobackup|--allocatable|-!(-*)[Ax]) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | --allocatable | -!(-*)[Ax]) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_physicalvolumes_all fi } && -complete -F _pvchange pvchange + complete -F _pvchange pvchange _pvcreate() { @@ -161,27 +162,27 @@ _pvcreate() _filedir return ;; - --metadatatype|-!(-*)M) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + --metadatatype | -!(-*)M) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; --metadatacopies) - COMPREPLY=( $(compgen -W '0 1 2' -- "$cur") ) + COMPREPLY=($(compgen -W '0 1 2' -- "$cur")) return ;; - --metadatasize|--setphysicalvolumesize) + --metadatasize | --setphysicalvolumesize) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_filedir fi } && -complete -F _pvcreate pvcreate + complete -F _pvcreate pvcreate _pvmove() { @@ -189,46 +190,47 @@ _pvmove() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --name|-!(-*)n) + --name | -!(-*)n) _lvm_logicalvolumes return + ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_physicalvolumes fi } && -complete -F _pvmove pvmove + complete -F _pvmove pvmove _pvremove() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_physicalvolumes_all fi } && -complete -F _pvremove pvremove + complete -F _pvremove pvremove _vgscan() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) fi } && -complete -F _vgscan vgscan + complete -F _vgscan vgscan _vgs() { @@ -236,11 +238,11 @@ _vgs() _init_completion || return case $prev in - --options|--sort|-!(-*)[oO]) - COMPREPLY=( $(compgen -W 'vg_fmt vg_uuid vg_name vg_attr vg_size + --options | --sort | -!(-*)[oO]) + COMPREPLY=($(compgen -W 'vg_fmt vg_uuid vg_name vg_attr vg_size vg_free vg_sysid vg_extent_size vg_extent_count vg_free_count max_lv max_pv pv_count lv_count snap_count vg_seqno' \ - -- "$cur") ) + -- "$cur")) return ;; --units) @@ -249,13 +251,13 @@ _vgs() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgs vgs + complete -F _vgs vgs _vgdisplay() { @@ -269,13 +271,13 @@ _vgdisplay() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgdisplay vgdisplay + complete -F _vgdisplay vgdisplay _vgchange() { @@ -283,19 +285,19 @@ _vgchange() _init_completion || return case $prev in - --available|--autobackup|--resizeable|-!(-*)[aAx]) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --available | --autobackup | --resizeable | -!(-*)[aAx]) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgchange vgchange + complete -F _vgchange vgchange _vgcreate() { @@ -303,46 +305,46 @@ _vgcreate() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --metadatatype|-!(-*)M) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + --metadatatype | -!(-*)M) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; - --physicalextentsize|-!(-*)s) + --physicalextentsize | -!(-*)s) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup|-M|--metadatatype|-s|--physicalextentsize)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_volumegroups else _lvm_physicalvolumes_all fi fi } && -complete -F _vgcreate vgcreate + complete -F _vgcreate vgcreate _vgremove() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgremove vgremove + complete -F _vgremove vgremove _vgrename() { @@ -350,19 +352,19 @@ _vgrename() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgrename vgrename + complete -F _vgrename vgrename _vgreduce() { @@ -370,26 +372,26 @@ _vgreduce() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_volumegroups else _lvm_physicalvolumes fi fi } && -complete -F _vgreduce vgreduce + complete -F _vgreduce vgreduce _vgextend() { @@ -397,55 +399,55 @@ _vgextend() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --size|-!(-*)L) + --size | -!(-*)L) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup|-L|--size)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_volumegroups else _lvm_physicalvolumes_all fi fi } && -complete -F _vgextend vgextend + complete -F _vgextend vgextend _vgport() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgport vgimport vgexport + complete -F _vgport vgimport vgexport _vgck() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgck vgck + complete -F _vgck vgck _vgconvert() { @@ -453,12 +455,12 @@ _vgconvert() _init_completion || return case $prev in - --metadatatype|-!(-*)M) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + --metadatatype | -!(-*)M) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; --metadatacopies) - COMPREPLY=( $(compgen -W '0 1 2' -- "$cur") ) + COMPREPLY=($(compgen -W '0 1 2' -- "$cur")) return ;; --metadatasize) @@ -467,13 +469,13 @@ _vgconvert() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgconvert vgconvert + complete -F _vgconvert vgconvert _vgcfgbackup() { @@ -481,19 +483,19 @@ _vgcfgbackup() _init_completion || return case $prev in - --file|-!(-*)f) + --file | -!(-*)f) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgcfgbackup vgcfgbackup + complete -F _vgcfgbackup vgcfgbackup _vgcfgrestore() { @@ -501,27 +503,27 @@ _vgcfgrestore() _init_completion || return case $prev in - --file|-!(-*)f) + --file | -!(-*)f) _filedir return ;; - --metadatatype|-!(-*)M) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + --metadatatype | -!(-*)M) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; - --name|-!(-*)n) + --name | -!(-*)n) _lvm_volumegroups return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgcfgrestore vgcfgrestore + complete -F _vgcfgrestore vgcfgrestore _vgmerge() { @@ -529,19 +531,19 @@ _vgmerge() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgmerge vgmerge + complete -F _vgmerge vgmerge _vgsplit() { @@ -549,53 +551,53 @@ _vgsplit() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --metadatatype|-!(-*)M) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + --metadatatype | -!(-*)M) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup|-M|--metadatatype)' - if [[ $args -eq 0 || $args -eq 1 ]]; then + if ((args == 0 || args == 1)); then _lvm_volumegroups else _lvm_physicalvolumes fi fi } && -complete -F _vgsplit vgsplit + complete -F _vgsplit vgsplit _vgmknodes() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgmknodes vgmknodes + complete -F _vgmknodes vgmknodes _lvscan() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) fi } && -complete -F _lvscan lvscan + complete -F _lvscan lvscan _lvs() { @@ -603,10 +605,10 @@ _lvs() _init_completion || return case $prev in - --options|--sort|-!(-*)[oO]) - COMPREPLY=( $(compgen -W 'lv_uuid lv_name lv_attr lv_minor lv_size + --options | --sort | -!(-*)[oO]) + COMPREPLY=($(compgen -W 'lv_uuid lv_name lv_attr lv_minor lv_size seg_count origin snap_percent segtype stripes stripesize - chunksize seg_start seg_size' -- "$cur") ) + chunksize seg_start seg_size' -- "$cur")) return ;; --units) @@ -615,13 +617,13 @@ _lvs() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvs lvs + complete -F _lvs lvs _lvdisplay() { @@ -635,13 +637,13 @@ _lvdisplay() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvdisplay lvdisplay + complete -F _lvdisplay lvdisplay _lvchange() { @@ -649,23 +651,23 @@ _lvchange() _init_completion || return case $prev in - --available|--autobackup|--contiguous|--persistent|-!(-*)[aACM]) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --available | --autobackup | --contiguous | --persistent | -!(-*)[aACM]) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --permission|-!(-*)p) - COMPREPLY=( $(compgen -W 'r rw' -- "$cur") ) + --permission | -!(-*)p) + COMPREPLY=($(compgen -W 'r rw' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvchange lvchange + complete -F _lvchange lvchange _lvcreate() { @@ -673,37 +675,37 @@ _lvcreate() _init_completion || return case $prev in - --autobackup|--contiguous|--persistent|--zero|-!(-*)[ACMZ]) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | --contiguous | --persistent | --zero | -!(-*)[ACMZ]) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --size|-!(-*)L) + --size | -!(-*)L) _lvm_sizes return ;; - --permission|-!(-*)p) - COMPREPLY=( $(compgen -W 'r rw' -- "$cur") ) + --permission | -!(-*)p) + COMPREPLY=($(compgen -W 'r rw' -- "$cur")) return ;; - --name|-!(-*)n) + --name | -!(-*)n) _lvm_logicalvolumes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|-C|-M|-Z|--autobackup|--contiguous|--persistent|--zero|-L|--size|-p|--permission|-n|--name)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_volumegroups else _lvm_physicalvolumes fi fi } && -complete -F _lvcreate lvcreate + complete -F _lvcreate lvcreate _lvremove() { @@ -711,19 +713,19 @@ _lvremove() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvremove lvremove + complete -F _lvremove lvremove _lvrename() { @@ -731,19 +733,19 @@ _lvrename() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvrename lvrename + complete -F _lvrename lvrename _lvreduce() { @@ -751,23 +753,23 @@ _lvreduce() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --size|-!(-*)L) + --size | -!(-*)L) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvreduce lvreduce + complete -F _lvreduce lvreduce _lvresize() { @@ -775,29 +777,29 @@ _lvresize() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --size|-!(-*)L) + --size | -!(-*)L) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup|-L|--size)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_logicalvolumes else _lvm_physicalvolumes fi fi } && -complete -F _lvresize lvresize + complete -F _lvresize lvresize _lvextend() { @@ -805,55 +807,55 @@ _lvextend() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --size|-!(-*)L) + --size | -!(-*)L) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup|-L|--size)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_logicalvolumes else _lvm_physicalvolumes fi fi } && -complete -F _lvextend lvextend + complete -F _lvextend lvextend _lvm() { local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'dumpconfig help lvchange lvcreate lvdisplay + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'dumpconfig help lvchange lvcreate lvdisplay lvextend lvmchange lvmdiskscan lvmsadc lvmsar lvreduce lvremove lvrename lvresize lvs lvscan pvchange pvcreate pvdata pvdisplay pvmove pvremove pvresize pvs pvscan vgcfgbackup vgcfgrestore vgchange vgck vgconvert vgcreate vgdisplay vgexport vgextend vgimport vgmerge vgmknodes vgreduce vgremove vgrename vgs vgscan - vgsplit version' -- "$cur") ) + vgsplit version' -- "$cur")) else case "${words[1]}" in - pvchange|pvcreate|pvdisplay|pvmove|pvremove|pvresize|pvs|pvscan|\ - vgcfgbackup|vgcfgrestore|vgchange|vgck|vgconvert|vgcreate|\ - vgdisplay|vgexport|vgextend|vgimport|vgmerge|vgmknodes|vgreduce|\ - vgremove|vgrename|vgs|vgscan|vgsplit|lvchange|lvcreate|lvdisplay|\ - lvextend|lvreduce|lvremove|lvrename|lvresize|lvscan) + pvchange | pvcreate | pvdisplay | pvmove | pvremove | pvresize | pvs | pvscan | \ + vgcfgbackup | vgcfgrestore | vgchange | vgck | vgconvert | vgcreate | \ + vgdisplay | vgexport | vgextend | vgimport | vgmerge | vgmknodes | vgreduce | \ + vgremove | vgrename | vgs | vgscan | vgsplit | lvchange | lvcreate | lvdisplay | \ + lvextend | lvreduce | lvremove | lvrename | lvresize | lvscan) _${words[1]} ;; esac fi } && -complete -F _lvm lvm + complete -F _lvm lvm # ex: filetype=sh diff --git a/completions/lz4 b/completions/lz4 index 76c24bfa..f297b5d8 100644 --- a/completions/lz4 +++ b/completions/lz4 @@ -12,22 +12,22 @@ _lz4() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -X '-*#*' -W \ - '$(_parse_help "$1" -h) -B{4..7} -i{1..9}' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -X '-*#*' -W \ + '$(_parse_help "$1" -h) -B{4..7} -i{1..9}' -- "$cur")) return fi local args word xspec="*.?(t)lz4" _count_args - [[ $args -gt 2 ]] && return + ((args > 2)) && return for word in "${words[@]}"; do case $word in -*[dt]*) case $args in 1) xspec="!"$xspec ;; - 2) [[ $word == *t* ]] && return + 2) [[ $word == *t* ]] && return ;; esac break ;; @@ -45,8 +45,8 @@ _lz4() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _lz4 lz4 lz4c + complete -F _lz4 lz4 lz4c # ex: filetype=sh diff --git a/completions/lzip b/completions/lzip index 0f95722c..05f169c9 100644 --- a/completions/lzip +++ b/completions/lzip @@ -8,15 +8,15 @@ _lzip() local decompress=false case $prev in - --help|--version|--member-size|--match-length|--dictionary-size|\ - --volume-size|--data-size|-!(-*)@([bmsSB]|[hV]*)) + --help | --version | --member-size | --match-length | --dictionary-size | \ + --volume-size | --data-size | -!(-*)@([bmsSB]|[hV]*)) return ;; --decompress-!(-*)d) decompress=true ;; --threads-!(-*)n) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; --output-!(-*)o) @@ -27,9 +27,9 @@ _lzip() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -40,8 +40,8 @@ _lzip() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -f -X "*.lz" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "*.lz" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _lzip clzip lzip pdlzip plzip + complete -F _lzip clzip lzip pdlzip plzip # ex: filetype=sh diff --git a/completions/lzma b/completions/lzma index 81a626f5..34fba89f 100644 --- a/completions/lzma +++ b/completions/lzma @@ -8,27 +8,27 @@ _lzma() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -{1..9}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -{1..9}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi local IFS=$'\n' xspec="*.@(lzma|tlz)" - if [[ "$prev" == --* ]]; then - [[ "$prev" == --@(decompress|list|test) ]] && xspec="!"$xspec - [[ "$prev" == --compress ]] && xspec= - elif [[ "$prev" == -* ]]; then - [[ "$prev" == -*[dt]* ]] && xspec="!"$xspec - [[ "$prev" == -*z* ]] && xspec= + if [[ $prev == --* ]]; then + [[ $prev == --@(decompress|list|test) ]] && xspec="!"$xspec + [[ $prev == --compress ]] && xspec= + elif [[ $prev == -* ]]; then + [[ $prev == -*[dt]* ]] && xspec="!"$xspec + [[ $prev == -*z* ]] && xspec= fi _tilde "$cur" || return compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _lzma lzma + complete -F _lzma lzma # ex: filetype=sh diff --git a/completions/lzop b/completions/lzop index bedc122e..2642742a 100644 --- a/completions/lzop +++ b/completions/lzop @@ -6,7 +6,7 @@ _lzop() _init_completion || return case $prev in - --output|-!(-*)o) + --output | -!(-*)o) _filedir return ;; @@ -14,32 +14,32 @@ _lzop() _filedir -d return ;; - --suffix|-!(-*)S) + --suffix | -!(-*)S) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -9 -P + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -9 -P --fast --best --decompress --extract --test --list --ls --info --sysinfo --license --help --version --stdout --output --path --force --no-checksum --no-name --name --no-mode --no-time --suffix --keep --delete --crc32 --no-warn --ignore-warn --quiet --verbose --no-stdin --filter --checksum --no-color --mono --color' \ - -- "$cur") ) + -- "$cur")) return fi local xspec="*.?(t)lzo" case $prev in - --decompress|--uncompress|--extract|--list|--ls|--info|--test) + --decompress | --uncompress | --extract | --list | --ls | --info | --test) xspec="!"$xspec ;; --force) xspec= ;; - --*) - ;; + --*) ;; + -*f*) xspec= ;; @@ -52,8 +52,8 @@ _lzop() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _lzop lzop + complete -F _lzop lzop # ex: filetype=sh diff --git a/completions/macof b/completions/macof index c92a3864..ad29f58f 100644 --- a/completions/macof +++ b/completions/macof @@ -12,12 +12,11 @@ _macof() ;; esac - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) fi } && -complete -F _macof macof + complete -F _macof macof # ex: filetype=sh diff --git a/completions/mailmanctl b/completions/mailmanctl index dac1c5bf..3bbc2f24 100644 --- a/completions/mailmanctl +++ b/completions/mailmanctl @@ -5,14 +5,14 @@ _mailmanctl() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--no-restart --run-as-user - --stale-lock-cleanup --quiet --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--no-restart --run-as-user + --stale-lock-cleanup --quiet --help' -- "$cur")) else - COMPREPLY=( $(compgen -W 'start stop restart reopen' -- "$cur") ) + COMPREPLY=($(compgen -W 'start stop restart reopen' -- "$cur")) fi } && -complete -F _mailmanctl mailmanctl + complete -F _mailmanctl mailmanctl # ex: filetype=sh diff --git a/completions/make b/completions/make index f119dcc3..96517c21 100644 --- a/completions/make +++ b/completions/make @@ -8,7 +8,7 @@ _make_target_extract_script() local prefix="$1" local prefix_pat=$(command sed 's/[][\,.*^$(){}?+|/]/\\&/g' <<<"$prefix") local basename=${prefix##*/} - local dirname_len=$(( ${#prefix} - ${#basename} )) + local dirname_len=$((${#prefix} - ${#basename})) if [[ $mode == -d ]]; then # display mode, only output current path component to the next slash @@ -67,8 +67,8 @@ _make_target_extract_script() EOF # don't complete with hidden targets unless we are doing a partial completion - if [[ -z "${prefix_pat}" || "${prefix_pat}" = */ ]]; then - cat <<EOF + if [[ -z ${prefix_pat} || ${prefix_pat} == */ ]]; then + cat <<EOF /^${prefix_pat}[^a-zA-Z0-9]/d; # convention for hidden tgt EOF fi @@ -86,37 +86,37 @@ _make() local cur prev words cword split _init_completion -s || return - local file makef makef_dir=( "-C" "." ) makef_inc i + local makef makef_dir=("-C" ".") i case $prev in - --file|--makefile|--old-file|--assume-old|--what-if| --new-file|\ - --assume-new|-!(-*)[foW]) + --file | --makefile | --old-file | --assume-old | --what-if | --new-file | \ + --assume-new | -!(-*)[foW]) _filedir return ;; - --include-dir|--directory|-!(-*)[ICm]) + --include-dir | --directory | -!(-*)[ICm]) _filedir -d return ;; -!(-*)E) - COMPREPLY=( $(compgen -v -- "$cur") ) + COMPREPLY=($(compgen -v -- "$cur")) return ;; - --eval|-!(-*)[DVx]) + --eval | -!(-*)[DVx]) return ;; - --jobs|-!(-*)j) - COMPREPLY=( $(compgen -W "{1..$(( $(_ncpus)*2 ))}" -- "$cur") ) + --jobs | -!(-*)j) + COMPREPLY=($(compgen -W "{1..$(($(_ncpus) * 2))}" -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts="$(_parse_help "$1")" - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace elif [[ $cur == *=* ]]; then prev=${cur%%=*} cur=${cur#*=} @@ -126,20 +126,20 @@ _make() else # before we check for makefiles, see if a path was specified # with -C/--directory - for (( i=0; i < ${#words[@]}; i++ )); do + for ((i = 1; i < ${#words[@]}; i++)); do if [[ ${words[i]} == -@(C|-directory) ]]; then # eval for tilde expansion - eval "makef_dir=( -C \"${words[i+1]}\" )" + eval "makef_dir=( -C \"${words[i + 1]}\" )" break fi done # before we scan for targets, see if a Makefile name was # specified with -f/--file/--makefile - for (( i=0; i < ${#words[@]}; i++ )); do + for ((i = 1; i < ${#words[@]}; i++)); do if [[ ${words[i]} == -@(f|-?(make)file) ]]; then # eval for tilde expansion - eval "makef=( -f \"${words[i+1]}\" )" + eval "makef=( -f \"${words[i + 1]}\" )" break fi done @@ -147,24 +147,24 @@ _make() # recognise that possible completions are only going to be displayed # so only the base name is shown local mode=-- - if (( COMP_TYPE != 9 )); then + if ((COMP_TYPE != 9)); then mode=-d # display-only mode fi local IFS=$' \t\n' script=$(_make_target_extract_script $mode "$cur") - COMPREPLY=( $(LC_ALL=C \ + COMPREPLY=($(LC_ALL=C \ $1 -npq __BASH_MAKE_COMPLETION__=1 \ - "${makef[@]}" "${makef_dir[@]}" .DEFAULT 2>/dev/null | \ - command sed -ne "$script") ) + ${makef+"${makef[@]}"} "${makef_dir[@]}" .DEFAULT 2>/dev/null | + command sed -ne "$script")) if [[ $mode != -d ]]; then # Completion will occur if there is only one suggestion # so set options for completion based on the first one - [[ $COMPREPLY == */ ]] && compopt -o nospace + [[ ${COMPREPLY-} == */ ]] && compopt -o nospace fi fi } && -complete -F _make make gmake gnumake pmake colormake + complete -F _make make gmake gnumake pmake colormake bmake # ex: filetype=sh diff --git a/completions/makepkg b/completions/makepkg index 71d4f76d..23ac7848 100644 --- a/completions/makepkg +++ b/completions/makepkg @@ -7,16 +7,16 @@ _makepkg_slackware() _init_completion || return case "$prev" in - -l|--linkadd|-c|--chown) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + -l | --linkadd | -c | --chown) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W \ + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W \ '$($1 | command sed -e "s/^options://" | _parse_help -)' \ - -- "$cur") ) + -- "$cur")) return fi @@ -43,6 +43,6 @@ _makepkg_bootstrap() complete -F $fname makepkg $fname } && -complete -F _makepkg_bootstrap makepkg + complete -F _makepkg_bootstrap makepkg # ex: filetype=sh diff --git a/completions/man b/completions/man index e5a47361..81d06f51 100644 --- a/completions/man +++ b/completions/man @@ -10,29 +10,29 @@ _man() local mansect="@([0-9lnp]|[0-9][px]|3?(gl|pm))" case $prev in - --config-file|-!(-*)C) + --config-file | -!(-*)C) _filedir conf return ;; - --local-file|-!(-*)l) + --local-file | -!(-*)l) _filedir "$manext" return ;; - --manpath|-!(-*)M) + --manpath | -!(-*)M) _filedir -d return ;; - --pager|-!(-*)P) + --pager | -!(-*)P) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; - --preprocessor|-!(-*)p) - COMPREPLY=( $(compgen -W 'e p t g r v' -- "$cur") ) + --preprocessor | -!(-*)p) + COMPREPLY=($(compgen -W 'e p t g r v' -- "$cur")) return ;; - --locale|--systems|--extension|--prompt|--recode|--encoding|\ - -!(-*)[LmerRE]) + --locale | --systems | --extension | --prompt | --recode | --encoding | \ + -!(-*)[LmerRE]) return ;; esac @@ -41,13 +41,13 @@ _man() if [[ $cur == -* ]]; then local opts=$(_parse_help "$1" -h) - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi # file based completion if parameter looks like a path - if [[ "$cur" == @(*/|[.~])* ]]; then + if [[ $cur == @(*/|[.~])* ]]; then _filedir "$manext" return fi @@ -57,7 +57,8 @@ _man() # determine manual section to search local sect - [[ "$prev" == $mansect ]] && sect=$prev || sect='*' + # shellcheck disable=SC2053 + [[ $prev == $mansect ]] && sect=$prev || sect='*' _expand || return @@ -68,29 +69,33 @@ _man() manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }" fi - local IFS=$' \t\n' reset=$(shopt -p failglob); shopt -u failglob + local IFS=$' \t\n' reset=$(shopt -p failglob) + shopt -u failglob # redirect stderr for when path doesn't exist - COMPREPLY=( $(eval command ls "$manpath" 2>/dev/null) ) + COMPREPLY=($(eval command ls "$manpath" 2>/dev/null)) $reset - # weed out directory path names and paths to man pages - COMPREPLY=( ${COMPREPLY[@]##*/?(:)} ) - # strip suffix from man pages - COMPREPLY=( ${COMPREPLY[@]%$comprsuffix} ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}") ) + if ((${#COMPREPLY[@]} != 0)); then + # weed out directory path names and paths to man pages + COMPREPLY=(${COMPREPLY[@]##*/?(:)}) + # strip suffix from man pages + COMPREPLY=(${COMPREPLY[@]%$comprsuffix}) + COMPREPLY=($(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}")) + fi - if [[ "$prev" != $mansect ]]; then + # shellcheck disable=SC2053 + if [[ $prev != $mansect ]]; then # File based completion for the rest, prepending ./ if needed # (man 1.6f needs that for man pages in current dir) local i start=${#COMPREPLY[@]} _filedir "$manext" - for (( i=$start; i < ${#COMPREPLY[@]}; i++ )); do + for ((i = start; i < ${#COMPREPLY[@]}; i++)); do [[ ${COMPREPLY[i]} == */* ]] || COMPREPLY[i]=./${COMPREPLY[i]} done fi __ltrim_colon_completions "$cur" } && -complete -F _man man apropos whatis + complete -F _man man apropos whatis # ex: filetype=sh diff --git a/completions/mc b/completions/mc index 8e96dd97..cf38821c 100644 --- a/completions/mc +++ b/completions/mc @@ -6,24 +6,24 @@ _mc() _init_completion -s || return case $prev in - --edit|--view|--ftplog|--printwd|-!(-*)[evlP]) + --edit | --view | --ftplog | --printwd | -!(-*)[evlP]) _filedir return ;; - --help|--help-*|--version|--colors|--debuglevel|-!(-*)[hVCD]) + --help | --help-* | --version | --colors | --debuglevel | -!(-*)[hVCD]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir -d fi } && -complete -F _mc mc + complete -F _mc mc # ex: filetype=sh diff --git a/completions/mcrypt b/completions/mcrypt index f6094a22..0c3ab5e6 100644 --- a/completions/mcrypt +++ b/completions/mcrypt @@ -7,61 +7,61 @@ _mcrypt() _init_completion || return case $prev in - -g|--openpgp-z) - COMPREPLY=( $(compgen -W '{0..9}' -- "$cur") ) + -g | --openpgp-z) + COMPREPLY=($(compgen -W '{0..9}' -- "$cur")) return ;; - -o|--keymode) - COMPREPLY=( $(compgen -W '$($1 --list-keymodes 2>/dev/null )' \ - -- "$cur") ) + -o | --keymode) + COMPREPLY=($(compgen -W '$($1 --list-keymodes 2>/dev/null )' \ + -- "$cur")) return ;; - -m|--mode) - COMPREPLY=( $(compgen -W "$($1 --list 2>/dev/null | cut -d: -f2-)" \ - -- "$cur") ) + -m | --mode) + COMPREPLY=($(compgen -W "$($1 --list 2>/dev/null | cut -d: -f2-)" \ + -- "$cur")) return ;; - -a|--algorithm) - COMPREPLY=( $(compgen -W "$($1 --list 2>/dev/null | \ - awk '{print $1}')" -- "$cur") ) + -a | --algorithm) + COMPREPLY=($(compgen -W "$($1 --list 2>/dev/null | + awk '{print $1}')" -- "$cur")) return ;; - -h|--hash) - COMPREPLY=( $(compgen -W '$($1 --list-hash 2>/dev/null | \ - command sed -e 1d)' -- "$cur") ) + -h | --hash) + COMPREPLY=($(compgen -W '$($1 --list-hash 2>/dev/null | \ + command sed -e 1d)' -- "$cur")) return ;; - -k|-s|--key|--keysize) + -k | -s | --key | --keysize) return ;; - -f|-c|--keyfile|--config) + -f | -c | --keyfile | --config) _filedir return ;; - --algorithms-directory|--modes-directory) + --algorithms-directory | --modes-directory) _filedir -d return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) elif [[ ${words[0]} == mdecrypt ]]; then _filedir nc else local i decrypt=0 - for (( i=1; i < ${#words[@]}-1; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do if [[ ${words[i]} == -@(d|-decrypt) ]]; then _filedir nc decrypt=1 break fi done - if [[ $decrypt -eq 0 ]]; then + if ((decrypt == 0)); then _filedir fi fi } && -complete -F _mcrypt mcrypt mdecrypt + complete -F _mcrypt mcrypt mdecrypt # ex: filetype=sh diff --git a/completions/mdadm b/completions/mdadm index 5fbd9bf3..37effd96 100644 --- a/completions/mdadm +++ b/completions/mdadm @@ -4,13 +4,13 @@ _mdadm_raid_level() { local mode - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in - -!(-*)C*|--create) + -!(-*)C* | --create) mode=create break ;; - -!(-*)B*|--build) + -!(-*)B* | --build) mode=build break ;; @@ -19,13 +19,13 @@ _mdadm_raid_level() case $mode in create) - COMPREPLY=( $(compgen -W 'linear raid0 0 stripe raid1 1 mirror + COMPREPLY=($(compgen -W 'linear raid0 0 stripe raid1 1 mirror raid4 4 raid5 5 raid6 6 raid10 10 multipath mp faulty' \ - -- "$cur") ) + -- "$cur")) ;; build) - COMPREPLY=( $(compgen -W 'linear stripe raid0 0 raid1 multipath mp - faulty' -- "$cur") ) + COMPREPLY=($(compgen -W 'linear stripe raid0 0 raid1 multipath mp + faulty' -- "$cur")) ;; esac } @@ -33,64 +33,63 @@ _mdadm_raid_level() _mdadm_raid_layout() { local level - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -@(l|-level) ]]; then - level=${words[i+1]} + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -@(l|-level) ]]; then + level=${words[i + 1]} break fi done case $level in raid5) - COMPREPLY=( $(compgen -W 'left-asymmetric left-symmetric - right-asymmetric right-symmetric la ra ls rs' -- "$cur") ) + COMPREPLY=($(compgen -W 'left-asymmetric left-symmetric + right-asymmetric right-symmetric la ra ls rs' -- "$cur")) ;; raid10) - COMPREPLY=( $(compgen -W 'n o p' -- "$cur") ) + COMPREPLY=($(compgen -W 'n o p' -- "$cur")) ;; faulty) - COMPREPLY=( $(compgen -W 'write-transient wt read-transient rt + COMPREPLY=($(compgen -W 'write-transient wt read-transient rt write-persistent wp read-persistent rp write-all read-fixable - rf clear flush none' -- "$cur") ) + rf clear flush none' -- "$cur")) ;; esac } _mdadm_auto_flag() { - COMPREPLY=( $(compgen -W 'no yes md mdp part p' -- "$cur") ) + COMPREPLY=($(compgen -W 'no yes md mdp part p' -- "$cur")) } _mdadm_update_flag() { - COMPREPLY=( $(compgen -W 'sparc2.2 summaries uuid name homehost resync - byteorder super-minor' -- "$cur") ) + COMPREPLY=($(compgen -W 'sparc2.2 summaries uuid name homehost resync + byteorder super-minor' -- "$cur")) } - _mdadm() { local cur prev words cword split _init_completion -s || return case $prev in - --config|--bitmap|--backup-file|-!(-*)[cb]) + --config | --bitmap | --backup-file | -!(-*)[cb]) _filedir return ;; - --level|-!(-*)l) + --level | -!(-*)l) _mdadm_raid_level return ;; - --layout|--parity|-!(-*)p) + --layout | --parity | -!(-*)p) _mdadm_raid_layout return ;; - --auto|-!(-*)a) + --auto | -!(-*)a) _mdadm_auto_flag return ;; - --update|-!(-*)U) + --update | -!(-*)U) _mdadm_update_flag return ;; @@ -101,50 +100,50 @@ _mdadm() local options='--help --help-options --version --verbose --quiet --brief --force --config= --scan --metadata= --homehost=' - if [[ "$cur" == -* ]]; then - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W "$options --assemble --build --create - --monitor --grow" -- "$cur") ) + if [[ $cur == -* ]]; then + if ((cword == 1)); then + COMPREPLY=($(compgen -W "$options --assemble --build --create + --monitor --grow" -- "$cur")) else - case ${words[cword-1]} in - --assemble|-!(-*)A*) - COMPREPLY=( $(compgen -W "$options --uuid= --super-minor= + case ${words[cword - 1]} in + --assemble | -!(-*)A*) + COMPREPLY=($(compgen -W "$options --uuid= --super-minor= --name= --force --run --no-degraded --auto= --bitmap= --backup-file= --update= --auto-update-homehost" \ - -- "$cur") ) + -- "$cur")) ;; - --build|--create|--grow|-!(-*)[BCG]*) - COMPREPLY=( $(compgen -W "$options --raid-devices= + --build | --create | --grow | -!(-*)[BCG]*) + COMPREPLY=($(compgen -W "$options --raid-devices= --spare-devices= --size= --chunk= --rounding= --level= --layout= --parity= --bitmap= --bitmap-chunk= --write-mostly --write-behind= --assume-clean --backup-file= --name= --run --force --auto=" \ - -- "$cur") ) + -- "$cur")) ;; - --follow|--monitor|-!(-*)F) - COMPREPLY=( $(compgen -W "$options --mail --program + --follow | --monitor | -!(-*)F) + COMPREPLY=($(compgen -W "$options --mail --program --alert --syslog --delay --daemonise --pid-file - --oneshot --test" -- "$cur") ) + --oneshot --test" -- "$cur")) ;; - /dev/*|--add|--fail|--remove) - COMPREPLY=( $(compgen -W "$options --add --re-add - --remove --fail --set-faulty" -- "$cur") ) + /dev/* | --add | --fail | --remove) + COMPREPLY=($(compgen -W "$options --add --re-add + --remove --fail --set-faulty" -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W "$options --query --detail + COMPREPLY=($(compgen -W "$options --query --detail --examine --sparc2.2 --examine-bitmap --run --stop --readonly --readwrite --zero-superblock --test" \ - -- "$cur") ) + -- "$cur")) ;; esac fi - [[ $COMPREPLY == *= ]] && compopt -o nospace + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else cur=${cur:=/dev/} _filedir fi } && -complete -F _mdadm mdadm + complete -F _mdadm mdadm # ex: filetype=sh diff --git a/completions/mdtool b/completions/mdtool index 67a3c7c3..428e33b7 100644 --- a/completions/mdtool +++ b/completions/mdtool @@ -7,17 +7,18 @@ _mdtool() local command i - for (( i=0; i < ${#words[@]}-1; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do if [[ ${words[i]} == @(build|generate-makefiles|setup) ]]; then command=${words[i]} + break fi done - if [[ -n "$command" ]]; then + if [[ -v command ]]; then case $command in "build") - COMPREPLY=( $(compgen -W '--f --buildfile --p --project' \ - -S":" -- "$cur") ) + COMPREPLY=($(compgen -W '--f --buildfile --p --project' \ + -S":" -- "$cur")) # TODO: This does not work :( #if [[ "$prev" == *: ]]; then # case $prev in @@ -33,29 +34,29 @@ _mdtool() ;; "generate-makefiles") compopt -o filenames - COMPREPLY=( $(compgen -o filenames -G"*.mds" -- "$cur") ) - if [[ "$prev" == *mds ]]; then - COMPREPLY=( $(compgen -W '--simple-makefiles --s --d:' \ - -- "$cur") ) + COMPREPLY=($(compgen -o filenames -G"*.mds" -- "$cur")) + if [[ $prev == *mds ]]; then + COMPREPLY=($(compgen -W '--simple-makefiles --s --d:' \ + -- "$cur")) fi return ;; "setup") # TODO: at least return filenames after these options. - COMPREPLY=( $(compgen -W 'install i uninstall u check-install + COMPREPLY=($(compgen -W 'install i uninstall u check-install ci update up list l list-av la list-update lu rep-add ra rep-remove rr rep-update ru rep-list rl reg-update reg-build rgu info rep-build rb pack p help h dump-file' \ - -- "$cur") ) + -- "$cur")) return ;; esac fi - COMPREPLY=( $(compgen -W 'gsetup build dbgen project-export - generate-makefiles gettext-update setup -q' -- "$cur") ) + COMPREPLY=($(compgen -W 'gsetup build dbgen project-export + generate-makefiles gettext-update setup -q' -- "$cur")) } && -complete -F _mdtool mdtool + complete -F _mdtool mdtool # ex: filetype=sh diff --git a/completions/medusa b/completions/medusa index f0ca7022..45129879 100644 --- a/completions/medusa +++ b/completions/medusa @@ -15,16 +15,16 @@ _medusa() return ;; -*M) - COMPREPLY=( $(compgen -W "$($1 -d | awk '/^ +\+/ {print $2}' \ - | command sed -e 's/\.mod$//')") ) + COMPREPLY=($(compgen -W "$($1 -d | awk '/^ +\+/ {print $2}' | + command sed -e 's/\.mod$//')")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _medusa medusa + complete -F _medusa medusa # ex: filetype=sh diff --git a/completions/mii-diag b/completions/mii-diag index b62174e7..c433a7a2 100644 --- a/completions/mii-diag +++ b/completions/mii-diag @@ -6,21 +6,21 @@ _mii_diag() _init_completion -s || return case $prev in - -F|-A|--advertise|--fixed-speed) - COMPREPLY=( $(compgen -W '100baseT4 100baseTx 100baseTx-FD - 100baseTx-HD 10baseT 10baseT-FD 10baseT-HD' -- "$cur") ) + -F | -A | --advertise | --fixed-speed) + COMPREPLY=($(compgen -W '100baseT4 100baseTx 100baseTx-FD + 100baseTx-HD 10baseT 10baseT-FD 10baseT-HD' -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else _available_interfaces -a fi } && -complete -F _mii_diag -o default mii-diag + complete -F _mii_diag -o default mii-diag # ex: filetype=sh diff --git a/completions/mii-tool b/completions/mii-tool index 9c88ba14..1b80202b 100644 --- a/completions/mii-tool +++ b/completions/mii-tool @@ -6,27 +6,27 @@ _mii_tool() _init_completion -s || return case $prev in - --force|-!(-*)F) - COMPREPLY=( $(compgen -W '100baseTx-FD 100baseTx-HD 10baseT-FD - 10baseT-HD' -- "$cur") ) + --force | -!(-*)F) + COMPREPLY=($(compgen -W '100baseTx-FD 100baseTx-HD 10baseT-FD + 10baseT-HD' -- "$cur")) return ;; - --advertise|-!(-*)A) - COMPREPLY=( $(compgen -W '100baseT4 100baseTx-FD 100baseTx-HD - 10baseT-FD 10baseT-HD' -- "$cur") ) + --advertise | -!(-*)A) + COMPREPLY=($(compgen -W '100baseT4 100baseTx-FD 100baseTx-HD + 10baseT-FD 10baseT-HD' -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _available_interfaces -a fi } && -complete -F _mii_tool -o default mii-tool + complete -F _mii_tool -o default mii-tool # ex: filetype=sh diff --git a/completions/minicom b/completions/minicom index 2e98229a..57510e98 100644 --- a/completions/minicom +++ b/completions/minicom @@ -6,35 +6,35 @@ _minicom() _init_completion -s || return case $prev in - --attrib|--color|-!(-*)[ac]) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + --attrib | --color | -!(-*)[ac]) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; - --script|--capturefile|-!(-*)[SC]) + --script | --capturefile | -!(-*)[SC]) _filedir return ;; - --ptty|-!(-*)p) - COMPREPLY=( $(printf '%s\n' /dev/tty*) ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' \ - -- "$cur") ) + --ptty | -!(-*)p) + COMPREPLY=($(printf '%s\n' /dev/tty*)) + COMPREPLY=($(compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' \ + -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi COMPREPLY=( - $(printf '%s\n' /etc/minirc.* /etc/minicom/minirc.* ~/.minirc.* \ - | command sed -e '/\*$/d' -e 's/^.*minirc\.//' \ - | command grep "^${cur}") ) + $(printf '%s\n' /etc/minirc.* /etc/minicom/minirc.* ~/.minirc.* | + command sed -e '/\*$/d' -e 's/^.*minirc\.//' | + command grep "^${cur}")) } && -complete -F _minicom -o default minicom + complete -F _minicom -o default minicom # ex: filetype=sh diff --git a/completions/mkinitrd b/completions/mkinitrd index 2e131227..bcb7e075 100644 --- a/completions/mkinitrd +++ b/completions/mkinitrd @@ -6,11 +6,11 @@ _mkinitrd() _init_completion -s || return case $prev in - --preload|--with|--builtin) + --preload | --with | --builtin) _modules return ;; - --fstab|--dsdt) + --fstab | --dsdt) _filedir return ;; @@ -22,14 +22,14 @@ _mkinitrd() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version --help -v -f --preload \ + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--version --help -v -f --preload \ --force-scsi-probe --omit-scsi-modules \ --omit-ide-modules --image-version --force-raid-probe \ --omit-raid-modules --with= --force-lvm-probe \ --omit-lvm-modules --builtin --omit-dmraid --net-dev \ - --fstab --nocompress --dsdt --bootchart' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + --fstab --nocompress --dsdt --bootchart' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else local args _count_args @@ -45,6 +45,6 @@ _mkinitrd() fi } && -complete -F _mkinitrd mkinitrd + complete -F _mkinitrd mkinitrd # ex: filetype=sh diff --git a/completions/mktemp b/completions/mktemp index 96c7a118..e063810d 100644 --- a/completions/mktemp +++ b/completions/mktemp @@ -6,10 +6,10 @@ _mktemp() _init_completion -s || return case "$prev" in - --help|--version|--suffix) + --help | --version | --suffix) return ;; - --tmpdir|-!(-*)p) + --tmpdir | -!(-*)p) _filedir -d return ;; @@ -17,13 +17,13 @@ _mktemp() $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") [[ $opts ]] || opts="-d -u -q -p -t" # non-GNU fallback - COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W "$opts" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _mktemp mktemp + complete -F _mktemp mktemp # ex: filetype=sh diff --git a/completions/mmsitepass b/completions/mmsitepass index fc938d82..49daae61 100644 --- a/completions/mmsitepass +++ b/completions/mmsitepass @@ -5,11 +5,11 @@ _mmsitepass() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--listcreator --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--listcreator --help' -- "$cur")) fi } && -complete -F _mmsitepass mmsitepass + complete -F _mmsitepass mmsitepass # ex: filetype=sh diff --git a/completions/modinfo b/completions/modinfo index c151fad4..009bcf32 100644 --- a/completions/modinfo +++ b/completions/modinfo @@ -6,13 +6,13 @@ _modinfo() _init_completion -s || return case "$prev" in - --field|-!(-*)F) - COMPREPLY=( $(compgen -W 'alias author depends description + --field | -!(-*)F) + COMPREPLY=($(compgen -W 'alias author depends description filename firmware license parm srcversion staging vermagic - version' -- "${cur,,}") ) + version' -- "${cur,,}")) return ;; - --set-version|-!(-*)k) + --set-version | -!(-*)k) _kernel_versions return ;; @@ -20,28 +20,28 @@ _modinfo() $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi local i version=$(uname -r) - for (( i=${#words[@]}-1; i>0; i-- )); do + for ((i = ${#words[@]} - 1; i > 0; i--)); do if [[ ${words[i]} == -@(!(-*)k*|-set-version) ]]; then - version=${words[i+1]} + version=${words[i + 1]} break fi done # do filename completion if we're giving a path to a module - if [[ "$cur" == @(*/|[.~])* ]]; then - _filedir '@(?(k)o?(.gz))' + if [[ $cur == @(*/|[.~])* ]]; then + _filedir '@(?(k)o?(.[gx]z))' else _modules $version fi } && -complete -F _modinfo modinfo + complete -F _modinfo modinfo # ex: filetype=sh diff --git a/completions/modprobe b/completions/modprobe index 16c8453a..36cb5882 100644 --- a/completions/modprobe +++ b/completions/modprobe @@ -6,18 +6,18 @@ _modprobe() _init_completion -s || return case "$prev" in - --help|--version|-!(-*)[hV]) + --help | --version | -!(-*)[hV]) return ;; - --config|-!(-*)C) + --config | -!(-*)C) _filedir return ;; - --dirname|--type|-!(-*)[dt]) + --dirname | --type | -!(-*)[dt]) _filedir -d return ;; - --set-version|-!(-*)S) + --set-version | -!(-*)S) _kernel_versions return ;; @@ -25,44 +25,44 @@ _modprobe() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - if [[ ! $COMPREPLY ]]; then - COMPREPLY=( $(compgen -W '-a --all -b --use-blacklist -C --config + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + if [[ ! ${COMPREPLY-} ]]; then + COMPREPLY=($(compgen -W '-a --all -b --use-blacklist -C --config -c --showconfig --dump-modversions -d --dirname --first-time --force-vermagic --force-modversion -f --force -i --ignore-install --ignore-remove -l --list -n --dry-run -q --quiet -R --resolve-alias -r --remove -S --set-version --show-depends -s --syslog -t --type -V --version -v - --verbose' -- "$cur") ) + --verbose' -- "$cur")) fi - [[ $COMPREPLY == *= ]] && compopt -o nospace + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi local i mode=insert module="" version=$(uname -r) - for (( i=1; i < $cword; i++ )); do + for ((i = 1; i < cword; i++)); do case "${words[i]}" in - --remove|-!(-*)r*) + --remove | -!(-*)r*) mode=remove ;; - --list|-!(-*)l*) + --list | -!(-*)l*) mode=list ;; --dump-modversions) - mode=file + mode="file" ;; - --set-version|-!(-*)S) - version=${words[i+1]} # -S is not $prev and not $cur + --set-version | -!(-*)S) + version=${words[i + 1]} # -S is not $prev and not $cur ;; - --config|--dirname|--type|-!(-*)[Cdt]) + --config | --dirname | --type | -!(-*)[Cdt]) ((i++)) # skip option and its argument ;; -*) # skip all other options ;; *) - [ -z "$module" ] && module=${words[i]} + [[ -z $module ]] && module=${words[i]} ;; esac done @@ -79,45 +79,45 @@ _modprobe() ;; insert) # do filename completion if we're giving a path to a module - if [[ "$cur" == @(*/|[.~])* ]]; then - _filedir '@(?(k)o?(.gz))' - elif [[ -n "$module" ]]; then + if [[ $cur == @(*/|[.~])* ]]; then + _filedir '@(?(k)o?(.[gx]z))' + elif [[ -n $module ]]; then # do module parameter completion if [[ $cur == *=* ]]; then prev=${cur%%=*} cur=${cur#*=} - if PATH="$PATH:/sbin" modinfo -p "$module" 2>/dev/null \ - | command grep -q "^$prev:.*(bool)"; then + if PATH="$PATH:/sbin" modinfo -p "$module" 2>/dev/null | + command grep -q "^$prev:.*(bool)"; then local choices="on off" [[ $cur ]] && choices="1 0 y Y n N on off" - COMPREPLY=( $(compgen -W "$choices" -- "$cur") ) + COMPREPLY=($(compgen -W "$choices" -- "$cur")) fi else - COMPREPLY=( $(compgen -S = -W "$(PATH="$PATH:/sbin" \ - modinfo -p "$module" 2>/dev/null | \ - awk -F: '!/^[ \t]/ { print $1 }')" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -S = -W "$(PATH="$PATH:/sbin" \ + modinfo -p "$module" 2>/dev/null | + awk -F: '!/^[ \t]/ { print $1 }')" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi else _modules $version - if [[ $COMPREPLY ]]; then + if [[ ${COMPREPLY-} ]]; then # filter out already installed modules - local -a mods=( "${COMPREPLY[@]}" ) + local -a mods=("${COMPREPLY[@]}") _installed_modules "$cur" for i in "${!mods[@]}"; do for module in "${COMPREPLY[@]}"; do - if [[ ${mods[i]} == $module ]]; then + if [[ ${mods[i]} == "$module" ]]; then unset 'mods[i]' break fi done done - COMPREPLY=( "${mods[@]}" ) + COMPREPLY=("${mods[@]}") fi fi ;; esac } && -complete -F _modprobe modprobe + complete -F _modprobe modprobe # ex: filetype=sh diff --git a/completions/monodevelop b/completions/monodevelop index 4aa213b7..1c5b5ba4 100644 --- a/completions/monodevelop +++ b/completions/monodevelop @@ -7,13 +7,13 @@ _monodevelop() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir fi } && -complete -F _monodevelop monodevelop + complete -F _monodevelop monodevelop # ex: filetype=sh diff --git a/completions/mplayer b/completions/mplayer index 525c63e2..d71ebb8e 100644 --- a/completions/mplayer +++ b/completions/mplayer @@ -3,9 +3,9 @@ _mplayer_options_list() { cur=${cur%\\} - 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") ) + 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")) } _mplayer() @@ -16,8 +16,8 @@ _mplayer() local cmd=${words[0]} i j k=0 case $prev in - -[av][cfo]|-[av]fm|-vop|-fstype|-demuxer|-o[av]c|-of|-profile| \ - -audio-demuxer|-sub-demuxer) + -[av][cfo] | -[av]fm | -vop | -fstype | -demuxer | -o[av]c | -of | -profile | \ + -audio-demuxer | -sub-demuxer) _mplayer_options_list $cmd $prev return ;; @@ -25,43 +25,43 @@ _mplayer() _mplayer_options_list $cmd -profile return ;; - -audiofile|-audio-file) + -audiofile | -audio-file) _filedir '@(mp3|mpg|og[ag]|w?(a)v|mid|flac|mka|ac3|ape)' return ;; - -font|-subfont) + -font | -subfont) if [[ $prev == -font ]]; then _filedir '@(desc|ttf)' else _filedir ttf fi local IFS=$'\n' - COMPREPLY+=( $(compgen -W '$(fc-list 2>/dev/null)' -- "$cur") ) + COMPREPLY+=($(compgen -W '$(fc-list 2>/dev/null)' -- "$cur")) return ;; - -sub|-sub-file) + -sub | -sub-file) _filedir '@(srt|sub|txt|utf|rar|mpsub|smi|js|ssa|ass)' return ;; -vobsub) _filedir '@(idx|ifo|sub)' local IFS=$'\n' - COMPREPLY=( $(for i in "${COMPREPLY[@]}"; do - if [[ -f $i && -r $i ]]; then - printf '%s\n' ${i%.*} - else - printf '%s\n' $i - fi - done) ) + COMPREPLY=($(for i in "${COMPREPLY[@]}"; do + if [[ -f $i && -r $i ]]; then + printf '%s\n' ${i%.*} + else + printf '%s\n' $i + fi + done)) return ;; - -subcp|-msgcharset) + -subcp | -msgcharset) local cp - cp=( $(iconv --list 2>/dev/null | command sed -e "s@//@@;" 2>/dev/null) ) - if [[ "$cur" == "${cur,,}" ]]; then - COMPREPLY=( $(compgen -W '${cp[@],,}' -- "$cur") ) + cp=($(iconv --list 2>/dev/null | command sed -e "s@//@@;" 2>/dev/null)) + if [[ $cur == "${cur,,}" ]]; then + COMPREPLY=($(compgen -W '${cp[@],,}' -- "$cur")) else - COMPREPLY=( $(compgen -W '${cp[@]^^}' -- "$cur") ) + COMPREPLY=($(compgen -W '${cp[@]^^}' -- "$cur")) fi return ;; @@ -107,53 +107,52 @@ _mplayer() _filedir -d return ;; - -mixer|-dvdauth|-fb|-zrdev) + -mixer | -dvdauth | -fb | -zrdev) cur=${cur:=/dev/} _filedir return ;; - -edl|-edlout|-lircconf|-menu-cfg|-playlist|-csslib|-dumpfile| \ - -subfile|-vobsub|-aofile|-fbmodeconfig|-include|-o|-dvdkey| \ - -passlogfile) + -edl | -edlout | -lircconf | -menu-cfg | -playlist | -csslib | -dumpfile | \ + -subfile | -aofile | -fbmodeconfig | -include | -o | -dvdkey | -passlogfile) _filedir return ;; - -autoq|-autosync|-loop|-menu-root|-speed|-sstep|-aid|-alang| \ - -bandwidth|-bluray-angle|-bluray-chapter|-cache|-chapter|-dvd-speed| \ - -dvdangle|-fps|-frames|-mc|-passwd|-user|-sb|-srate|-ss|-vcd| \ - -vi|-vid|-vivo|-ffactor|-sid|-slang|-spualign|-spuaa|-spugauss| \ - -vobsubid|-delay|-bpp|-brightness|-contrast|-dfbopts|-display| \ - -fbmode|-geometry|-guiwid|-hue|-icelayer|-screen[wh]|-wid| \ - -monitor-dotclock|-monitor-[hv]freq|-panscan| \ - -saturation|-xineramascreen|-zrcrop|-zrnorm|-zrquality| \ - -zr[xy]doff|-zr[vh]dec|-pp|-x|-y|-xy|-z|-stereo| \ - -audio-density|-audio-delay|-audio-preload|-endpos|-osdlevel| \ - -ffourcc|-sws|-skiplimit|-format|-ofps|-aadriver| \ - -aaosdcolor|-aasubcolor|-vobsubout|-vobsuboutid|-vobsuboutindex| \ - -sub-bg-alpha|-sub-bg-color|-subdelay|-subfps|-subpos| \ - -subalign|-subwidth|-subfont-blur|-subfont-outline| \ - -subfont-autoscale|-subfont-encoding|-subfont-osd-scale| \ - -subfont-text-scale) + -autoq | -autosync | -loop | -menu-root | -speed | -sstep | -aid | -alang | \ + -bandwidth | -bluray-angle | -bluray-chapter | -cache | -chapter | -dvd-speed | \ + -dvdangle | -fps | -frames | -mc | -passwd | -user | -sb | -srate | -ss | -vcd | \ + -vi | -vid | -vivo | -ffactor | -sid | -slang | -spualign | -spuaa | -spugauss | \ + -vobsubid | -delay | -bpp | -brightness | -contrast | -dfbopts | -display | \ + -fbmode | -geometry | -guiwid | -hue | -icelayer | -screen[wh] | -wid | \ + -monitor-dotclock | -monitor-[hv]freq | -panscan | \ + -saturation | -xineramascreen | -zrcrop | -zrnorm | -zrquality | \ + -zr[xy]doff | -zr[vh]dec | -pp | -x | -y | -xy | -z | -stereo | \ + -audio-density | -audio-delay | -audio-preload | -endpos | -osdlevel | \ + -ffourcc | -sws | -skiplimit | -format | -ofps | -aadriver | \ + -aaosdcolor | -aasubcolor | -vobsubout | -vobsuboutid | -vobsuboutindex | \ + -sub-bg-alpha | -sub-bg-color | -subdelay | -subfps | -subpos | \ + -subalign | -subwidth | -subfont-blur | -subfont-outline | \ + -subfont-autoscale | -subfont-encoding | -subfont-osd-scale | \ + -subfont-text-scale) return ;; -channels) - COMPREPLY=( $(compgen -W '2 4 6 8' -- "$cur") ) + COMPREPLY=($(compgen -W '2 4 6 8' -- "$cur")) return ;; - -aspect|-monitoraspect) - COMPREPLY=( $(compgen -W '1:1 3:2 4:3 5:4 14:9 14:10 16:9 16:10 - 2.35:1' -- "$cur") ) + -aspect | -monitoraspect) + COMPREPLY=($(compgen -W '1:1 3:2 4:3 5:4 14:9 14:10 16:9 16:10 + 2.35:1' -- "$cur")) __ltrim_colon_completions "$cur" return ;; -lavdopts) - COMPREPLY=( $(compgen -W 'bitexact bug= debug= ec= er= fast gray + COMPREPLY=($(compgen -W 'bitexact bug= debug= ec= er= fast gray idct= lowres= sb= st= skiploopfilter= skipidct= skipframe= - threads= vismv= vstats' -- "$cur") ) + threads= vismv= vstats' -- "$cur")) return ;; -lavcopts) - COMPREPLY=( $(compgen -W 'vcodec= vqmin= vqscale= vqmax= mbqmin= + COMPREPLY=($(compgen -W 'vcodec= vqmin= vqscale= vqmax= mbqmin= mbqmax= vqdiff= vmax_b_frames= vme= vhq v4mv keyint= vb_strategy= vpass= aspect= vbitrate= vratetol= vrc_maxrate= vrc_minrate= vrc_buf_size= vb_qfactor= vi_qfactor= vb_qoffset= @@ -162,120 +161,120 @@ _mplayer() vpsize= gray vfdct= idct= lumi_mask= dark_mask= tcplx_mask= scplx_mask= naq ildct format= pred qpel precmp= cmp= subcmp= predia= dia= trell last_pred= preme= subq= psnr mpeg_quant aic - umv' -- "$cur") ) + umv' -- "$cur")) return ;; -ssf) - COMPREPLY=( $(compgen -W 'lgb= cgb= ls= cs= chs= cvs=' -- "$cur") ) + COMPREPLY=($(compgen -W 'lgb= cgb= ls= cs= chs= cvs=' -- "$cur")) return ;; -jpeg) - COMPREPLY=( $(compgen -W 'noprogressive progressive nobaseline - baseline optimize= smooth= quality= outdir=' -- "$cur") ) + COMPREPLY=($(compgen -W 'noprogressive progressive nobaseline + baseline optimize= smooth= quality= outdir=' -- "$cur")) return ;; -xvidopts) - COMPREPLY=( $(compgen -W 'dr2 nodr2' -- "$cur") ) + COMPREPLY=($(compgen -W 'dr2 nodr2' -- "$cur")) return ;; -xvidencopts) - COMPREPLY=( $(compgen -W 'pass= bitrate= fixed_quant= me_quality= + COMPREPLY=($(compgen -W 'pass= bitrate= fixed_quant= me_quality= 4mv rc_reaction_delay_factor= rc_averaging_period= rc_buffer= quant_range= min_key_interval= max_key_interval= mpeg_quant mod_quant lumi_mask hintedme hintfile debug keyframe_boost= - kfthreshold= kfreduction=' -- "$cur") ) + kfthreshold= kfreduction=' -- "$cur")) return ;; -divx4opts) - COMPREPLY=( $(compgen -W 'br= key= deinterlace q= min_quant= + COMPREPLY=($(compgen -W 'br= key= deinterlace q= min_quant= max_quant= rc_period= rc_reaction_period= crispness= - rc_reaction_ratio= pass= vbrpass= help' -- "$cur") ) + rc_reaction_ratio= pass= vbrpass= help' -- "$cur")) return ;; -info) - COMPREPLY=( $(compgen -W 'name= artist= genre= subject= - copyright= srcform= comment= help' -- "$cur") ) + COMPREPLY=($(compgen -W 'name= artist= genre= subject= + copyright= srcform= comment= help' -- "$cur")) return ;; -lameopts) - COMPREPLY=( $(compgen -W 'vbr= abr cbr br= q= aq= ratio= vol= - mode= padding= fast preset= help' -- "$cur") ) + COMPREPLY=($(compgen -W 'vbr= abr cbr br= q= aq= ratio= vol= + mode= padding= fast preset= help' -- "$cur")) return ;; -rawaudio) - COMPREPLY=( $(compgen -W 'on channels= rate= samplesize= format=' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'on channels= rate= samplesize= format=' \ + -- "$cur")) return ;; -rawvideo) - COMPREPLY=( $(compgen -W 'on fps= sqcif qcif cif 4cif pal ntsc w= - h= y420 yv12 yuy2 y8 format= size=' -- "$cur") ) + COMPREPLY=($(compgen -W 'on fps= sqcif qcif cif 4cif pal ntsc w= + h= y420 yv12 yuy2 y8 format= size=' -- "$cur")) return ;; -aop) - COMPREPLY=( $(compgen -W 'list= delay= format= fout= volume= mul= - softclip' -- "$cur") ) + COMPREPLY=($(compgen -W 'list= delay= format= fout= volume= mul= + softclip' -- "$cur")) return ;; -dxr2) - COMPREPLY=( $(compgen -W 'ar-mode= iec958-encoded iec958-decoded + COMPREPLY=($(compgen -W 'ar-mode= iec958-encoded iec958-decoded mute ucode= 75ire bw color interlaced macrovision= norm= square-pixel ccir601-pixel cr-left= cr-right= cr-top= cr-bot= ck-rmin= ck-gmin= ck-bmin= ck-rmax= ck-gmax= ck-bmax= ck-r= ck-g= ck-b= ignore-cache= ol-osd= olh-cor= olw-cor= olx-cor= - oly-cor= overlay overlay-ratio= update-cache' -- "$cur") ) + oly-cor= overlay overlay-ratio= update-cache' -- "$cur")) return ;; -tv) - COMPREPLY=( $(compgen -W 'on noaudio driver= device= input= freq= + COMPREPLY=($(compgen -W 'on noaudio driver= device= input= freq= outfmt= width= height= buffersize= norm= channel= chanlist= audiorate= forceaudio alsa amode= forcechan= adevice= audioid= volume= bass= treble= balance= fps= channels= immediatemode=' \ - -- "$cur") ) + -- "$cur")) return ;; -mf) - COMPREPLY=( $(compgen -W 'on w= h= fps= type=' -- "$cur") ) + COMPREPLY=($(compgen -W 'on w= h= fps= type=' -- "$cur")) return ;; -cdda) - COMPREPLY=( $(compgen -W 'speed= paranoia= generic-dev= + COMPREPLY=($(compgen -W 'speed= paranoia= generic-dev= sector-size= overlap= toc-bias toc-offset= skip noskip' \ - -- "$cur") ) + -- "$cur")) return ;; -input) - COMPREPLY=( $(compgen -W 'conf= ar-delay ar-rate keylist cmdlist - js-dev file' -- "$cur") ) + COMPREPLY=($(compgen -W 'conf= ar-delay ar-rate keylist cmdlist + js-dev file' -- "$cur")) return ;; -af-adv) - COMPREPLY=( $(compgen -W 'force= list=' -- "$cur") ) + COMPREPLY=($(compgen -W 'force= list=' -- "$cur")) return ;; -noconfig) - COMPREPLY=( $(compgen -W 'all gui system user' -- "$cur") ) + COMPREPLY=($(compgen -W 'all gui system user' -- "$cur")) return ;; -*) # Assume arg is required for everything else except options # for which -list-options says Type is Flag or Print. - $cmd -noconfig all -list-options 2>/dev/null \ - | while read -r i j k; do - if [[ $i == ${prev#-} ]]; then - [[ ${j,,} != @(flag|print) ]] && return 1 - break - fi - done || return + $cmd -noconfig all -list-options 2>/dev/null | + while read -r i j k; do + if [[ $i == "${prev#-}" ]]; then + [[ ${j,,} != @(flag|print) ]] && return 1 + break + fi + done || return ;; esac case $cur in -*) - COMPREPLY=( $(compgen -W '$($cmd -noconfig all -list-options 2>/dev/null | \ - command sed -ne '1,/^[[:space:]]*Name/d' \ + 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") ) + -e "/^-\(Total\|.*\*\)\{0,1\}$/!p")' -- "$cur")) ;; *) _filedir '@(m?(j)p?(e)g|M?(J)P?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fl[iv]|FL[IV]|fxm|FXM|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|t[ps]|T[PS]|3g[p2]|3gpp?(2)|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2t?(s)|M2T?(S)|mts|MTS|vdr|VDR|xvid|XVID|ape|APE|gif|GIF|nut|NUT|bik|BIK|web[am]|WEB[AM]|amr|AMR|awb|AWB|iso|ISO|opus|OPUS|m[eo]d|M[EO]D|xm|XM|it|IT|s[t3]m|S[T3]M|mtm|MTM|w64|W64)?(.@(crdownload|part))' @@ -283,6 +282,6 @@ _mplayer() esac } && -complete -F _mplayer mplayer mplayer2 mencoder gmplayer kplayer + complete -F _mplayer mplayer mplayer2 mencoder gmplayer kplayer # ex: filetype=sh diff --git a/completions/mr b/completions/mr index 15f634a3..930e3c96 100644 --- a/completions/mr +++ b/completions/mr @@ -1,6 +1,7 @@ # mr completion -*- shell-script -*- -_mr() { +_mr() +{ local cur prev words cword _init_completion || return @@ -8,7 +9,11 @@ _mr() { help="$(PERLDOC_PAGER=cat PERLDOC=-otext "${1}" help 2>/dev/null)" - commands="$(awk '/\[options\]/ { print $3 }' <<<"${help}")" + commands="$( + printf %s "$help" | while read -r _ options cmd _; do + [[ $options != "[options]" ]] || printf "%s\n" "$cmd" + done + )" # Split [online|offline] and remove `action` placeholder. commands="${commands//@(action|[\[\|\]])/$'\n'}" # Add standard aliases. @@ -17,7 +22,7 @@ _mr() { # Determine if user has entered an `mr` command. Used to block top-level # (option and command) completions. local cmd i - for (( i=0; i < ${#words[@]}-1; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do if [[ $commands == *"${words[i]}"* ]]; then cmd="${words[i]}" break @@ -25,30 +30,30 @@ _mr() { done # Complete options for specific commands. - if [[ -n $cmd ]]; then + if [[ -v cmd ]]; then case $cmd in bootstrap) _filedir # Also complete stdin (-) as a potential bootstrap source. - if [[ -z "${cur}" || $cur == - ]] && [[ $prev != - ]]; then - COMPREPLY+=( - ) + if [[ -z ${cur} || $cur == - ]] && [[ $prev != - ]]; then + COMPREPLY+=(-) fi return ;; clean) - if [[ "${cur}" == -* ]]; then - COMPREPLY=( $(compgen -W '-f' -- "${cur}") ) + if [[ ${cur} == -* ]]; then + COMPREPLY=($(compgen -W '-f' -- "${cur}")) fi return ;; - commit|ci|record) - if [[ "${cur}" == -* ]]; then - COMPREPLY=( $(compgen -W '-m' -- "${cur}") ) + commit | ci | record) + if [[ ${cur} == -* ]]; then + COMPREPLY=($(compgen -W '-m' -- "${cur}")) fi return ;; run) - COMPREPLY=( $(compgen -c -- "${cur}") ) + COMPREPLY=($(compgen -c -- "${cur}")) return ;; *) @@ -60,27 +65,27 @@ _mr() { # Complete top-level options and commands. case $prev in - --config|-!(-*)c) + --config | -!(-*)c) _filedir return ;; - --directory|-!(-*)d) + --directory | -!(-*)d) _filedir -d return ;; esac if [[ $cur == -* ]]; then - options="$(_parse_help - <<<"${help}")" + options="$(printf '%s\n' "$help" | _parse_help -)" # Remove short options (all have compatible long options). options="${options//-[a-z]$'\n'/}" # Remove deprecated options. options="${options//--path/}" - COMPREPLY=( $(compgen -W "${options}" -- "${cur}") ) + COMPREPLY=($(compgen -W "${options}" -- "${cur}")) else - COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") ) + COMPREPLY=($(compgen -W "${commands}" -- "${cur}")) fi } && -complete -F _mr mr + complete -F _mr mr # ex: filetype=sh diff --git a/completions/msynctool b/completions/msynctool index 4fd51618..4de37f5b 100644 --- a/completions/msynctool +++ b/completions/msynctool @@ -7,36 +7,36 @@ _msynctool() case $words in --configure) - COMPREPLY=( $(compgen -W "$($1 --showgroup \ + COMPREPLY=($(compgen -W "$($1 --showgroup \ $prev | awk '/^Member/ {print $2}' | command sed \ - -e 's/:$//')" -- "$cur") ) + -e 's/:$//')" -- "$cur")) return ;; --addmember) - COMPREPLY=( $(compgen -W '$($1 --listplugins \ - | command sed -e 1d)' -- "$cur") ) + COMPREPLY=($(compgen -W '$($1 --listplugins \ + | command sed -e 1d)' -- "$cur")) return ;; esac case $prev in - --configure|--addgroup|--delgroup|--showgroup|--sync|--addmember) - COMPREPLY=( $(compgen -W '$($1 --listgroups \ - | command sed -e 1d)' -- "$cur") ) + --configure | --addgroup | --delgroup | --showgroup | --sync | --addmember) + COMPREPLY=($(compgen -W '$($1 --listgroups \ + | command sed -e 1d)' -- "$cur")) return ;; - --showformats|--filter-objtype|--slow-sync) - COMPREPLY=( $(compgen -W '$($1 --listobjects \ - | command sed -e 1d)' -- "$cur") ) + --showformats | --filter-objtype | --slow-sync) + COMPREPLY=($(compgen -W '$($1 --listobjects \ + | command sed -e 1d)' -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W '--listgroups --listplugins --listobjects + COMPREPLY=($(compgen -W '--listgroups --listplugins --listobjects --showformats --showgroup --sync --filter-objtype --slow-sync --wait --multi --addgroup --delgroup --addmember --configure --manual - --configdir --conflict' -- "$cur") ) + --configdir --conflict' -- "$cur")) } && -complete -F _msynctool msynctool + complete -F _msynctool msynctool # ex: filetype=sh diff --git a/completions/mtx b/completions/mtx index 9266687c..b5c270bd 100644 --- a/completions/mtx +++ b/completions/mtx @@ -11,22 +11,22 @@ _mtx() options="-f nobarcode invert noattach --version inquiry noattach \ inventory status load unload eepos first last next" - tapes=$(mtx status 2>/dev/null | \ + tapes=$(mtx status 2>/dev/null | awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }') - tapes=${tapes//:Full} + tapes=${tapes//:Full/} - drives=$(mtx status 2>/dev/null | \ + drives=$(mtx status 2>/dev/null | awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }') - drives=${drives//:Full} - drives=${drives//:Empty} + drives=${drives//:Full/} + drives=${drives//:Empty/} - if [[ $cword -gt 1 ]]; then + if ((cword > 1)); then case $prev in load) - COMPREPLY=( $(compgen -W "$tapes" -- "$cur") ) + COMPREPLY=($(compgen -W "$tapes" -- "$cur")) ;; - unload|first|last|next) - COMPREPLY=( $(compgen -W "$drives" -- "$cur") ) + unload | first | last | next) + COMPREPLY=($(compgen -W "$drives" -- "$cur")) ;; -f) true @@ -36,9 +36,9 @@ _mtx() ;; esac else - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) fi } && -complete -F _mtx mtx + complete -F _mtx mtx # ex: filetype=sh diff --git a/completions/munin-node-configure b/completions/munin-node-configure index 1d564d3f..39d8d64b 100644 --- a/completions/munin-node-configure +++ b/completions/munin-node-configure @@ -10,7 +10,7 @@ _munin_node_configure() _filedir return ;; - --servicedir|--libdir) + --servicedir | --libdir) _filedir -d return ;; @@ -19,15 +19,15 @@ _munin_node_configure() return ;; --snmpversion) - COMPREPLY=( $(compgen -W '1 2c 3' -- "$cur") ) + COMPREPLY=($(compgen -W '1 2c 3' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _munin_node_configure munin-node-configure + complete -F _munin_node_configure munin-node-configure # ex: filetype=sh diff --git a/completions/munin-run b/completions/munin-run index 6855e02d..97e526aa 100644 --- a/completions/munin-run +++ b/completions/munin-run @@ -6,23 +6,23 @@ _munin_run() _init_completion || return case $prev in - --config|--sconffile) + --config | --sconffile) _filedir return ;; - --servicedir|--sconfdir) + --servicedir | --sconfdir) _filedir -d return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - COMPREPLY=( $(compgen -W \ - '$(command ls /etc/munin/plugins 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W \ + '$(command ls /etc/munin/plugins 2>/dev/null)' -- "$cur")) fi } && -complete -F _munin_run munin-run + complete -F _munin_run munin-run # ex: filetype=sh diff --git a/completions/munin-update b/completions/munin-update index ac770a6b..8766eaee 100644 --- a/completions/munin-update +++ b/completions/munin-update @@ -16,12 +16,12 @@ _munin_update() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--force-root --noforce-root --service --host + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--force-root --noforce-root --service --host --config --help --debug --nodebug --fork --nofork --stdout - --nostdout --timeout' -- "$cur") ) + --nostdout --timeout' -- "$cur")) fi } && -complete -F _munin_update munin-update + complete -F _munin_update munin-update # ex: filetype=sh diff --git a/completions/munindoc b/completions/munindoc index a08399ba..5c7644a6 100644 --- a/completions/munindoc +++ b/completions/munindoc @@ -5,9 +5,9 @@ _munindoc() local cur prev words cword _init_completion || return - COMPREPLY=( $(compgen -W \ - '$(command ls /usr/share/munin/plugins 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W \ + '$(command ls /usr/share/munin/plugins 2>/dev/null)' -- "$cur")) } && -complete -F _munindoc munindoc + complete -F _munindoc munindoc # ex: filetype=sh diff --git a/completions/mussh b/completions/mussh index e76817c7..c2f7a522 100644 --- a/completions/mussh +++ b/completions/mussh @@ -6,47 +6,47 @@ _mussh() _init_completion || return case $prev in - --help|-V|-m|-t) + --help | -V | -m | -t) return ;; -d) - COMPREPLY=( $(compgen -W '{0..2}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..2}' -- "$cur")) return ;; -v) - COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..3}' -- "$cur")) return ;; - -i|-H|-C) + -i | -H | -C) _filedir return ;; - -o|-po) + -o | -po) _xfunc ssh _ssh_options return ;; - -l|-L) - COMPREPLY=( $(compgen -u -- "$cur") ) + -l | -L) + COMPREPLY=($(compgen -u -- "$cur")) return ;; -s) _shells return ;; - -p|-h) + -p | -h) [[ $cur == *@* ]] && _user_at_host || _known_hosts_real -a -- "$cur" return ;; -c) compopt -o filenames - COMPREPLY+=( $(compgen -c -- "$cur") ) + COMPREPLY+=($(compgen -c -- "$cur")) return ;; esac - [[ $cur != -* ]] || \ - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $cur != -* ]] || + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _mussh mussh + complete -F _mussh mussh # ex: filetype=sh diff --git a/completions/mutt b/completions/mutt index 43a8842e..1161487a 100644 --- a/completions/mutt +++ b/completions/mutt @@ -9,19 +9,18 @@ _muttaddr() _muttaliases "$1" _muttquery "$1" - COMPREPLY+=( $(compgen -u -- "$1") ) + COMPREPLY+=($(compgen -u -- "$1")) } - # Find muttrc to use # @output muttrc filename _muttrc() { # Search COMP_WORDS for '-F muttrc' or '-Fmuttrc' argument set -- "${words[@]}" - while [[ $# -gt 0 ]]; do + while (($# > 0)); do if [[ $1 == -F* ]]; then - if [[ ${#1} -gt 2 ]]; then + if ((${#1} > 2)); then muttrc="$(dequote "${1:2}")" else shift @@ -32,17 +31,16 @@ _muttrc() shift done - if [[ -z $muttrc ]]; then + if [[ ! -v muttrc ]]; then if [[ -f ~/.${muttcmd}rc ]]; then - muttrc="~/.${muttcmd}rc" + muttrc=\~/.${muttcmd}rc elif [[ -f ~/.${muttcmd}/${muttcmd}rc ]]; then - muttrc="~/.${muttcmd}/${muttcmd}rc" + muttrc=\~/.${muttcmd}/${muttcmd}rc fi fi - printf "%s" "$muttrc" + printf "%s" "${muttrc-}" } - # Recursively build list of sourced config files # @param $1 List of config files found so far # @param $2 Config file to process @@ -54,11 +52,11 @@ _muttconffiles() sofar=" $1 " shift - while [[ "$1" ]]; do - newconffiles=( $(command sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval printf %s $1) ) ) - for file in "${newconffiles[@]}"; do + while [[ ${1-} ]]; do + newconffiles=($(command sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' "$(eval printf %s $1)")) + for file in ${newconffiles+"${newconffiles[@]}"}; do __expand_tilde_by_ref file - [[ ! -f "$file" || $sofar == *\ $file\ * ]] && continue + [[ ! -f $file || $sofar == *\ $file\ * ]] && continue sofar+=" $file" sofar=" $(eval _muttconffiles \"$sofar\" $file) " done @@ -67,7 +65,6 @@ _muttconffiles() printf '%s\n' $sofar } - # @param $1 (cur) Current word to complete _muttaliases() { @@ -77,13 +74,13 @@ _muttaliases() muttrc=$(_muttrc) [[ -z $muttrc ]] && return - conffiles=( $(eval _muttconffiles $muttrc $muttrc) ) - aliases=( $(command sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \ - $(eval echo "${conffiles[@]}")) ) - COMPREPLY+=( $(compgen -W "${aliases[*]}" -- "$cur") ) + conffiles=($(eval _muttconffiles $muttrc $muttrc)) + # shellcheck disable=SC2046 + aliases=("$(command sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \ + $(eval echo "${conffiles[@]}"))") + COMPREPLY+=($(compgen -W "${aliases[*]}" -- "$cur")) } - # @param $1 (cur) Current word to complete _muttquery() { @@ -91,18 +88,17 @@ _muttquery() local -a queryresults querycmd="$($muttcmd -Q query_command 2>/dev/null | command sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|'$cur'|')" - if [[ -z "$cur" || -z "$querycmd" ]]; then + if [[ -z $cur || -z $querycmd ]]; then queryresults=() else __expand_tilde_by_ref querycmd - queryresults=( $($querycmd | \ - command sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p') ) + queryresults=($($querycmd | + command sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p')) fi - COMPREPLY+=( $(compgen -W "${queryresults[*]}" -- "$cur") ) + COMPREPLY+=($(compgen -W "${queryresults[*]}" -- "$cur")) } - # @param $1 (cur) Current word to complete _muttfiledir() { @@ -116,50 +112,49 @@ _muttfiledir() # Match any file in $folder beginning with $cur # (minus the leading '=' sign). compopt -o filenames - COMPREPLY=( $(compgen -f -- "$folder/${cur:1}") ) - COMPREPLY=( ${COMPREPLY[@]#$folder/} ) + COMPREPLY=($(compgen -f -- "$folder/${cur:1}")) + COMPREPLY=(${COMPREPLY[@]#$folder/}) return elif [[ $cur == !* ]]; then - spoolfile="$($muttcmd -F "$muttrc" -Q spoolfile 2>/dev/null | \ + spoolfile="$($muttcmd -F "$muttrc" -Q spoolfile 2>/dev/null | command sed -e 's|^spoolfile=\"\(.*\)\"$|\1|')" - [[ ! -z $spoolfile ]] && eval cur="${cur/^!/$spoolfile}" + [[ -n $spoolfile ]] && eval cur="${cur/^!/$spoolfile}" fi _filedir } - _mutt() { local cur prev words cword _init_completion -n =+! || return case $cur in - -*) - COMPREPLY=( $(compgen -W '-A -a -b -c -e -f -F -H -i -m -n -p -Q -R -s - -v -x -y -z -Z -h' -- "$cur") ) - return - ;; - *) - case $prev in - -*[afFHi]) - _muttfiledir "$cur" - return - ;; - -*A) - _muttaliases "$cur" - return - ;; - -*[emQshpRvyzZ]) + -*) + COMPREPLY=($(compgen -W '-A -a -b -c -e -f -F -H -i -m -n -p -Q -R -s + -v -x -y -z -Z -h' -- "$cur")) return ;; *) - _muttaddr "$cur" - return + case $prev in + -*[afFHi]) + _muttfiledir "$cur" + return + ;; + -*A) + _muttaliases "$cur" + return + ;; + -*[emQshpRvyzZ]) + return + ;; + *) + _muttaddr "$cur" + return + ;; + esac ;; - esac - ;; esac } && -complete -F _mutt -o default mutt muttng + complete -F _mutt -o default mutt muttng # ex: filetype=sh diff --git a/completions/mypy b/completions/mypy index 82da1f08..534d5755 100644 --- a/completions/mypy +++ b/completions/mypy @@ -5,12 +5,12 @@ _mypy() local cur prev words cword split _init_completion -s || return - [[ $cword -gt 2 && ${words[cword-2]} == --shadow-file ]] && \ - prev=--shadow-file # hack; takes two args + [[ $cword -gt 2 && ${words[cword - 2]} == --shadow-file ]] && + prev=--shadow-file # hack; takes two args case $prev in - --help|--version|--python-version|--platform|--always-true|\ - --always-false|--find-occurrences|--package|--command|-!(-*)[hVpc]) + --help | --version | --python-version | --platform | --always-true | \ + --always-false | --find-occurrences | --package | --command | -!(-*)[hVpc]) return ;; --config-file) @@ -18,18 +18,18 @@ _mypy() return ;; --follow-imports) - COMPREPLY=( $(compgen -W 'normal silent skip error' -- "$cur") ) + COMPREPLY=($(compgen -W 'normal silent skip error' -- "$cur")) return ;; --python-executable) - COMPREPLY=( $(compgen -c -- "${cur:-py}") ) + COMPREPLY=($(compgen -c -- "${cur:-py}")) return ;; - --*-dir|--*-report) + --*-dir | --*-report) _filedir -d return ;; - --custom-typing|--module|-!(-*)m) + --custom-typing | --module | -!(-*)m) _xfunc python _python_modules return ;; @@ -46,12 +46,12 @@ _mypy() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir '@(py|pyi)' } && -complete -F _mypy mypy + complete -F _mypy mypy # ex: filetype=sh diff --git a/completions/mysql b/completions/mysql index ffb4bcd7..93631332 100644 --- a/completions/mysql +++ b/completions/mysql @@ -2,12 +2,13 @@ _mysql_character_sets() { - local IFS=$' \t\n' reset=$(shopt -p failglob); shopt -u failglob - local -a charsets=( /usr/share/m{ariadb,ysql}/charsets/*.xml ) + local IFS=$' \t\n' reset=$(shopt -p failglob) + shopt -u failglob + local -a charsets=(/usr/share/m{ariadb,ysql}/charsets/*.xml) $reset - charsets=( "${charsets[@]##*/}" ) - charsets=( "${charsets[@]%%?(Index|\*).xml}" utf8 ) - COMPREPLY+=( $(compgen -W '${charsets[@]}' -- "$cur") ) + charsets=("${charsets[@]##*/}") + charsets=("${charsets[@]%%?(Index|\*).xml}" utf8) + COMPREPLY+=($(compgen -W '${charsets[@]}' -- "$cur")) } _mysql() @@ -16,16 +17,16 @@ _mysql() _init_completion -s || return case $prev in - --user|-!(-*)u) - COMPREPLY=( $(compgen -u -- "$cur") ) + --user | -!(-*)u) + COMPREPLY=($(compgen -u -- "$cur")) return ;; - --database|-!(-*)D) - COMPREPLY=( $(compgen -W "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur") ) + --database | -!(-*)D) + COMPREPLY=($(compgen -W "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur")) return ;; - --host|-!(-*)h) + --host | -!(-*)h) _known_hosts_real -- "$cur" return ;; @@ -34,23 +35,23 @@ _mysql() return ;; - --character-sets-dir|--ssl-capath) + --character-sets-dir | --ssl-capath) _filedir -d return ;; - --socket|-!(-*)S) + --socket | -!(-*)S) _filedir sock return ;; --protocol) - COMPREPLY=( $(compgen -W 'tcp socket pipe memory' -- "$cur") ) + COMPREPLY=($(compgen -W 'tcp socket pipe memory' -- "$cur")) return ;; - --defaults-file|--defaults-extra-file|--tee) + --defaults-file | --defaults-extra-file | --tee) _filedir return ;; - --ssl-ca|--ssl-cert) + --ssl-ca | --ssl-cert) _filedir '@(pem|cer|c?(e)rt)' return ;; @@ -58,13 +59,13 @@ _mysql() _filedir '@(pem|key)' return ;; - --port|--set-variable|--ssl-cipher|--connect_timeout|\ - --max_allowed_packet|--prompt|--net_buffer_length|--select_limit|\ - --max_join_size|--server-arg|--debug|--delimiter|--execute|--pager|\ - -!(-*)[Pe]) + --port | --set-variable | --ssl-cipher | --connect_timeout | \ + --max_allowed_packet | --prompt | --net_buffer_length | --select_limit | \ + --max_join_size | --server-arg | --debug | --delimiter | --execute | --pager | \ + -!(-*)[Pe]) return ;; - --help|--version|-!(-*)[?IV]) + --help | --version | -!(-*)[?IV]) return ;; esac @@ -76,23 +77,23 @@ _mysql() local help=$(_parse_help "$1") help+=" --skip-comments --skip-ssl" - COMPREPLY=( $(compgen -W "$help" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W "$help" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return ;; # only complete long options -) compopt -o nospace - COMPREPLY=( -- ) + COMPREPLY=(--) return ;; esac - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" \ - -- "$cur") ) + -- "$cur")) } && -complete -F _mysql mysql + complete -F _mysql mysql # ex: filetype=sh diff --git a/completions/mysqladmin b/completions/mysqladmin index 1e34a34d..53295340 100644 --- a/completions/mysqladmin +++ b/completions/mysqladmin @@ -6,15 +6,15 @@ _mysqladmin() _init_completion -s || return case $prev in - --user|-!(-*)u) - COMPREPLY=( $(compgen -u -- "$cur") ) + --user | -!(-*)u) + COMPREPLY=($(compgen -u -- "$cur")) return ;; - --host|-!(-*)h) + --host | -!(-*)h) _known_hosts_real -- "$cur" return ;; - --character-sets-dir|--ssl-capath) + --character-sets-dir | --ssl-capath) _filedir -d return ;; @@ -22,15 +22,15 @@ _mysqladmin() _xfunc mysql _mysql_character_sets return ;; - --socket|-!(-*)S) + --socket | -!(-*)S) _filedir sock return ;; - --defaults-file|--defaults-extra-file) + --defaults-file | --defaults-extra-file) _filedir return ;; - --ssl-ca|--ssl-cert) + --ssl-ca | --ssl-cert) _filedir '@(pem|cer|c?(e)rt)' return ;; @@ -38,26 +38,26 @@ _mysqladmin() _filedir '@(pem|key)' return ;; - --count|--port|--set-variable|--sleep|--ssl-cipher|--wait|\ - --connect_timeout|--shutdown_timeout|-!(-*)[cPOiw]) + --count | --port | --set-variable | --sleep | --ssl-cipher | --wait | \ + --connect_timeout | --shutdown_timeout | -!(-*)[cPOiw]) return ;; - --help|--version|-!(-*)[?V]) + --help | --version | -!(-*)[?V]) return ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) - COMPREPLY+=( $(compgen -W 'create debug drop extended-status flush-hosts + COMPREPLY+=($(compgen -W 'create debug drop extended-status flush-hosts flush-logs flush-status flush-tables flush-threads flush-privileges kill password old-password ping processlist reload refresh shutdown - status start-slave stop-slave variables version' -- "$cur") ) + status start-slave stop-slave variables version' -- "$cur")) - [[ $COMPREPLY == *= ]] && compopt -o nospace + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _mysqladmin mysqladmin + complete -F _mysqladmin mysqladmin # ex: filetype=sh diff --git a/completions/nc b/completions/nc index 0ba61808..6fb09943 100644 --- a/completions/nc +++ b/completions/nc @@ -10,7 +10,7 @@ _nc() return ;; -*s) - if [[ "${words[*]}" == *-6* ]]; then + if [[ ${words[*]} == *-6* ]]; then _ip_addresses -6 __ltrim_colon_completions "$cur" else @@ -19,13 +19,13 @@ _nc() return ;; -*T) - COMPREPLY=( $(compgen -W 'critical inetcontrol lowcost lowdelay + COMPREPLY=($(compgen -W 'critical inetcontrol lowcost lowdelay netcontrol throughput reliability ef af{11..43} cs{0..7}' \ - -- "$cur") ) + -- "$cur")) return ;; -*X) - COMPREPLY=( $(compgen -W '4 5 connect' -- "$cur") ) + COMPREPLY=($(compgen -W '4 5 connect' -- "$cur")) return ;; -*x) @@ -34,17 +34,18 @@ _nc() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) return fi # Complete 1st non-option arg only - local args; _count_args "" "-*[IiMmOPpqsTVWwXx]" - [[ $args -eq 1 ]] || return + local args + _count_args "" "-*[IiMmOPpqsTVWwXx]" + ((args == 1)) || return _known_hosts_real -- "$cur" } && -complete -F _nc nc + complete -F _nc nc # ex: filetype=sh diff --git a/completions/ncftp b/completions/ncftp index 35146f3c..c3f2cf15 100644 --- a/completions/ncftp +++ b/completions/ncftp @@ -6,22 +6,22 @@ _ncftp() _init_completion || return case $prev in - -u|-p|-P|-j|-F) + -u | -p | -P | -j | -F) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) return fi if [[ $cword -eq 1 && -f ~/.ncftp/bookmarks ]]; then - COMPREPLY=( $(compgen -W '$(command sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \ - ~/.ncftp/bookmarks)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(command sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \ + ~/.ncftp/bookmarks)' -- "$cur")) fi } && -complete -F _ncftp -o default ncftp + complete -F _ncftp -o default ncftp # ex: filetype=sh diff --git a/completions/nethogs b/completions/nethogs index 85fc1cb4..5cd3650e 100644 --- a/completions/nethogs +++ b/completions/nethogs @@ -8,19 +8,19 @@ _nethogs() case "$prev" in -d) # expect integer value - COMPREPLY+=( $(compgen -W '{0..9}') ) + COMPREPLY+=($(compgen -W '{0..9}')) compopt -o nospace return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h)' -- "$cur")) return fi _available_interfaces -a } && -complete -F _nethogs nethogs + complete -F _nethogs nethogs # ex: filetype=sh diff --git a/completions/newlist b/completions/newlist index 793928c3..f1f6cf85 100644 --- a/completions/newlist +++ b/completions/newlist @@ -6,20 +6,20 @@ _newlist() _init_completion -s || return case $prev in - -l|--language|-u|--urlhost|-e|--emailhost|--help) + -l | --language | -u | --urlhost | -e | --emailhost | --help) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _xfunc list_lists _mailman_lists fi } && -complete -F _newlist newlist + complete -F _newlist newlist # ex: filetype=sh diff --git a/completions/newusers b/completions/newusers index b7792b54..890a5fcc 100644 --- a/completions/newusers +++ b/completions/newusers @@ -6,25 +6,25 @@ _newusers() _init_completion -s || return case $prev in - -c|--crypt) - COMPREPLY=( $(compgen -W 'DES MD5 NONE SHA256 SHA512' -- "$cur") ) + -c | --crypt) + COMPREPLY=($(compgen -W 'DES MD5 NONE SHA256 SHA512' -- "$cur")) return ;; - -s|--sha-rounds) + -s | --sha-rounds) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _newusers newusers + complete -F _newusers newusers # ex: filetype=sh diff --git a/completions/ngrep b/completions/ngrep index 65f4dc6d..7d16c8d6 100644 --- a/completions/ngrep +++ b/completions/ngrep @@ -6,20 +6,20 @@ _ngrep() _init_completion || return case $prev in - -h|-V|-n|-A|-s|-S|-c|-P) + -h | -V | -n | -A | -s | -S | -c | -P) return ;; - -I|-O) + -I | -O) _filedir 'pcap?(ng)' return ;; -d) _available_interfaces -a - COMPREPLY+=( $(compgen -W 'any' -- "$cur") ) + COMPREPLY+=($(compgen -W 'any' -- "$cur")) return ;; -W) - COMPREPLY=( $(compgen -W 'normal byline single none' -- "$cur") ) + COMPREPLY=($(compgen -W 'normal byline single none' -- "$cur")) return ;; -F) @@ -28,11 +28,11 @@ _ngrep() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) return fi } && -complete -F _ngrep ngrep + complete -F _ngrep ngrep # ex: filetype=sh diff --git a/completions/nmap b/completions/nmap index b4e76baf..482148e3 100644 --- a/completions/nmap +++ b/completions/nmap @@ -2,15 +2,15 @@ _nmap() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s || return case $prev in - -iL|-oN|-oX|-oS|-oG|---excludefile|--resume|--stylesheet) + -iL | -oN | -oX | -oS | -oG | ---excludefile | --resume | --stylesheet) _filedir return ;; - -oA|--datadir) + -oA | --datadir) _filedir -d return ;; @@ -18,33 +18,39 @@ _nmap() _available_interfaces -a return ;; - -b|--dns-servers) + -b | --dns-servers) _known_hosts_real -- "$cur" return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-iL -iR --exclude --excludefile -sL -sP -PN - -PS -PA -PU -PY -PE -PP -PM -PO -n -R --dns-servers --system-dns - --traceroute -sS -sT -sA -sW -sM -sU -sN -sF -sX --scanflags -sI - -sY -sZ -sO -b -p -F -r --top-ports --port-ratio -sV - --version-intensity --version-light --version-all --version-trace - -sC --script= --script-args= --script-trace --script-updatedb -O - --osscan-limit --osscan-guess -T0 -T1 -T2 -T3 -T4 -T5 - --min-hostgroup --max-hostgroup --min-parallelism --max-parallelism - --min-rtt-timeout --max-rtt-timeout --initial-rtt-timeout - --max-retries --host-timeout --scan-delay --max-scan-delay - --min-rate --max-rate -f --mtu -D -S -e --source-port --data-length - --ip-options --ttl --spoof-mac --badsum --adler32 -oN -oX -oS -oG - -oA -v -d --reason --open --packet-trace --iflist --log-errors - --append-output --resume --stylesheet --webxml --no-stylesheet -6 - -A --datadir --send-eth --send-ip --privilege--unprivileged -V - -h' -- "$cur") ) + $split && return + + if [[ $cur == -* ]]; then + # strip everything following a :, inclusive + # strip everything following a =, exclusive + # expand -X; -Y to -X -Y + # expand -X/-Y/-Z to -X -Y -Z + # expand -X/Y/Z to -X -Y -Z + # expand --foo/bar to --foo --bar + # strip everything following a non-option name or = char + # TODO: should expand -T<0-5> to -T0 ... -T5 + COMPREPLY=($(compgen -W "$( + "$1" --help 2>&1 | command sed \ + -e "s/:.*$//" \ + -e "s/=.*$/=/" \ + -e "s/;[[:space:]]*-/ -/g" \ + -e "s/\/-/ -/g" \ + -e "/^[[:space:]]*-[^-]/s/\/\([^-]\)/ -\1/g" \ + -e "/^[[:space:]]*--/s/\/\([^-]\)/ --\1/g" \ + -e "s/[^[:space:]a-zA-Z0-9=-].*$//" + )" \ + -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _known_hosts_real -- "$cur" fi } && -complete -F _nmap nmap + complete -F _nmap nmap # ex: filetype=sh diff --git a/completions/nproc b/completions/nproc index 84092679..50273f07 100644 --- a/completions/nproc +++ b/completions/nproc @@ -6,7 +6,7 @@ _nproc() _init_completion -s || return case $prev in - --help|--version|--ignore) + --help | --version | --ignore) return ;; esac @@ -14,10 +14,10 @@ _nproc() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _nproc nproc + complete -F _nproc nproc # ex: filetype=sh diff --git a/completions/nslookup b/completions/nslookup index 267d0c30..3341b1f6 100644 --- a/completions/nslookup +++ b/completions/nslookup @@ -2,15 +2,15 @@ _bind_queryclass() { - COMPREPLY+=( $(compgen -W 'IN CH HS ANY' -- "$cur") ) + COMPREPLY+=($(compgen -W 'IN CH HS ANY' -- "$cur")) } _bind_querytype() { - # http://en.wikipedia.org/wiki/List_of_DNS_record_types - COMPREPLY+=( $(compgen -W 'A AAAA AFSDB APL CERT CNAME DHCID DLV DNAME + # https://en.wikipedia.org/wiki/List_of_DNS_record_types + COMPREPLY+=($(compgen -W 'A AAAA AFSDB APL CERT CNAME DHCID DLV DNAME DNSKEY DS HIP IPSECKEY KEY KX LOC MX NAPTR NS NSEC NSEC3 NSEC3PARAM PTR - RRSIG RP SIG SOA SPF SRV SSHFP TXT' -- "$cur") ) + RRSIG RP SIG SOA SPF SRV SSHFP TXT' -- "$cur")) } _nslookup() @@ -19,12 +19,12 @@ _nslookup() _init_completion -n = || return case $cur in - -class=*|-cl=*) + -class=* | -cl=*) cur=${cur#*=} _bind_queryclass return ;; - -querytype=*|-type=*|-q=*|-ty=*) + -querytype=* | -type=* | -q=* | -ty=*) cur=${cur#*=} _bind_querytype return @@ -35,21 +35,21 @@ _nslookup() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-all -class= -debug -nodebug -d2 -nod2 + COMPREPLY=($(compgen -W '-all -class= -debug -nodebug -d2 -nod2 -domain= -search -nosearch -port= -querytype= -recurse -norecurse - -retry= -timeout= -vc -novc -fail -nofail' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + -retry= -timeout= -vc -novc -fail -nofail' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi local args _count_args = - if [[ $args -le 2 ]]; then + if ((args <= 2)); then _known_hosts_real -- "$cur" - [[ $args -eq 1 && $cur == @(|-) ]] && COMPREPLY+=( - ) + [[ $args -eq 1 && $cur == @(|-) ]] && COMPREPLY+=(-) fi } && -complete -F _nslookup nslookup + complete -F _nslookup nslookup _host() { @@ -66,21 +66,21 @@ _host() return ;; -m) - COMPREPLY=( $(compgen -W 'trace record usage' -- "$cur") ) + COMPREPLY=($(compgen -W 'trace record usage' -- "$cur")) return ;; - -N|-R|-W) + -N | -R | -W) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi _known_hosts_real -- "$cur" } && -complete -F _host host + complete -F _host host # ex: filetype=sh diff --git a/completions/nsupdate b/completions/nsupdate index ff3b9a47..68df333e 100644 --- a/completions/nsupdate +++ b/completions/nsupdate @@ -20,21 +20,21 @@ _nsupdate() ;; -*y) if [[ $cur == h* ]]; then - COMPREPLY=( $(compgen -W "hmac-{md5,sha{1,224,256,384,512}}" \ - -S : -- "$cur") ) - [[ $COMPREPLY == *: ]] && compopt -o nospace + COMPREPLY=($(compgen -W "hmac-{md5,sha{1,224,256,384,512}}" \ + -S : -- "$cur")) + [[ ${COMPREPLY-} == *: ]] && compopt -o nospace fi return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi _filedir } && -complete -F _nsupdate nsupdate + complete -F _nsupdate nsupdate # ex: filetype=sh diff --git a/completions/ntpdate b/completions/ntpdate index 5291336c..f6ee8f54 100644 --- a/completions/ntpdate +++ b/completions/ntpdate @@ -11,11 +11,11 @@ _ntpdate() return ;; -*U) - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) return ;; -*p) - COMPREPLY=( $(compgen -W '{1..8}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..8}' -- "$cur")) return ;; @@ -24,12 +24,12 @@ _ntpdate() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) else _known_hosts_real -- "$cur" fi } && -complete -F _ntpdate ntpdate + complete -F _ntpdate ntpdate # ex: filetype=sh diff --git a/completions/oggdec b/completions/oggdec index 9bdf5019..97bde205 100644 --- a/completions/oggdec +++ b/completions/oggdec @@ -6,18 +6,18 @@ _oggdec() _init_completion -s || return case $prev in - --help|--version|-!(-*)[hV]*) + --help | --version | -!(-*)[hV]*) return ;; - --bits|-!(-*)b) - COMPREPLY=( $(compgen -W "8 16" -- "$cur") ) + --bits | -!(-*)b) + COMPREPLY=($(compgen -W "8 16" -- "$cur")) return ;; - --endianness|--sign|-!(-*)[es]) - COMPREPLY=( $(compgen -W "0 1" -- "$cur") ) + --endianness | --sign | -!(-*)[es]) + COMPREPLY=($(compgen -W "0 1" -- "$cur")) return ;; - --output|-!(-*)o) + --output | -!(-*)o) _filedir wav return ;; @@ -25,14 +25,14 @@ _oggdec() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir ogg } && -complete -F _oggdec oggdec + complete -F _oggdec oggdec # ex: filetype=sh diff --git a/completions/op b/completions/op index ddbe4c73..31d64758 100644 --- a/completions/op +++ b/completions/op @@ -3,7 +3,7 @@ _op_commands() { "$@" --help 2>/dev/null | - awk "/^(Available |Sub)commands/{flag=1;next}/^ /&&flag{print \$1}" + awk '/^(Available |Sub)commands/{flag=1;next}/^ /&&flag{print $1}' } _op_command_options() @@ -11,11 +11,11 @@ _op_command_options() case $cur in -*) for i in "${!words[@]}"; do - [[ ${words[i]} == -* || $i -eq 0 ]] && unset words[i] + [[ ${words[i]} == -* || $i -eq 0 ]] && unset "words[i]" done - COMPREPLY=( $(compgen -W \ - '$(_parse_usage "$1" "${words[*]} --help") --help' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W \ + '$(_parse_usage "$1" "${words[*]} --help") --help' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return 0 ;; esac @@ -28,29 +28,32 @@ _op() _init_completion -s || return local command i - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in - --help|--version) return ;; + --help | --version) return ;; -*) ;; - *) command=${words[i]}; break ;; + *) + command=${words[i]} + break + ;; esac done - if [[ -z $command && $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ ! -v command && $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - [[ $command ]] && _op_command_options "$1" && return + [[ -v command ]] && _op_command_options "$1" && return - if [[ -z $command || $command == $prev ]]; then - COMPREPLY=( $(compgen -W '$(_op_commands "$1" $command)' -- "$cur") ) - [[ $COMPREPLY ]] && return + if [[ ! -v command || $command == "$prev" ]]; then + COMPREPLY=($(compgen -W '$(_op_commands "$1" ${command-})' -- "$cur")) + [[ ${COMPREPLY-} ]] && return fi # TODO specific command and subcommand completions } && -complete -F _op op + complete -F _op op # ex: filetype=sh diff --git a/completions/openssl b/completions/openssl index 50300a43..dd770920 100644 --- a/completions/openssl +++ b/completions/openssl @@ -5,9 +5,9 @@ _openssl_sections() local config f # check if a specific configuration file is used - for (( i=2; i < cword; i++ )); do - if [[ "${words[i]}" == -config ]]; then - config=${words[i+1]} + for ((i = 2; i < cword; i++)); do + if [[ ${words[i]} == -config ]]; then + config=${words[i + 1]} break fi done @@ -22,13 +22,17 @@ _openssl_sections() [[ ! -f $config ]] && return - COMPREPLY=( $(compgen -W "$(awk '/\[.*\]/ {print $2}' $config)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(awk '/\[.*\]/ {print $2}' $config)" -- "$cur")) } _openssl_digests() { - "$1" dgst -h 2>&1 | \ + "$1" dgst -h 2>&1 | awk '/^-.*[ \t]to use the .* message digest algorithm/ { print $1 }' + local -a digests=($("$1" help 2>&1 | + command sed -ne '/^Message Digest commands/,/^[[:space:]]*$/p' | + command sed -e 1d)) + printf "%s\n" "${digests[@]/#/-}" } _openssl() @@ -51,29 +55,29 @@ _openssl() rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 rc4-40 sha224 sha256 sha384 sha512 genpkey pkey pkeyparam pkeyutl' - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W "$commands" -- "$cur")) else command=${words[1]} case $prev in - -CA|-CAfile|-CAkey|-CAserial|-cert|-certfile|-config|-content| \ - -dcert|-dkey|-dhparam|-extfile|-in|-inkey|-kfile|-key|-keyout| \ - -out|-oid|-paramfile|-peerkey|-prvrify|-rand|-recip|-revoke| \ - -sess_in|-sess_out|-spkac|-sigfile|-sign|-signkey|-signer| \ - -signature|-ss_cert|-untrusted|-verify) + -CA | -CAfile | -CAkey | -CAserial | -cert | -certfile | -config | -content | \ + -dcert | -dkey | -dhparam | -extfile | -in | -inkey | -kfile | -key | -keyout | \ + -out | -oid | -paramfile | -peerkey | -prvrify | -rand | -recip | -revoke | \ + -sess_in | -sess_out | -spkac | -sigfile | -sign | -signkey | -signer | \ + -signature | -ss_cert | -untrusted | -verify | -writerand) _filedir return ;; - -outdir|-CApath) + -outdir | -CApath) _filedir -d return ;; - -name|-crlexts|-extensions) + -name | -crlexts | -extensions) _openssl_sections return ;; - -inform|-outform|-keyform|-certform|-CAform|-CAkeyform|-dkeyform|\ - -dcertform|-peerform) + -inform | -outform | -keyform | -certform | -CAform | -CAkeyform | -dkeyform | \ + -dcertform | -peerform) formats='DER PEM' case $command in x509) @@ -86,7 +90,7 @@ _openssl() formats+=" ENGINE" ;; esac - COMPREPLY=( $(compgen -W "$formats" -- "$cur") ) + COMPREPLY=($(compgen -W "$formats" -- "$cur")) return ;; -connect) @@ -94,177 +98,41 @@ _openssl() return ;; -starttls) - COMPREPLY=( $(compgen -W 'smtp pop3 imap ftp' -- "$cur") ) + COMPREPLY=($(compgen -W ' + smtp pop3 imap ftp xmpp xmpp-server telnet irc mysql + postgres lmtp nntp sieve ldap + ' -- "$cur")) return ;; -cipher) - COMPREPLY=( $(IFS=: compgen -W "$($1 ciphers)" -- "$cur") ) + COMPREPLY=($(IFS=: compgen -W "$($1 ciphers)" -- "$cur")) return ;; -kdf) - COMPREPLY=( $(compgen -W 'TLS1-PRF HKDF' -- "$cur") ) + COMPREPLY=($(compgen -W 'TLS1-PRF HKDF' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # possible options for the command + options=$(_parse_help "$1" "$command -help" 2>/dev/null) case $command in - asn1parse) - options='-inform -in -out -noout -offset -length -i -oid - -strparse' - ;; - ca) - options='-verbose -config -name -gencrl -revoke -crl_reason - -crl_hold -crl_compromise -crl_CA_compromise -crldays - -crlhours -crlexts -startdate -enddate -days -md - -policy -keyfile -key -passin -cert -selfsig -in -out - -notext -outdir -infiles -spkac -ss_cert -preserveDN - -noemailDN -batch -msie_hack -extensions -extfile - -engine -subj -utf8 -multivalue-rdn' - ;; - ciphers) - options='-v -ssl2 -ssl3 -tls1' - ;; - crl) - options='-inform -outform -text -in -out -noout -hash - -issuer -lastupdate -nextupdate -CAfile -CApath' - ;; - crl2pkcs7) - options='-inform -outform -in -out -print_certs' - ;; - dgst) - options="-c -d -hex -binary -out -sign -verify -prverify - -signature $(_openssl_digests $1)" - ;; - dsa) - options='-inform -outform -in -passin -out -passout -des - -des3 -idea -text -noout -modulus -pubin -pubout' - ;; - dsaparam) - options='-inform -outform -in -out -noout -text -C -rand - -genkey' - ;; - enc) - options='-ciphername -in -out -pass -e -d -a -A -k -kfile - -S -K -iv -p -P -bufsize -debug' - ;; - dhparam) - options='-inform -outform -in -out -dsaparam -noout -text - -C -2 -5 -rand' - ;; - 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' - ;; - pkcs7) - 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' - ;; - req) - options="-inform -outform -in -passin -out -passout -text - -noout -verify -modulus -new -rand -newkey -newkey - -nodes -key -keyform -keyout $(_openssl_digests $1) - -config -x509 -days -asn1-kludge -newhdr -extensions - -reqexts section" - ;; - rsa) - options='-inform -outform -in -passin -out -passout - -sgckey -des -des3 -idea -text -noout -modulus -check - -pubin -pubout -engine' - ;; - rsautl) - options='-in -out -inkey -pubin -certin -sign -verify - -encrypt -decrypt -pkcs -ssl -raw -hexdump -asn1parse' - ;; - s_client) - options='-connect -verify -cert -certform -key -keyform - -pass -CApath -CAfile -reconnect -pause -showcerts - -debug -msg -nbio_test -state -nbio -crlf -ign_eof - -quiet -ssl2 -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 - -bugs -cipher -starttls -engine -tlsextdebug - -no_ticket -sess_out -sess_in -rand' - ;; - s_server) - options='-accept -context -verify -Verify -crl_check - -crl_check_all -cert -certform -key -keyform -pass - -dcert -dcertform -dkey -dkeyform -dpass -dhparam - -nbio -nbio_test -crlf -debug -msg -state -CApath - -CAfile -nocert -cipher -quiet -no_tmp_rsa -ssl2 - -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 -no_dhe - -bugs -hack -www -WWW -HTTP -engine -tlsextdebug - -no_ticket -id_prefix -rand' - ;; - s_time) - options='-connect -www -cert -key -CApath -CAfile -reuse - -new -verify -nbio -time -ssl2 -ssl3 -bugs -cipher' - ;; - sess_id) - options='-inform -outform -in -out -text -noout -context ID' - ;; - smime) - options='-encrypt -decrypt -sign -verify -pk7out -des -des3 - -rc2-40 -rc2-64 -rc2-128 -aes128 -aes192 -aes256 -in - -certfile -signer -recip -inform -passin -inkey -out - -outform -content -to -from -subject -text -rand' - ;; - speed) - options='-engine' - ;; - verify) - options='-CApath -CAfile -purpose -untrusted -help - -issuer_checks -verbose -certificates' - ;; - x509) - options="-inform -outform -keyform -CAform -CAkeyform -in - -out -serial -hash -subject_hash -issuer_hash -subject - -issuer -nameopt -email -startdate -enddate -purpose - -dates -modulus -fingerprint -alias -noout -trustout - -clrtrust -clrreject -addtrust -addreject -setalias - -days -set_serial -signkey -x509toreq -req -CA -CAkey - -CAcreateserial -CAserial -text -C -clrext - -extfile -extensions -engine $(_openssl_digests $1)" - ;; - md*|sha*|ripemd160) - options='-c -d' - ;; + dgst | req | x509) options+=" $(_openssl_digests $1)" ;; esac - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) else - if [[ "$command" == speed ]]; then - COMPREPLY=( $(compgen -W 'md2 mdc2 md5 hmac sha1 rmd160 + if [[ $command == speed ]]; then + COMPREPLY=($(compgen -W 'md2 mdc2 md5 hmac sha1 rmd160 idea-cbc rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4 rsa512 rsa1024 rsa2048 rsa4096 dsa512 dsa1024 dsa2048 idea - rc2 des rsa blowfish' -- "$cur") ) + rc2 des rsa blowfish' -- "$cur")) else _filedir fi fi fi } && -complete -F _openssl -o default openssl + complete -F _openssl -o default openssl # ex: filetype=sh diff --git a/completions/opera b/completions/opera index dc0859ea..f2bc8c30 100644 --- a/completions/opera +++ b/completions/opera @@ -6,8 +6,8 @@ _opera() _init_completion || return case "$prev" in - ?(-)-widget|?(-)-urllist|?(-)-uiparserlog|?(-)-uiwidgetsparserlog|\ - ?(-)-profilinglog) + ?(-)-widget | ?(-)-urllist | ?(-)-uiparserlog | ?(-)-uiwidgetsparserlog | \ + ?(-)-profilinglog) _filedir return ;; @@ -16,32 +16,32 @@ _opera() return ;; ?(-)-remote) - COMPREPLY=( $(compgen -W 'openURL\\( openFile\\( openM2\\( + COMPREPLY=($(compgen -W 'openURL\\( openFile\\( openM2\\( openComposer\\( addBookmark\\( raise\\(\\) lower\\(\\)' \ - -- "$cur") ) - [[ $COMPREPLY == *\( ]] && compopt -o nospace + -- "$cur")) + [[ ${COMPREPLY-} == *\( ]] && compopt -o nospace return ;; ?(-)-windowname) - COMPREPLY=( $(compgen -W 'first last opera{1..9}' -- "$cur") ) + COMPREPLY=($(compgen -W 'first last opera{1..9}' -- "$cur")) return ;; - ?(-)-geometry|?(-)-window|?(-)-display|?(-)-urllistloadtimeout|\ - ?(-)-delaycustomizations|?(-)-dialogtest|?(-)-inidialogtest|\ - ?(-)-gputest) + ?(-)-geometry | ?(-)-window | ?(-)-display | ?(-)-urllistloadtimeout | \ + ?(-)-delaycustomizations | ?(-)-dialogtest | ?(-)-inidialogtest | \ + ?(-)-gputest) # argument required but no completions available return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir '@(?([xX]|[sS])[hH][tT][mM]?([lL]))' } && -complete -F _opera opera + complete -F _opera opera # ex: filetype=sh diff --git a/completions/optipng b/completions/optipng index 22889bf4..0f6b40e1 100644 --- a/completions/optipng +++ b/completions/optipng @@ -6,14 +6,14 @@ _optipng() _init_completion || return case $prev in - -'?'|-h|--help|-f) + -'?' | -h | --help | -f) return ;; -o) - COMPREPLY=( $(compgen -W '{0..7}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..7}' -- "$cur")) return ;; - -out|-log) + -out | -log) _filedir return ;; @@ -22,31 +22,31 @@ _optipng() return ;; -i) - COMPREPLY=( $(compgen -W '0 1' -- "$cur") ) + COMPREPLY=($(compgen -W '0 1' -- "$cur")) return ;; - -zc|-zm) - COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) + -zc | -zm) + COMPREPLY=($(compgen -W '{1..9}' -- "$cur")) return ;; -zw) - COMPREPLY=( $(compgen -W '256 512 1k 2k 4k 8k 16k 32k' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '256 512 1k 2k 4k 8k 16k 32k' \ + -- "$cur")) return ;; -strip) - COMPREPLY=( $(compgen -W 'all' -- "$cur") ) + COMPREPLY=($(compgen -W 'all' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir '@(png|bmp|gif|pnm|tif?(f))' } && -complete -F _optipng optipng + complete -F _optipng optipng # ex: filetype=sh diff --git a/completions/p4 b/completions/p4 index e383c8cf..ed5f20c2 100644 --- a/completions/p4 +++ b/completions/p4 @@ -14,38 +14,38 @@ _p4() uresource uxbinary xbinary xltext xtempobj xtext \ text binary resource" - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W "$p4commands" -- "$cur") ) - elif [[ $cword -eq 2 ]]; then + if ((cword == 1)); then + COMPREPLY=($(compgen -W "$p4commands" -- "$cur")) + elif ((cword == 2)); then case $prev in help) - COMPREPLY=( $(compgen -W "simple commands environment + COMPREPLY=($(compgen -W "simple commands environment filetypes jobview revisions usage views $p4commands" \ - -- "$cur") ) + -- "$cur")) ;; admin) - COMPREPLY=( $(compgen -W "checkpoint stop" -- "$cur") ) - ;; - *) + COMPREPLY=($(compgen -W "checkpoint stop" -- "$cur")) ;; + *) ;; + esac - elif [[ $cword -gt 2 ]]; then + elif ((cword > 2)); then case $prev in -t) - case ${words[$cword-2]} in - add|edit|reopen) - COMPREPLY=( $(compgen -W "$p4filetypes" -- "$cur") ) - ;; - *) + case ${words[cword - 2]} in + add | edit | reopen) + COMPREPLY=($(compgen -W "$p4filetypes" -- "$cur")) ;; + *) ;; + esac ;; - *) - ;; + *) ;; + esac fi } && -complete -F _p4 -o default p4 g4 + complete -F _p4 -o default p4 g4 # ex: filetype=sh diff --git a/completions/pack200 b/completions/pack200 index f35840b0..1a6ded7a 100644 --- a/completions/pack200 +++ b/completions/pack200 @@ -6,37 +6,37 @@ _pack200() _init_completion -s || return case $prev in - -S|--segment-limit|-P|--pass-file|-C|--class-attribute|\ - -F|--field-attribute|-M|--method-attribute|-D|--code-attribute|\ - '-?'|-h|--help|-V|--version|-J) + -S | --segment-limit | -P | --pass-file | -C | --class-attribute | \ + -F | --field-attribute | -M | --method-attribute | -D | --code-attribute | \ + '-?' | -h | --help | -V | --version | -J) return ;; - -E|--effort) - COMPREPLY=( $(compgen -W '{0..9}' -- "$cur") ) + -E | --effort) + COMPREPLY=($(compgen -W '{0..9}' -- "$cur")) return ;; - -H|--deflate-hint) - COMPREPLY=( $(compgen -W 'true false keep' -- "$cur") ) + -H | --deflate-hint) + COMPREPLY=($(compgen -W 'true false keep' -- "$cur")) return ;; - -m|--modification-time) - COMPREPLY=( $(compgen -W 'latest keep' -- "$cur") ) + -m | --modification-time) + COMPREPLY=($(compgen -W 'latest keep' -- "$cur")) return ;; - -U|--unknown-attribute) - COMPREPLY=( $(compgen -W 'error strip pass' -- "$cur") ) + -U | --unknown-attribute) + COMPREPLY=($(compgen -W 'error strip pass' -- "$cur")) return ;; - -f|--config-file) + -f | --config-file) _filedir properties return ;; - -l|--log-file) - COMPREPLY=( $(compgen -W '-' -- "$cur") ) + -l | --log-file) + COMPREPLY=($(compgen -W '-' -- "$cur")) _filedir log return ;; - -r|--repack) + -r | --repack) _filedir jar return ;; @@ -46,29 +46,29 @@ _pack200() # Check if a pack or a jar was already given. local i pack=false jar=false - for (( i=0; i < ${#words[@]}-1; i++ )) ; do + for ((i = 1; i < ${#words[@]} - 1; i++)); do case ${words[i]} in - *.pack|*.pack.gz) pack=true ;; + *.pack | *.pack.gz) pack=true ;; *.jar) jar=true ;; esac done - if ! $pack ; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--no-gzip --gzip --strip-debug + if ! $pack; then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--no-gzip --gzip --strip-debug --no-keep-file-order --segment-limit= --effort= --deflate-hint= --modification-time= --pass-file= --unknown-attribute= --class-attribute= --field-attribute= --method-attribute= --code-attribute= --config-file= --verbose --quiet --log-file= - --help --version -J --repack' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + --help --version -J --repack' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir 'pack?(.gz)' fi - elif ! $jar ; then + elif ! $jar; then _filedir jar fi } && -complete -F _pack200 pack200 + complete -F _pack200 pack200 # ex: filetype=sh diff --git a/completions/passwd b/completions/passwd index 5a1e5629..652a41e5 100644 --- a/completions/passwd +++ b/completions/passwd @@ -6,19 +6,19 @@ _passwd() _init_completion || return case $prev in - --minimum|--maximum|--warning|--inactive|--help|--usage|-!(-*)[nxwi?]) + --minimum | --maximum | --warning | --inactive | --help | --usage | -!(-*)[nxwi?]) return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) return fi _allowed_users } && -complete -F _passwd passwd + complete -F _passwd passwd # ex: filetype=sh diff --git a/completions/patch b/completions/patch index df85211d..e883d9ca 100644 --- a/completions/patch +++ b/completions/patch @@ -6,42 +6,42 @@ _patch() _init_completion -s || return case $prev in - --strip|--ifdef|--prefix|--basename-prefix|--suffix|--get|\ - -!(-*)[pDBYzg]) + --strip | --ifdef | --prefix | --basename-prefix | --suffix | --get | \ + -!(-*)[pDBYzg]) return ;; - --fuzz|-!(-*)F) - COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) + --fuzz | -!(-*)F) + COMPREPLY=($(compgen -W '{0..3}' -- "$cur")) return ;; - --input|-!(-*)i) + --input | -!(-*)i) _filedir '@(?(d)patch|dif?(f))' return ;; - --output|--reject-file|-!(-*)[or]) - [[ ! $cur || $cur == - ]] && COMPREPLY=( - ) + --output | --reject-file | -!(-*)[or]) + [[ ! $cur || $cur == - ]] && COMPREPLY=(-) _filedir return ;; --quoting-style) - COMPREPLY=( $(compgen -W 'literal shell shell-always c escape' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'literal shell shell-always c escape' \ + -- "$cur")) return ;; - --version-control|-!(-*)V) - COMPREPLY=( $(compgen -W 'simple numbered existing' -- "$cur") ) + --version-control | -!(-*)V) + COMPREPLY=($(compgen -W 'simple numbered existing' -- "$cur")) return ;; - --directory|-!(-*)d) + --directory | -!(-*)d) _filedir -d return ;; --reject-format) - COMPREPLY=( $(compgen -W 'context unified' -- "$cur") ) + COMPREPLY=($(compgen -W 'context unified' -- "$cur")) return ;; --read-only) - COMPREPLY=( $(compgen -W 'ignore warn fail' -- "$cur") ) + COMPREPLY=($(compgen -W 'ignore warn fail' -- "$cur")) return ;; esac @@ -49,8 +49,8 @@ _patch() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -65,6 +65,6 @@ _patch() ;; esac } && -complete -F _patch patch + complete -F _patch patch # ex: filetype=sh diff --git a/completions/pdftotext b/completions/pdftotext index 79c837e0..a3501baa 100644 --- a/completions/pdftotext +++ b/completions/pdftotext @@ -6,31 +6,34 @@ _pdftotext() _init_completion || return case $prev in - -h|-help|--help|-'?'|-f|-l|-r|-x|-y|-W|-H|-fixed|-opw|-upw) + -h | -help | --help | -'?' | -f | -l | -r | -x | -y | -W | -H | -fixed | -opw | -upw) return ;; -enc) - COMPREPLY=( $(compgen -W '$("$1" -listenc 2>/dev/null | - command sed -e 1d)' -- "$cur") ) + COMPREPLY=($(compgen -W '$("$1" -listenc 2>/dev/null | + command sed -e 1d)' -- "$cur")) return ;; -eol) - COMPREPLY=( $(compgen -W "unix dos mac" -- "$cur") ) + COMPREPLY=($(compgen -W "unix dos mac" -- "$cur")) return ;; esac if [[ $cur == -* && ${prev,,} != *.pdf ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi case ${prev,,} in - -|*.txt) ;; - *.pdf) COMPREPLY=( $(compgen -W '-' -- "$cur") ) ; _filedir txt ;; + - | *.txt) ;; + *.pdf) + COMPREPLY=($(compgen -W '-' -- "$cur")) + _filedir txt + ;; *) _filedir pdf ;; esac } && -complete -F _pdftotext pdftotext + complete -F _pdftotext pdftotext # ex: filetype=sh diff --git a/completions/perl b/completions/perl index bf117970..9823d730 100644 --- a/completions/perl +++ b/completions/perl @@ -2,9 +2,9 @@ _perl_helper() { - COMPREPLY=( $(compgen -P "$prefix" -W \ + COMPREPLY=($(compgen -P "$prefix" -W \ "$(${2:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl $1 $cur)" \ - -- "$cur") ) + -- "$cur")) [[ $1 == functions ]] || __ltrim_colon_completions "$prefix$cur" } @@ -16,7 +16,7 @@ _perl() local prefix="" temp optPrefix optSuffix # If option not followed by whitespace, reassign prev and cur - if [[ "$cur" == -?* ]]; then + if [[ $cur == -?* ]]; then temp=$cur prev=${temp:0:2} cur=${temp:2} @@ -35,7 +35,7 @@ _perl() -*[Ix]) local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -d $optPrefix $optSuffix -- "$cur") ) + COMPREPLY=($(compgen -d $optPrefix $optSuffix -- "$cur")) return ;; -*[mM]) @@ -50,14 +50,14 @@ _perl() temp="${cur##+(:)}" prefix+="${cur%$temp}" local IFS=$'\n' - COMPREPLY=( $(compgen -P "$prefix" -W \ + COMPREPLY=($(compgen -P "$prefix" -W \ '$($1 -MConfig -e "print join \"\\n\", - keys %Config::Config" 2>/dev/null)' -- "$temp") ) + keys %Config::Config" 2>/dev/null)' -- "$temp")) __ltrim_colon_completions "$prefix$temp" fi return ;; - -*d|-*dt) + -*d | -*dt) if [[ $cur == :* ]]; then temp="${cur#:}" prefix="$prefix${cur%$temp}" @@ -72,25 +72,25 @@ _perl() # valid syntax. However, the argument is neither a filename nor a # directory, but one line of perl program, thus do not suggest # _filedir completion. - elif [[ "$prev" == -e ]] || [[ "$prev" == -E ]]; then + elif [[ $prev == -e ]] || [[ $prev == -E ]]; then return # Likewise, `-I' also accepts a space between option and argument # and it takes a directory as value. - elif [[ "$prev" == -I ]]; then + elif [[ $prev == -I ]]; then local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -d $optPrefix $optSuffix -- "$cur") ) + COMPREPLY=($(compgen -d ${optPrefix-} ${optSuffix-} -- "$cur")) return - elif [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p - -n -a -F -l -0 -I -m -M -P -S -x -i -e' -- "$cur") ) + elif [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p + -n -a -F -l -0 -I -m -M -P -S -x -i -e' -- "$cur")) else _filedir fi } && -complete -F _perl perl + complete -F _perl perl _perldoc() { @@ -100,7 +100,7 @@ _perldoc() local prefix="" temp # completing an option (may or may not be separated by a space) - if [[ "$cur" == -?* ]]; then + if [[ $cur == -?* ]]; then temp=$cur prev=${temp:0:2} cur=${temp:2} @@ -108,7 +108,7 @@ _perldoc() fi local perl="${1%doc}" - [[ $perl == $1 ]] || ! type $perl &>/dev/null && perl= + [[ $perl == "$1" ]] || ! type $perl &>/dev/null && perl= case $prev in -*[hVnoMwL]) @@ -124,23 +124,23 @@ _perldoc() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) else # return available modules (unless it is clearly a file) - if [[ "$cur" != @(*/|[.~])* ]]; then + if [[ $cur != @(*/|[.~])* ]]; then _perl_helper perldocs $perl if [[ $cur == p* ]]; then - COMPREPLY+=( $(compgen -W \ + COMPREPLY+=($(compgen -W \ '$(PERLDOC_PAGER=cat "$1" -u perl | \ command sed -ne "/perl.*Perl overview/,/perlwin32/p" | \ awk "\$NF=2 && \$1 ~ /^perl/ { print \$1 }")' \ - -- "$cur") ) + -- "$cur")) fi fi _filedir 'p@([lm]|od)' fi } && -complete -F _perldoc -o bashdefault perldoc + complete -F _perldoc -o bashdefault perldoc # ex: filetype=sh diff --git a/completions/perlcritic b/completions/perlcritic index d9a4063d..78435495 100644 --- a/completions/perlcritic +++ b/completions/perlcritic @@ -6,46 +6,46 @@ _perlcritic() _init_completion || return case $prev in - --help|--version|--top|--include|--exclude|--single-policy|\ - --colo?(u)r-severity-*|--program-extensions|-[?HVs]) + --help | --version | --top | --include | --exclude | --single-policy | \ + --colo?(u)r-severity-* | --program-extensions | -[?HVs]) return ;; --severity) - COMPREPLY=( $(compgen -W "{1..5} brutal cruel harsh stern gentle" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "{1..5} brutal cruel harsh stern gentle" \ + -- "$cur")) return ;; - --profile|-p) + --profile | -p) _filedir perlcriticrc return ;; --theme) - COMPREPLY=( $(compgen -W '$("$1" --list-themes 2>/dev/null)' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '$("$1" --list-themes 2>/dev/null)' \ + -- "$cur")) return ;; --profile-strictness) - COMPREPLY=( $(compgen -W 'warn fatal quiet' -- "$cur") ) + COMPREPLY=($(compgen -W 'warn fatal quiet' -- "$cur")) return ;; --verbose) - COMPREPLY=( $(compgen -W '{1..11}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..11}' -- "$cur")) return ;; --pager) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi _filedir 'p[lm]' } && -complete -F _perlcritic perlcritic + complete -F _perlcritic perlcritic # ex: filetype=sh diff --git a/completions/perltidy b/completions/perltidy index 91bd5094..4404cf80 100644 --- a/completions/perltidy +++ b/completions/perltidy @@ -6,7 +6,7 @@ _perltidy() _init_completion -n = || return case $prev in - -h|--help) + -h | --help) return ;; -o) @@ -22,20 +22,20 @@ _perltidy() return ;; -ole=*) - COMPREPLY=( $(compgen -W 'dos win mac unix' -- "${cur#*=}") ) + 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#*=}") ) + -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#*=}") ) + COMPREPLY=($(compgen -W '0 1' -- "${cur#*=}")) return ;; -cab=*) - COMPREPLY=( $(compgen -W '0 1 2 3' -- "${cur#*=}") ) + COMPREPLY=($(compgen -W '0 1 2 3' -- "${cur#*=}")) return ;; -*=) @@ -44,12 +44,12 @@ _perltidy() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir 'p[lm]|t' fi } && -complete -F _perltidy perltidy + complete -F _perltidy perltidy # ex: filetype=sh diff --git a/completions/pgrep b/completions/pgrep index 1c507a42..62dbb651 100644 --- a/completions/pgrep +++ b/completions/pgrep @@ -6,33 +6,43 @@ _pgrep() _init_completion || return case $prev in - --delimiter|--pgroup|--session|--terminal|-!(-*)[cdgJMNstTz]) + --delimiter | --pgroup | --session | --terminal | -!(-*)[cdgJMNstTz]) return ;; --signal) _signals return ;; - --pidfile|-!(-*)F) + --pidfile | -!(-*)F) _filedir return ;; - --group|-!(-*)G) + --group | -!(-*)G) _gids return ;; -j) - COMPREPLY=( $(compgen -W 'any none' -- "$cur") ) + COMPREPLY=($(compgen -W 'any none' -- "$cur")) return ;; - --parent|-!(-*)P) + --parent | --ns | -!(-*)P) _pids return ;; - --euid|--uid|-!(-*)[uU]) + --euid | --uid | -!(-*)[uU]) _uids return ;; + --nslist) + local prefix= + [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=( + $(IFS="$IFS," compgen -W '$($1 --help 2>&1 | + command sed -ne "s/^[[:space:]]*Available namespaces://p")' \ + -- "${cur##*,}")) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) + return + ;; esac if [[ $cur == -* ]]; then @@ -40,13 +50,13 @@ _pgrep() [[ $help ]] || help='$("$1" --usage 2>&1 | command sed -e "s/\[-signal\]//" -e "s/\[-SIGNAL\]//" | _parse_usage -)' - COMPREPLY=( $(compgen -W "$help" -- "$cur") ) + COMPREPLY=($(compgen -W "$help" -- "$cur")) [[ $cword -eq 1 && $1 == *pkill ]] && _signals - return fi _pnames -s } && -complete -F _pgrep pgrep pkill + complete -F _pgrep pgrep pkill # ex: filetype=sh diff --git a/completions/pidof b/completions/pidof index 9e5c012b..a11b4323 100644 --- a/completions/pidof +++ b/completions/pidof @@ -6,22 +6,22 @@ _pidof() _init_completion || return case $prev in - --help|-V|--version|-!(-*)[hV]*) + --help | -V | --version | -!(-*)[hV]*) return ;; - --omit-pid|-!(-*)o) + --omit-pid | -!(-*)o) _pids return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _pnames } && -complete -F _pidof pidof + complete -F _pidof pidof # ex: filetype=sh diff --git a/completions/pine b/completions/pine index bf6056e0..319c8d5c 100644 --- a/completions/pine +++ b/completions/pine @@ -6,27 +6,27 @@ _pine() _init_completion || return case $prev in - -help|-d|-f|-c|-I|-n|-url|-copy_pinerc|-copy_abook) + -help | -d | -f | -c | -I | -n | -url | -copy_pinerc | -copy_abook) return ;; - -attach|-attachlist|-attach_and_delete|-p|-P|-pinerc|-passfile|-x) + -attach | -attachlist | -attach_and_delete | -p | -P | -pinerc | -passfile | -x) _filedir return ;; -sort) - COMPREPLY=( $(compgen -W 'arrival subject threaded orderedsubject - date from size score to cc' -- "$cur") ) + COMPREPLY=($(compgen -W 'arrival subject threaded orderedsubject + date from size score to cc' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) else - COMPREPLY=( $(compgen -W '$(awk "{print \$1}" ~/.addressbook \ - 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(awk "{print \$1}" ~/.addressbook \ + 2>/dev/null)' -- "$cur")) fi } && -complete -F _pine pine alpine + complete -F _pine pine alpine # ex: filetype=sh diff --git a/completions/ping b/completions/ping index d611ae87..446f0267 100644 --- a/completions/ping +++ b/completions/ping @@ -19,22 +19,22 @@ _ping() # Path MTU strategy in Linux, mask|time in FreeBSD local opts="do want dont" [[ $OSTYPE == *bsd* ]] && opts="mask time" - COMPREPLY=( $(compgen -W '$opts' -- "$cur") ) + COMPREPLY=($(compgen -W '$opts' -- "$cur")) return ;; -*N) if [[ $cur != *= ]]; then - COMPREPLY=( $(compgen -W 'name ipv6 ipv6-global ipv6-sitelocal + COMPREPLY=($(compgen -W 'name ipv6 ipv6-global ipv6-sitelocal ipv6-linklocal ipv6-all ipv4 ipv4-all subject-ipv6= - subject-ipv4= subject-name= subject-fqdn=' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + subject-ipv4= subject-name= subject-fqdn=' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi return ;; -*Q) # TOS in Linux, "somewhat quiet" (no args) in FreeBSD if [[ $OSTYPE != *bsd* ]]; then - COMPREPLY=( $(compgen -W '{0..7}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..7}' -- "$cur")) return fi ;; @@ -45,8 +45,8 @@ _ping() ;; -*T) # Timestamp option in Linux, TTL in FreeBSD - [[ $OSTYPE == *bsd* ]] || \ - COMPREPLY=( $(compgen -W 'tsonly tsandaddr' -- "$cur") ) + [[ $OSTYPE == *bsd* ]] || + COMPREPLY=($(compgen -W 'tsonly tsandaddr' -- "$cur")) return ;; -*4*) @@ -59,13 +59,13 @@ _ping() if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) return fi [[ $1 == *6 ]] && ipvx=-6 - _known_hosts_real $ipvx -- "$cur" + _known_hosts_real ${ipvx-} -- "$cur" } && -complete -F _ping ping ping6 + complete -F _ping ping ping6 # ex: filetype=sh diff --git a/completions/pkg-config b/completions/pkg-config index 57191370..b9db1673 100644 --- a/completions/pkg-config +++ b/completions/pkg-config @@ -6,24 +6,24 @@ _pkg_config() _init_completion -s || return case $prev in - --define-variable|--atleast-version|--atleast-pkgconfig-version| \ - --exact-version|--max-version) + --define-variable | --atleast-version | --atleast-pkgconfig-version | \ + --exact-version | --max-version) # argument required but no completions available return ;; --variable) - local i - for (( i=1; i < ${#words[@]}; i++ )); do - if [[ ${words[i]} != -* ]]; then - COMPREPLY=( $(compgen -W \ - '$("$1" ${words[i]} --print-variables 2>/dev/null)' \ - -- "$cur") ) + local word + for word in "${words[@]:1}"; do + if [[ $word != -* ]]; then + COMPREPLY=($(compgen -W \ + '$("$1" $word --print-variables 2>/dev/null)' \ + -- "$cur")) break fi done return ;; - -\?|--help|--version|--usage) + -\? | --help | --version | --usage) # all other arguments are noop with these return ;; @@ -31,15 +31,15 @@ _pkg_config() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - COMPREPLY=( $(compgen -W "$($1 --list-all \ - 2>/dev/null | awk '{print $1}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 --list-all \ + 2>/dev/null | awk '{print $1}')" -- "$cur")) _filedir pc fi } && -complete -F _pkg_config pkg-config + complete -F _pkg_config pkg-config # ex: filetype=sh diff --git a/completions/pkg-get b/completions/pkg-get index 2f251338..72bd0a05 100644 --- a/completions/pkg-get +++ b/completions/pkg-get @@ -15,7 +15,7 @@ _pkg_get_get_catalog_file() done conffile="${conffile:-/opt/csw/etc/pkg-get.conf}" - if [[ -z "$url" ]]; then + if [[ -z $url ]]; then url=$(awk -F= ' $1=="url" { print $2 }' $conffile) fi @@ -25,48 +25,48 @@ _pkg_get_get_catalog_file() echo "$catalog_file" } && -_pkg_get() -{ - local cur prev file catalog_file url command - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - - if [[ "${prev}" == "-s" ]]; then - return 1 - fi + _pkg_get() + { + local cur prev file catalog_file url command + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD - 1]}" - local i=${#COMP_WORDS[*]} - while [[ $i -gt 0 ]]; do - if [[ "${COMP_WORDS[--i]}" == -s ]]; then - url="${COMP_WORDS[$((i+1))]}" + if [[ ${prev} == "-s" ]]; then + return 1 fi - if [[ "${COMP_WORDS[$i]}" == @(-[aDdiUu]|available|describe|download|install|list|updatecatalog|upgrade) ]]; then - command="${COMP_WORDS[$i]}" - fi - done - if [[ -n "$command" ]]; then - if [[ "$command" == @(-[Ddi]|describe|download|install) ]]; then - catalog_file=$(_pkg_get_get_catalog_file "$url") - if [[ -f $catalog_file ]]; then - local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' $catalog_file) - COMPREPLY=( $(compgen -W "${packages_list}" -- ${cur}) ) + local i=${#COMP_WORDS[*]} + while ((i > 0)); do + if [[ ${COMP_WORDS[--i]} == -s ]]; then + url="${COMP_WORDS[i + 1]}" + fi + if [[ ${COMP_WORDS[i]} == @(-[aDdiUu]|available|describe|download|install|list|updatecatalog|upgrade) ]]; then + command="${COMP_WORDS[i]}" + fi + done + + if [[ -v command ]]; then + if [[ $command == @(-[Ddi]|describe|download|install) ]]; then + catalog_file=$(_pkg_get_get_catalog_file "$url") + if [[ -f $catalog_file ]]; then + local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' $catalog_file) + COMPREPLY=($(compgen -W "${packages_list}" -- ${cur})) + fi fi + return fi - return - fi - if [[ ${cur} == -* ]]; then - local opts="-c -d -D -f -i -l -s -S -u -U -v" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return - fi + if [[ ${cur} == -* ]]; then + local opts="-c -d -D -f -i -l -s -S -u -U -v" + COMPREPLY=($(compgen -W "${opts}" -- ${cur})) + return + fi - local commands="available describe download install list \ + local commands="available describe download install list \ updatecatalog upgrade" - COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) ) -} && -complete -F _pkg_get pkg-get + COMPREPLY=($(compgen -W "${commands}" -- ${cur})) + } && + complete -F _pkg_get pkg-get # ex: filetype=sh diff --git a/completions/pkg_delete b/completions/pkg_delete index 942647d0..2abb6714 100644 --- a/completions/pkg_delete +++ b/completions/pkg_delete @@ -7,12 +7,12 @@ _pkg_delete() local pkgdir=${PKG_DBDIR:-/var/db/pkg}/ - [[ "$prev" == -o || "$prev" == -p || "$prev" == -W ]] && return + [[ $prev == -o || $prev == -p || $prev == -W ]] && return - COMPREPLY=( $(compgen -d -- "$pkgdir$cur") ) - COMPREPLY=( ${COMPREPLY[@]#$pkgdir} ) + COMPREPLY=($(compgen -d -- "$pkgdir$cur")) + ((${#COMPREPLY[@]} == 0)) || COMPREPLY=(${COMPREPLY[@]#$pkgdir}) } && -complete -F _pkg_delete -o dirnames pkg_delete pkg_info pkg_deinstall + complete -F _pkg_delete -o dirnames pkg_delete pkg_info pkg_deinstall # ex: filetype=sh diff --git a/completions/pkgadd b/completions/pkgadd index 576b4114..3f5b6a11 100644 --- a/completions/pkgadd +++ b/completions/pkgadd @@ -2,7 +2,7 @@ # # Copyright 2006 Yann Rouillard <yann@opencsw.org> -_pkgadd () +_pkgadd() { local cur prev words cword _init_completion -n : || return @@ -12,10 +12,10 @@ _pkgadd () # available in this directory local device=/var/spool/pkg local i=$cword - while [[ $((i--)) -gt 0 ]]; do - case "${words[$i]}" in + while ((i-- > 0)); do + case "${words[i]}" in -d) - device="${words[$((i+1))]}" + device="${words[i + 1]}" break ;; esac @@ -26,35 +26,37 @@ _pkgadd () _filedir pkg _filedir -d ;; - -a|-r|-V) + -a | -r | -V) _filedir ;; - -k|-s|-R) + -k | -s | -R) _filedir -d ;; - -P|-k|-x) - ;; + -P | -x) ;; + *) if [[ ${cur} == -* ]]; then local opts="-a -A -d -k -n -M -P -r -R -s -v -V -x" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=($(compgen -W "${opts}" -- ${cur})) else local pkginst_list if [[ -d $device ]]; then + local -a tmplist for filedir in $(/bin/ls -1 $device); do if [[ -d "$device/$filedir" ]] && [[ -f "$device/$filedir/pkginfo" ]]; then - pkginst_list+=( ${pkginst_list[@]:-} "$filedir" ) + tmplist+=(${tmplist[@]:-} "$filedir") fi done - pkginst_list="${pkginst_list[@]}" + pkginst_list="${tmplist[*]}" else - pkginst_list=$(strings $(dequote $device) | \ - command grep "^PKG=" | sort -u | cut -d= -f2) + pkginst_list="$(strings "$(dequote $device)" | + command grep ^PKG= | sort -u | cut -d= -f2)" + fi + COMPREPLY=($(compgen -W "$pkginst_list" -- ${cur})) fi - COMPREPLY=( $(compgen -W "$pkginst_list" -- ${cur}) ) - fi + ;; esac } && -complete -F _pkgadd pkgadd + complete -F _pkgadd pkgadd # ex: filetype=sh diff --git a/completions/pkgrm b/completions/pkgrm index ef3b2a8d..2449d349 100644 --- a/completions/pkgrm +++ b/completions/pkgrm @@ -2,7 +2,7 @@ # # Copyright 2006 Yann Rouillard <yann@opencsw.org> -_pkgrm () +_pkgrm() { local cur prev words cword _init_completion || return @@ -12,13 +12,13 @@ _pkgrm () # available in this directory local spool=/var/sadm/pkg local i=$cword - while [[ $((i--)) -gt 0 ]]; do - (( i-- )) - case "${words[$i]}" in + while ((i-- > 0)); do + ((i--)) + case "${words[i]}" in -s) - spool="${words[$((i+1))]}" + spool="${words[i + 1]}" break - ;; + ;; esac done @@ -29,8 +29,8 @@ _pkgrm () -s | -R) _filedir -d ;; - -Y) - ;; + -Y) ;; + *) if [[ ${cur} == -* ]]; then local opts="-a -A -n -M -R -s -v -V -Y" @@ -38,9 +38,9 @@ _pkgrm () else COMPREPLY=($(compgen -W "$(/bin/ls -1 $spool)" -- ${cur})) fi - ;; + ;; esac } && -complete -F _pkgrm pkgrm + complete -F _pkgrm pkgrm # ex: filetype=sh diff --git a/completions/pkgtool b/completions/pkgtool index 8bea9cdd..951bae40 100644 --- a/completions/pkgtool +++ b/completions/pkgtool @@ -6,7 +6,7 @@ _pkgtool() _init_completion || return case "$prev" in - --source_dir|--target_dir) + --source_dir | --target_dir) _filedir -d return ;; @@ -15,7 +15,7 @@ _pkgtool() return ;; --source_device) - COMPREPLY=( $(compgen -f -d -- "${cur:-/dev/}") ) + COMPREPLY=($(compgen -f -d -- "${cur:-/dev/}")) return ;; --tagfile) @@ -24,12 +24,12 @@ _pkgtool() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--sets --ignore-tagfiles --tagfile + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--sets --ignore-tagfiles --tagfile --source-mounted --source_dir --target_dir --source_device' \ - -- "$cur") ) + -- "$cur")) fi } && -complete -F _pkgtool pkgtool + complete -F _pkgtool pkgtool # ex: filetype=sh diff --git a/completions/pkgutil b/completions/pkgutil index febc2135..91d87480 100644 --- a/completions/pkgutil +++ b/completions/pkgutil @@ -22,74 +22,74 @@ _pkgutil() declare -a catalog_files=() local i=$cword - while [[ $((i--)) -gt 1 ]]; do - if [[ "${words[$i]}" == -@(t|-temp) ]]; then - local url="${words[$((i+1))]}" + while ((i-- > 1)); do + if [[ ${words[i]} == -@(t|-temp) ]]; then + local url="${words[i + 1]}" local catalog=$(_pkgutil_url2catalog "$url") catalog_files=("$catalog") - elif [[ "${words[$i]}" == --config ]]; then - configuration_files=( "$(dequote ${words[$((i+1))]})" ) - elif [[ "${words[$i]}" == -@([iurdacUS]|-install|-upgrade|-remove|-download|-available|-compare|-catalog|-stream) ]]; then - command="${words[$i]}" + elif [[ ${words[i]} == --config ]]; then + configuration_files=("$(dequote ${words[i + 1]})") + elif [[ ${words[i]} == -@([iurdacUS]|-install|-upgrade|-remove|-download|-available|-compare|-catalog|-stream) ]]; then + command="${words[i]}" fi done - if [[ "$prev" == -@([WPR]|-workdir|-pkgdir|-rootpath) ]]; then + if [[ $prev == -@([WPR]|-workdir|-pkgdir|-rootpath) ]]; then _filedir -d return fi - if [[ "$prev" == -@(o|-output|-config) ]]; then + if [[ $prev == -@(o|-output|-config) ]]; then _filedir return fi - if [[ "$prev" == -@(p|-param) ]]; then + if [[ $prev == -@(p|-param) ]]; then compopt -o nospace - COMPREPLY=( $(compgen -W "mirror: pkgaddopts: pkgrmopts: wgetopts: use_gpg: use_md5: pkgliststyle: maxpkglist: noncsw: stop_on_hook_soft_error: exclude_pattern: gpg_homedir: root_path: deptree_filter_common: show_current: catalog_not_cached: catalog_update:" -- $cur) ) + COMPREPLY=($(compgen -W "mirror: pkgaddopts: pkgrmopts: wgetopts: use_gpg: use_md5: pkgliststyle: maxpkglist: noncsw: stop_on_hook_soft_error: exclude_pattern: gpg_homedir: root_path: deptree_filter_common: show_current: catalog_not_cached: catalog_update:" -- $cur)) return fi - if [[ "$prev" == @(-T|--target) ]]; then + if [[ $prev == @(-T|--target) ]]; then # Work-around bash_completion issue where bash interprets a colon # as a separator, borrowed from maven completion code which borrowed # it from darcs completion code :) local colonprefixes=${cur%"${cur##*:}"} - COMPREPLY=( $(compgen -W "sparc:5.9 sparc:5.10 sparc:5.11 i386:5.9 i386:5.10 i386:5.11" -- $cur) ) + COMPREPLY=($(compgen -W "sparc:5.9 sparc:5.10 sparc:5.11 i386:5.9 i386:5.10 i386:5.11" -- $cur)) local i=${#COMPREPLY[*]} - while [ $((--i)) -ge 0 ]; do - COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"} + while ((i-- > 0)); do + COMPREPLY[i]=${COMPREPLY[i]#"$colonprefixes"} done return fi - if [[ -n "$command" ]] && [[ ! "$cur" == -* ]]; then + if [[ -v command && $cur != -* ]]; then local mirrors mirror_url mirrors=$(awk -F= ' $1 ~ /^ *mirror *$/ { print $2 }' "${configuration_files[@]}") mirrors=${mirrors:-http://mirror.opencsw.org/opencsw/testing} for mirror_url in $mirrors; do local catalog=$(_pkgutil_url2catalog "$mirror_url") - catalog_files=( "${catalog_files[@]}" "$catalog" ) + catalog_files=("${catalog_files[@]}" "$catalog") done - if [[ "$command" == -@([dius]|-download|-install|-upgrade|-stream) ]]; then + if [[ $command == -@([dius]|-download|-install|-upgrade|-stream) ]]; then local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "${catalog_files[@]}") - COMPREPLY=( $(compgen -W "${packages_list}" -- $cur) ) + COMPREPLY=($(compgen -W "${packages_list}" -- $cur)) - elif [[ "$command" == @(-r|--remove) ]]; then - local packages_list=$(pkginfo | awk ' $2 ~ /^CSW/ { printf ("%s|",$2) }') + elif [[ $command == @(-r|--remove) ]]; then + local packages_list=$(pkginfo | awk ' $2 ~ /^CSW/ { printf ("%s|",$2) }') packages_list=${packages_list%|} packages_list=$(nawk " \$3 ~ /^$packages_list\$/ { print \$1 }" "${catalog_files[@]}") - COMPREPLY=( $(compgen -W "${packages_list}" -- $cur) ) + COMPREPLY=($(compgen -W "${packages_list}" -- $cur)) fi return fi local commands="-i --install -u --upgrade -r --remove -d --download -U --catalog -a --available --describe -c --compare -C --compare-diff -A --compare-avail -e --email -t --temp -x --exclude -W --workdir -P --pkgdir -R --rootpath --config -y --yes -f --force -n --nomod -N --nodeps -D --debug --trace -h --help -v --version -V --syscheck -l --list -L --listfile -F --findfile --deptree --extract -s --stream -o --output -T --target --single -p --param --parse --cleanup --catinfo" - COMPREPLY=( $(compgen -W "${commands}" -- $cur) ) + COMPREPLY=($(compgen -W "${commands}" -- $cur)) } && -complete -F _pkgutil pkgutil + complete -F _pkgutil pkgutil # ex: filetype=sh diff --git a/completions/plague-client b/completions/plague-client index d8b2140e..4e982063 100644 --- a/completions/plague-client +++ b/completions/plague-client @@ -5,10 +5,10 @@ _plague_client() local cur prev words cword _init_completion || return - [[ $cword -eq 1 ]] && \ - COMPREPLY=( $(compgen -W 'build detail finish help is_paused kill list - list_builders pause requeue unpause update_builders' -- "$cur") ) + ((cword == 1)) && + COMPREPLY=($(compgen -W 'build detail finish help is_paused kill list + list_builders pause requeue unpause update_builders' -- "$cur")) } && -complete -F _plague_client plague-client + complete -F _plague_client plague-client # ex: filetype=sh diff --git a/completions/pm-hibernate b/completions/pm-hibernate index 1deadd11..ea3b0aa7 100644 --- a/completions/pm-hibernate +++ b/completions/pm-hibernate @@ -5,8 +5,8 @@ _pm_action() local cur prev words cword _init_completion || return - COMPREPLY=( $(compgen -W "--help $(_parse_help "$1")" -- "$cur") ) + COMPREPLY=($(compgen -W "--help $(_parse_help "$1")" -- "$cur")) } && -complete -F _pm_action pm-hibernate pm-suspend pm-suspend-hybrid + complete -F _pm_action pm-hibernate pm-suspend pm-suspend-hybrid # ex: filetype=sh diff --git a/completions/pm-is-supported b/completions/pm-is-supported index 6a112aeb..adc7fde7 100644 --- a/completions/pm-is-supported +++ b/completions/pm-is-supported @@ -5,9 +5,9 @@ _pm_is_supported() local cur prev words cword _init_completion || return - COMPREPLY=( $(compgen -W '--help --suspend --hibernate --suspend-hybrid' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '--help --suspend --hibernate --suspend-hybrid' \ + -- "$cur")) } && -complete -F _pm_is_supported pm-is-supported + complete -F _pm_is_supported pm-is-supported # ex: filetype=sh diff --git a/completions/pm-powersave b/completions/pm-powersave index 06f93de0..affb195d 100644 --- a/completions/pm-powersave +++ b/completions/pm-powersave @@ -5,8 +5,8 @@ _pm_powersave() local cur prev words cword _init_completion || return - COMPREPLY=( $(compgen -W "true false" -- "$cur") ) + COMPREPLY=($(compgen -W "true false" -- "$cur")) } && -complete -F _pm_powersave pm-powersave + complete -F _pm_powersave pm-powersave # ex: filetype=sh diff --git a/completions/pngfix b/completions/pngfix index b4b58e83..64b5481d 100644 --- a/completions/pngfix +++ b/completions/pngfix @@ -6,7 +6,7 @@ _pngfix() _init_completion -s || return case $prev in - --suffix|--prefix) + --suffix | --prefix) return ;; --output) @@ -14,9 +14,9 @@ _pngfix() return ;; --strip) - COMPREPLY=( $(IFS='|' compgen -W '$("$1" --help 2>&1 | + COMPREPLY=($(IFS='|' compgen -W '$("$1" --help 2>&1 | command sed -ne "s/.*--strip=\[\([^]]*\)\].*/\1/p")' \ - -- "$cur") ) + -- "$cur")) return ;; esac @@ -24,13 +24,13 @@ _pngfix() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir png } && -complete -F _pngfix pngfix + complete -F _pngfix pngfix # ex: filetype=sh diff --git a/completions/portinstall b/completions/portinstall index 8a70b136..80337407 100644 --- a/completions/portinstall +++ b/completions/portinstall @@ -13,19 +13,19 @@ _portinstall() # First try INDEX-5 indexfile=$portsdir/INDEX-5 # Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x - [[ "${OSTYPE%.*}" == freebsd5 && -f $indexfile ]] || + [[ ${OSTYPE%.*} == freebsd5 && -f $indexfile ]] || indexfile=$portsdir/INDEX - [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return + [[ $prev == -l || $prev == -L || $prev == -o ]] && return - COMPREPLY=( $(command grep -E "^$cur" 2>/dev/null <$indexfile | \ - cut -d'|' -f1) ) - COMPREPLY2=( $(command grep -E "^[^\|]+\|$portsdir$cur" 2>/dev/null \ - <$indexfile | cut -d'|' -f2) ) - COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} ) - COMPREPLY+=( "${COMPREPLY2[@]}" ) + COMPREPLY=($(command grep -E "^$cur" 2>/dev/null <$indexfile | + cut -d'|' -f1)) + COMPREPLY2=($(command grep -E "^[^\|]+\|$portsdir$cur" 2>/dev/null \ + <$indexfile | cut -d'|' -f2)) + COMPREPLY2=(${COMPREPLY2[@]#$portsdir}) + COMPREPLY+=("${COMPREPLY2[@]}") } && -complete -F _portinstall -o dirnames portinstall + complete -F _portinstall -o dirnames portinstall # ex: filetype=sh diff --git a/completions/portsnap b/completions/portsnap index f865183b..a2f0a936 100644 --- a/completions/portsnap +++ b/completions/portsnap @@ -8,18 +8,18 @@ _portsnap() _init_completion || return case $prev in - -d|-p) + -d | -p) _filedir -d return ;; - -l|-f) + -l | -f) _filedir return ;; esac - COMPREPLY=( $(compgen -W "fetch cron extract update" -- $cur) ) + COMPREPLY=($(compgen -W "fetch cron extract update" -- $cur)) } && -complete -F _portsnap portsnap + complete -F _portsnap portsnap # ex: filetype=sh diff --git a/completions/portupgrade b/completions/portupgrade index 42538077..ffe63056 100644 --- a/completions/portupgrade +++ b/completions/portupgrade @@ -5,15 +5,15 @@ _portupgrade() local cur prev words cword _init_completion || return - [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return + [[ $prev == -l || $prev == -L || $prev == -o ]] && return local pkgdir=${PKG_DBDIR:-/var/db/pkg}/ - COMPREPLY=( $(compgen -d -- "$pkgdir$cur") ) - COMPREPLY=( ${COMPREPLY[@]#$pkgdir} ) - COMPREPLY=( ${COMPREPLY[@]%-*} ) + COMPREPLY=($(compgen -d -- "$pkgdir$cur")) + COMPREPLY=(${COMPREPLY[@]#$pkgdir}) + COMPREPLY=(${COMPREPLY[@]%-*}) } && -complete -F _portupgrade -o dirnames portupgrade + complete -F _portupgrade -o dirnames portupgrade # ex: filetype=sh diff --git a/completions/postcat b/completions/postcat index 22006233..a58b0e57 100644 --- a/completions/postcat +++ b/completions/postcat @@ -13,20 +13,20 @@ _postcat() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi local idx qfile=0 for idx in "${words[@]}"; do - [[ "$idx" == -q ]] && qfile=1 && break + [[ $idx == -q ]] && qfile=1 && break done - if [[ $qfile -eq 1 ]]; then + if ((qfile == 1)); then local len=${#cur} pval - for pval in $(mailq 2>/dev/null | \ + for pval in $(mailq 2>/dev/null | command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//'); do - if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY+=( $pval ) + if [[ $cur == "${pval:0:len}" ]]; then + COMPREPLY+=($pval) fi done return @@ -34,6 +34,6 @@ _postcat() _filedir } && -complete -F _postcat postcat + complete -F _postcat postcat # ex: filetype=sh diff --git a/completions/postconf b/completions/postconf index 45b376be..4cb324c1 100644 --- a/completions/postconf +++ b/completions/postconf @@ -8,7 +8,7 @@ _postconf() local eqext case $prev in - -b|-t) + -b | -t) _filedir return ;; @@ -23,17 +23,17 @@ _postconf() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi local len=${#cur} pval for pval in $(/usr/sbin/postconf 2>/dev/null | cut -d ' ' -f 1); do - if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY+=( "$pval$eqext" ) + if [[ $cur == "${pval:0:len}" ]]; then + COMPREPLY+=("$pval${eqext-}") fi done } && -complete -F _postconf postconf + complete -F _postconf postconf # ex: filetype=sh diff --git a/completions/postfix b/completions/postfix index eda9ad46..f9605502 100644 --- a/completions/postfix +++ b/completions/postfix @@ -11,21 +11,23 @@ _postfix() return ;; -D) - COMPREPLY=( $(compgen -W 'start' -- "$cur") ) + COMPREPLY=($(compgen -W 'start' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - # TODO: doesn't seem to work; the usage message doesn't get output - # if we try to grep it, it's only output on the console? - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($( + compgen -W \ + '$(_bashcomp_try_faketty "$1" --help 2>&1 | _parse_usage -)' \ + -- "$cur" + )) return fi - COMPREPLY=( $(compgen -W 'check start stop abort flush reload status - set-permissions upgrade-configuration' -- "$cur") ) + COMPREPLY=($(compgen -W 'check start stop abort flush reload status + set-permissions upgrade-configuration' -- "$cur")) } && -complete -F _postfix postfix + complete -F _postfix postfix # ex: filetype=sh diff --git a/completions/postmap b/completions/postmap index 66756c1e..35c4ada1 100644 --- a/completions/postmap +++ b/completions/postmap @@ -16,26 +16,26 @@ _postmap() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi - if [[ "$cur" == *:* ]]; then + if [[ $cur == *:* ]]; then compopt -o filenames - COMPREPLY=( $(compgen -f -- "${cur#*:}") ) + COMPREPLY=($(compgen -f -- "${cur#*:}")) else local len=${#cur} pval for pval in $(/usr/sbin/postconf -m 2>/dev/null); do - if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY+=( "$pval:" ) + if [[ $cur == "${pval:0:len}" ]]; then + COMPREPLY+=("$pval:") fi done - if [[ ! $COMPREPLY ]]; then + if [[ ! ${COMPREPLY-} ]]; then compopt -o filenames - COMPREPLY=( $(compgen -f -- "$cur") ) + COMPREPLY=($(compgen -f -- "$cur")) fi fi } && -complete -F _postmap postmap postalias + complete -F _postmap postmap postalias # ex: filetype=sh diff --git a/completions/postsuper b/completions/postsuper index 509d2484..559449aa 100644 --- a/completions/postsuper +++ b/completions/postsuper @@ -14,30 +14,30 @@ _postsuper() ;; -[dr]) len=${#cur} - for pval in ALL $(mailq 2>/dev/null | \ + for pval in ALL $(mailq 2>/dev/null | command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//'); do - if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY+=( $pval ) + if [[ $cur == "${pval:0:len}" ]]; then + COMPREPLY+=($pval) fi done return ;; -h) len=${#cur} - for pval in ALL $(mailq 2>/dev/null | \ + for pval in ALL $(mailq 2>/dev/null | command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* ].*$//; /!$/d'); do - if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY+=( $pval ) + if [[ $cur == "${pval:0:len}" ]]; then + COMPREPLY+=($pval) fi done return ;; -H) len=${#cur} - for pval in ALL $(mailq 2>/dev/null | \ + for pval in ALL $(mailq 2>/dev/null | command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//'); do - if [[ "$cur" == "${pval:0:$len}" ]]; then - COMPREPLY+=( $pval ) + if [[ $cur == "${pval:0:len}" ]]; then + COMPREPLY+=($pval) fi done return @@ -45,12 +45,12 @@ _postsuper() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -W 'hold incoming active deferred' -- "$cur") ) + COMPREPLY=($(compgen -W 'hold incoming active deferred' -- "$cur")) } && -complete -F _postsuper postsuper + complete -F _postsuper postsuper # ex: filetype=sh diff --git a/completions/povray b/completions/povray index c5af018a..56dfd94d 100644 --- a/completions/povray +++ b/completions/povray @@ -16,35 +16,41 @@ _povray() cur="${povcur#[-+]I}" # to confuse _filedir pfx="${povcur%"$cur"}" _filedir pov - COMPREPLY=( ${COMPREPLY[@]/#/$pfx} ) + COMPREPLY=(${COMPREPLY[@]/#/$pfx}) return ;; [-+]O*) # guess what output file type user may want - case $(IFS=$'\n'; command grep '^[-+]F' <<<"${words[*]}") in + case $( + IFS=$'\n' + command grep '^[-+]F' <<<"${words[*]}" + ) in [-+]FN) oext=png ;; [-+]FP) oext=ppm ;; [-+]F[CT]) oext=tga ;; *) oext=$defoext ;; esac # complete filename corresponding to previously specified +I - COMPREPLY=( $(IFS=$'\n'; command grep '^[-+]I' <<<"${words[*]}") ) - COMPREPLY=( ${COMPREPLY[@]#[-+]I} ) - COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} ) + COMPREPLY=($( + IFS=$'\n' + command grep '^[-+]I' <<<"${words[*]}" + )) + COMPREPLY=(${COMPREPLY[@]#[-+]I}) + COMPREPLY=(${COMPREPLY[@]/%.pov/.$oext}) cur="${povcur#[-+]O}" # to confuse _filedir pfx="${povcur%"$cur"}" _filedir $oext - COMPREPLY=( ${COMPREPLY[@]/#/$pfx} ) + COMPREPLY=(${COMPREPLY[@]/#/$pfx}) return ;; - *.ini\[|*.ini\[*[^]]) # sections in .ini files + *.ini\[ | *.ini\[*[^]]) # sections in .ini files cur="${povcur#*\[}" pfx="${povcur%\["$cur"}" # prefix == filename [[ -r $pfx ]] || return - COMPREPLY=( $(command sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \ - -e 't' -e 'd' -- "$pfx") ) + COMPREPLY=($(command sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \ + -e 't' -e 'd' -- "$pfx")) # to prevent [bar] expand to nothing. can be done more easily? - COMPREPLY=( "${COMPREPLY[@]/#/${pfx}[}" ) + COMPREPLY=("${COMPREPLY[@]/#/${pfx}[}") return ;; *) @@ -53,6 +59,6 @@ _povray() ;; esac } && -complete -F _povray povray xpovray spovray + complete -F _povray povray xpovray spovray # ex: filetype=sh diff --git a/completions/prelink b/completions/prelink index 62580a95..1c39611f 100644 --- a/completions/prelink +++ b/completions/prelink @@ -6,18 +6,18 @@ _prelink() _init_completion -s || return case $prev in - -'?'|--help|--usage|-V|--version|-r|--reloc-only) + -'?' | --help | --usage | -V | --version | -r | --reloc-only) return ;; - -b|--black-list|--dynamic-linker|--undo-output) + -b | --black-list | --dynamic-linker | --undo-output) _filedir return ;; - -c|--config-file) + -c | --config-file) _filedir conf return ;; - -C|--cache) + -C | --cache) _filedir cache return ;; @@ -30,13 +30,13 @@ _prelink() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _prelink prelink + complete -F _prelink prelink # ex: filetype=sh diff --git a/completions/printenv b/completions/printenv new file mode 100644 index 00000000..3553e83d --- /dev/null +++ b/completions/printenv @@ -0,0 +1,23 @@ +# printenv(1) completion -*- shell-script -*- + +_printenv() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help | --version) + return + ;; + esac + + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + return + fi + + COMPREPLY=($(compgen -v -- "$cur")) +} && + complete -F _printenv printenv + +# ex: filetype=sh diff --git a/completions/protoc b/completions/protoc index d4381446..fdd77be6 100644 --- a/completions/protoc +++ b/completions/protoc @@ -6,11 +6,7 @@ _protoc() _init_completion -s || return case $prev in - --proto_path|--cpp_out|--java_out|--python_out) - _filedir -d - return - ;; - --version|-h|--help|--encode|--decode) + --version | -h | --help | --encode | --decode) return ;; --descriptor_set_out) @@ -18,16 +14,20 @@ _protoc() return ;; --error_format) - COMPREPLY=( $(compgen -W 'gcc msvs' -- "$cur") ) + COMPREPLY=($(compgen -W 'gcc msvs' -- "$cur")) return ;; --plugin) if [[ $cur != *=* ]]; then compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) fi return ;; + --proto_path | --*_out) + _filedir -d + return + ;; esac $split && return @@ -36,28 +36,28 @@ _protoc() -o*) cur=${cur:2} _filedir - COMPREPLY=( "${COMPREPLY[@]/#/-o}" ) + COMPREPLY=("${COMPREPLY[@]/#/-o}") return ;; -I*) cur=${cur:2} _filedir -d - COMPREPLY=( "${COMPREPLY[@]/#/-I}" ) + COMPREPLY=("${COMPREPLY[@]/#/-I}") return ;; -*) - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) local i for i in "${!COMPREPLY[@]}"; do [[ ${COMPREPLY[i]} == -oFILE ]] && unset 'COMPREPLY[i]' done - [[ $COMPREPLY == *= ]] && compopt -o nospace + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return ;; esac _filedir proto } && -complete -F _protoc protoc + complete -F _protoc protoc # ex: filetype=sh diff --git a/completions/psql b/completions/psql index ceedf07e..4bc6049f 100644 --- a/completions/psql +++ b/completions/psql @@ -4,16 +4,16 @@ _pg_databases() { # -w was introduced in 8.4, https://launchpad.net/bugs/164772 # "Access privileges" in output may contain linefeeds, hence the NF > 1 - COMPREPLY=( $(compgen -W "$(psql -XAtqwlF $'\t' 2>/dev/null | \ - awk 'NF > 1 { print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(psql -XAtqwlF $'\t' 2>/dev/null | + awk 'NF > 1 { print $1 }')" -- "$cur")) } _pg_users() { # -w was introduced in 8.4, https://launchpad.net/bugs/164772 - COMPREPLY=( $(compgen -W "$(psql -XAtqwc 'select usename from pg_user' \ - template1 2>/dev/null)" -- "$cur") ) - [[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -W "$(psql -XAtqwc 'select usename from pg_user' \ + template1 2>/dev/null)" -- "$cur")) + ((${#COMPREPLY[@]} == 0)) && COMPREPLY=($(compgen -u -- "$cur")) } # createdb(1) completion @@ -24,29 +24,29 @@ _createdb() _init_completion -s || return case $prev in - --host|-!(-*)h) + --host | -!(-*)h) _known_hosts_real -- "$cur" return ;; - --username|--owner|-!(-*)[UO]) + --username | --owner | -!(-*)[UO]) _pg_users return ;; - --help|--version|--port|--tablespace|--encoding|--template|-!(-*)[pDET]) + --help | --version | --port | --tablespace | --encoding | --template | -!(-*)[pDET]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _pg_databases fi } && -complete -F _createdb createdb + complete -F _createdb createdb # createuser(1) completion # @@ -56,14 +56,14 @@ _createuser() _init_completion -s || return case $prev in - --help|--version|--port|--connection-limit|-!(-*)[pc]) + --help | --version | --port | --connection-limit | -!(-*)[pc]) return ;; - --host|-!(-*)h) + --host | -!(-*)h) _known_hosts_real -- "$cur" return ;; - --username|-!(-*)U) + --username | -!(-*)U) _pg_users return ;; @@ -71,12 +71,12 @@ _createuser() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _createuser createuser + complete -F _createuser createuser # dropdb(1) completion # @@ -86,29 +86,29 @@ _dropdb() _init_completion -s || return case $prev in - --host|-!(-*)h) + --host | -!(-*)h) _known_hosts_real -- "$cur" return ;; - --username|-!(-*)U) + --username | -!(-*)U) _pg_users return ;; - --help|--version) + --help | --version) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _pg_databases fi } && -complete -F _dropdb dropdb + complete -F _dropdb dropdb # dropuser(1) completion # @@ -118,14 +118,14 @@ _dropuser() _init_completion -s || return case $prev in - --help|--version|--port|-!(-*)p) + --help | --version | --port | -!(-*)p) return ;; - --host|-!(-*)h) + --host | -!(-*)h) _known_hosts_real -- "$cur" return ;; - --username|-!(-*)U) + --username | -!(-*)U) _pg_users return ;; @@ -133,14 +133,14 @@ _dropuser() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _pg_users fi } && -complete -F _dropuser dropuser + complete -F _dropuser dropuser # psql(1) completion # @@ -150,39 +150,39 @@ _psql() _init_completion -s || return case $prev in - --host|-!(-*)h) + --host | -!(-*)h) _known_hosts_real -- "$cur" return ;; - --username|-!(-*)U) + --username | -!(-*)U) _pg_users return ;; - --dbname|-!(-*)d) + --dbname | -!(-*)d) _pg_databases return ;; - --output|--file|--log-file|-!(-*)[ofL]) + --output | --file | --log-file | -!(-*)[ofL]) _filedir return ;; - --help|--version|--command|--field-separator|--port|--pset|\ - --record-separator|--table-attr|--set|--variable|-!(-*)[?VcFpPRTv]) + --help | --version | --command | --field-separator | --port | --pset | \ + --record-separator | --table-attr | --set | --variable | -!(-*)[?VcFpPRTv]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # return list of available options - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else # return list of available databases _pg_databases fi } && -complete -F _psql psql + complete -F _psql psql # ex: filetype=sh diff --git a/completions/puppet b/completions/puppet index b9e1bcd6..e8767de1 100644 --- a/completions/puppet +++ b/completions/puppet @@ -3,54 +3,54 @@ _puppet_logdest() { if [[ -z $cur ]]; then - COMPREPLY=( $(compgen -W 'syslog console /' -- "$cur") ) + COMPREPLY=($(compgen -W 'syslog console /' -- "$cur")) else - COMPREPLY=( $(compgen -W 'syslog console' -- "$cur") ) + COMPREPLY=($(compgen -W 'syslog console' -- "$cur")) _filedir fi } _puppet_digest() { - COMPREPLY=( $(compgen -W 'MD5 MD2 SHA1 SHA256' -- "$cur") ) + COMPREPLY=($(compgen -W 'MD5 MD2 SHA1 SHA256' -- "$cur")) } _puppet_certs() { local puppetca="puppet cert" - PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetca &>/dev/null \ - && puppetca=puppetca + PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetca &>/dev/null && + puppetca=puppetca - if [[ "$1" == --all ]]; then + if [[ $1 == --all ]]; then cert_list=$($puppetca --list --all | command sed -e 's/^[+-]\{0,1\}\s*\(\S\+\)\s\+.*$/\1/') else cert_list=$($puppetca --list) fi - COMPREPLY+=( $(compgen -W "$cert_list" -- "$cur") ) + COMPREPLY+=($(compgen -W "$cert_list" -- "$cur")) } _puppet_types() { puppet_types=$(puppet describe --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/') - COMPREPLY+=( $(compgen -W "$puppet_types" -- "$cur") ) + COMPREPLY+=($(compgen -W "$puppet_types" -- "$cur")) } _puppet_references() { local puppetdoc="puppet doc" - PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetdoc &>/dev/null \ - && puppetdoc=puppetdoc + PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetdoc &>/dev/null && + puppetdoc=puppetdoc puppet_doc_list=$($puppetdoc --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/') - COMPREPLY+=( $(compgen -W "$puppet_doc_list" -- "$cur") ) + COMPREPLY+=($(compgen -W "$puppet_doc_list" -- "$cur")) } _puppet_subcmd_opts() { # puppet cmd help is somewhat slow, avoid if possible - [[ -z $cur || $cur == -* ]] && \ - COMPREPLY+=( $(compgen -W \ - '$(_parse_usage "$1" "help $2")' -- "$cur") ) + [[ -z $cur || $cur == -* ]] && + COMPREPLY+=($(compgen -W \ + '$(_parse_usage "$1" "help $2")' -- "$cur")) } _puppet() @@ -58,10 +58,10 @@ _puppet() local cur prev words cword _init_completion || return - local xspec helpopts subcommand action + local subcommand action case $prev in - -h|--help|-V|--version) + -h | --help | -V | --version) return ;; esac @@ -96,19 +96,20 @@ _puppet() ;; puppet) case ${words[1]} in - agent|apply|cert|describe|doc|filebucket|kick|master|parser|queue|resource) + agent | apply | cert | describe | doc | filebucket | kick | master | parser | queue | resource) subcommand=${words[1]} ;; - *.pp|*.rb) + *.pp | *.rb) subcommand=apply ;; *) - COMPREPLY=( $(compgen -W 'agent apply cert describe doc + COMPREPLY=($(compgen -W 'agent apply cert describe doc filebucket kick master parser queue resource' \ - -- "$cur") ) + -- "$cur")) return ;; esac + ;; esac case $subcommand in @@ -126,46 +127,48 @@ _puppet() _known_hosts_real -- "$cur" return ;; - -l|--logdest) + -l | --logdest) _puppet_logdest return ;; --masterport) - COMPREPLY=( $(compgen -W '8140' -- "$cur") ) + COMPREPLY=($(compgen -W '8140' -- "$cur")) return ;; - -w|--waitforcert) - COMPREPLY=( $(compgen -W '0 15 30 60 120' -- "$cur") ) + -w | --waitforcert) + COMPREPLY=($(compgen -W '0 15 30 60 120' -- "$cur")) return ;; *) _puppet_subcmd_opts "$1" $subcommand # _parse_usage doesn't grok [-D|--daemonize|--no-daemonize] - COMPREPLY+=( $(compgen -W '--no-daemonize' -- "$cur") ) + COMPREPLY+=($(compgen -W '--no-daemonize' -- "$cur")) return + ;; esac ;; apply) case $prev in --catalog) - COMPREPLY=( $(compgen -W '-' -- "$cur") ) + COMPREPLY=($(compgen -W '-' -- "$cur")) _filedir json return ;; --execute) return ;; - -l|--logdest) + -l | --logdest) _puppet_logdest return ;; *) - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _puppet_subcmd_opts "$1" $subcommand else _filedir fi return + ;; esac ;; cert) @@ -176,117 +179,123 @@ _puppet() ;; *) action=$prev - COMPREPLY=( $(compgen -W '--digest --debug --help --verbose --version' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '--digest --debug --help --verbose --version' \ + -- "$cur")) case $action in - fingerprint|list|verify|--fingerprint|--list|--verify) - COMPREPLY+=( $(compgen -W '--all' -- "$cur") ) + fingerprint | list | verify | --fingerprint | --list | --verify) + COMPREPLY+=($(compgen -W '--all' -- "$cur")) _puppet_certs --all return ;; - generate|--generate) + generate | --generate) _known_hosts_real -- "$cur" return ;; - clean|print|revoke|--clean|--print|--revoke) + clean | print | revoke | --clean | --print | --revoke) _puppet_certs --all return ;; - sign|--sign) - COMPREPLY+=( $(compgen -W '--all' -- "$cur") ) + sign | --sign) + COMPREPLY+=($(compgen -W '--all' -- "$cur")) _puppet_certs return ;; *) - COMPREPLY+=( $(compgen -W 'clean fingerprint generate - list print revoke sign verify reinventory' -- "$cur") ) + COMPREPLY+=($(compgen -W 'clean fingerprint generate + list print revoke sign verify reinventory' -- "$cur")) return + ;; esac + ;; esac ;; describe) _puppet_subcmd_opts "$1" $subcommand - if [[ "$cur" != -* ]]; then + if [[ $cur != -* ]]; then _puppet_types fi return ;; doc) case $prev in - -o|--outputdir) + -o | --outputdir) _filedir -d return ;; - -m|--mode) - COMPREPLY=( $(compgen -W 'text trac pdf rdoc' -- "$cur") ) + -m | --mode) + COMPREPLY=($(compgen -W 'text trac pdf rdoc' -- "$cur")) return ;; - -r|--reference) + -r | --reference) _puppet_references return ;; *) - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _puppet_subcmd_opts "$1" $subcommand else _filedir fi return + ;; esac ;; filebucket) case $prev in - -s|--server) + -s | --server) _known_hosts_real -- "$cur" return ;; - -b|--bucket) + -b | --bucket) _filedir -d return ;; *) - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _puppet_subcmd_opts "$1" $subcommand else - COMPREPLY=( $(compgen -W 'backup get restore' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'backup get restore' \ + -- "$cur")) _filedir fi return + ;; esac ;; kick) case $prev in - -c|--class) + -c | --class) return ;; --host) _known_hosts_real -- "$cur" return ;; - -t|--tag) + -t | --tag) return ;; *) - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _puppet_subcmd_opts "$1" $subcommand else _known_hosts_real -- "$cur" fi return + ;; esac ;; master) case $prev in - -l|--logdest) + -l | --logdest) _puppet_logdest return ;; *) _puppet_subcmd_opts "$1" $subcommand # _parse_usage doesn't grok [-D|--daemonize|--no-daemonize] - COMPREPLY+=( $(compgen -W '--no-daemonize' -- "$cur") ) + COMPREPLY+=($(compgen -W '--no-daemonize' -- "$cur")) return + ;; esac ;; parser) @@ -297,31 +306,33 @@ _puppet() return ;; *) - COMPREPLY=( $(compgen -W 'validate' -- "$cur") ) + COMPREPLY=($(compgen -W 'validate' -- "$cur")) return + ;; esac ;; queue) case $prev in - -l|--logdest) + -l | --logdest) _puppet_logdest return ;; *) - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _puppet_subcmd_opts "$1" $subcommand else _filedir fi return + ;; esac ;; - resource|*) + resource | *) _puppet_subcmd_opts "$1" $subcommand return ;; esac } && -complete -F _puppet puppetmasterd puppetd puppetca ralsh puppetrun puppetqd filebucket puppetdoc puppet + complete -F _puppet puppetmasterd puppetd puppetca ralsh puppetrun puppetqd filebucket puppetdoc puppet # ex: filetype=sh diff --git a/completions/pv b/completions/pv index 007bb36b..99933f29 100644 --- a/completions/pv +++ b/completions/pv @@ -6,26 +6,26 @@ _pv() _init_completion || return case $prev in - --help|--version|--last-written|--format|--delay-start|--interval|\ - --width|--height|--name|--rate-limit|--buffer-size|-!(-*)[hVAFDiwHNLB]) + --help | --version | --last-written | --format | --delay-start | --interval | \ + --width | --height | --name | --rate-limit | --buffer-size | -!(-*)[hVAFDiwHNLB]) return ;; - --remote|-!(-*)R) + --remote | -!(-*)R) _pids return ;; - --pidfile|--watchfd|-!(-*)[Pd]) + --pidfile | --watchfd | -!(-*)[Pd]) _filedir pid return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else _filedir fi } && -complete -F _pv pv + complete -F _pv pv # ex: filetype=sh diff --git a/completions/pwck b/completions/pwck index cc5f2e42..fa07b0e1 100644 --- a/completions/pwck +++ b/completions/pwck @@ -5,14 +5,14 @@ _pwck() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) return fi _filedir } && -complete -F _pwck pwck + complete -F _pwck pwck # ex: filetype=sh diff --git a/completions/pwd b/completions/pwd index 56100173..b9c4fbc0 100644 --- a/completions/pwd +++ b/completions/pwd @@ -6,15 +6,15 @@ _pwd() _init_completion || return case $prev in - --help|--version) + --help | --version) return ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY ]] || \ - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} ]] || + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) } && -complete -F _pwd pwd + complete -F _pwd pwd # ex: filetype=sh diff --git a/completions/pwdx b/completions/pwdx index 675c41ff..25a1a1e1 100644 --- a/completions/pwdx +++ b/completions/pwdx @@ -6,7 +6,7 @@ _pwdx() _init_completion || return case $prev in - -h|--help|-V|--version) + -h | --help | -V | --version) return ;; esac @@ -14,11 +14,11 @@ _pwdx() if [[ $cur == -* ]]; then local help='$(_parse_help "$1")' [[ $help ]] || help=-V - COMPREPLY=( $(compgen -W "$help" -- "$cur") ) + COMPREPLY=($(compgen -W "$help" -- "$cur")) else _pids fi } && -complete -F _pwdx pwdx + complete -F _pwdx pwdx # ex: filetype=sh diff --git a/completions/pwgen b/completions/pwgen index 8781cb9a..50d31d5f 100644 --- a/completions/pwgen +++ b/completions/pwgen @@ -6,10 +6,10 @@ _pwgen() _init_completion -s || return case $prev in - --num-passwords|--help|-!(-*)[Nh]) + --num-passwords | --help | -!(-*)[Nh]) return ;; - --sha1|-!(-*)H) + --sha1 | -!(-*)H) _filedir return ;; @@ -18,11 +18,11 @@ _pwgen() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi } && -complete -F _pwgen pwgen + complete -F _pwgen pwgen # ex: filetype=sh diff --git a/completions/pycodestyle b/completions/pycodestyle index 2eac748c..dec6f375 100644 --- a/completions/pycodestyle +++ b/completions/pycodestyle @@ -6,11 +6,11 @@ _pycodestyle() _init_completion -s || return case $prev in - -h|--help|--version) + -h | --help | --version) return ;; --format) - COMPREPLY=( $(compgen -W 'default pylint' -- "$cur") ) + COMPREPLY=($(compgen -W 'default pylint' -- "$cur")) return ;; --config) @@ -22,13 +22,13 @@ _pycodestyle() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir py } && -complete -F _pycodestyle pycodestyle + complete -F _pycodestyle pycodestyle # ex: filetype=sh diff --git a/completions/pydoc b/completions/pydoc index 1e904885..e7b11788 100644 --- a/completions/pydoc +++ b/completions/pydoc @@ -6,7 +6,7 @@ _pydoc() _init_completion || return case $prev in - -k|-p) + -k | -p) return ;; -w) @@ -15,27 +15,28 @@ _pydoc() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W \ + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W \ '$("$1" | command sed -e "s/^pydoc3\{0,1\} //" | _parse_help -)' \ - -- "$cur") ) + -- "$cur")) return fi - COMPREPLY=( $(compgen -W 'keywords topics modules' -- "$cur") ) + COMPREPLY=($(compgen -W 'keywords topics modules' -- "$cur")) if [[ $cur != @(.|*/)* ]]; then - local python=python; [[ ${1##*/} == *3* ]] && python=python3 + local python=python + [[ ${1##*/} == *3* ]] && python=python3 _xfunc python _python_modules $python fi # Note that we don't do "pydoc modules" as it is known to hang on # some systems; _python_modules tends to work better and faster. - COMPREPLY+=( $(compgen -W \ - '$($1 keywords topics | command sed -e /^Here/d)' -- "$cur") ) + COMPREPLY+=($(compgen -W \ + '$($1 keywords topics | command sed -e /^Here/d)' -- "$cur")) _filedir py } && -complete -F _pydoc pydoc pydoc3 + complete -F _pydoc pydoc pydoc3 # ex: filetype=sh diff --git a/completions/pydocstyle b/completions/pydocstyle index eb858901..acbf1ece 100644 --- a/completions/pydocstyle +++ b/completions/pydocstyle @@ -6,8 +6,8 @@ _pydocstyle() _init_completion -s || return case $prev in - --help|--version|--match|--ignore-decorators|--select|--ignore|\ - --add-select|--add-ignore|-!(-*)h) + --help | --version | --match | --ignore-decorators | --select | --ignore | \ + --add-select | --add-ignore | -!(-*)h) return ;; --config) @@ -15,21 +15,21 @@ _pydocstyle() return ;; --convention) - COMPREPLY=( $(compgen -W "pep257 numpy" -- "$cur") ) + COMPREPLY=($(compgen -W "pep257 numpy" -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir py } && -complete -F _pydocstyle pydocstyle + complete -F _pydocstyle pydocstyle # ex: filetype=sh diff --git a/completions/pyflakes b/completions/pyflakes index 4a982784..0a4e9771 100644 --- a/completions/pyflakes +++ b/completions/pyflakes @@ -6,18 +6,18 @@ _pyflakes() _init_completion || return case $prev in - -h|--help|--version) + -h | --help | --version) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir py } && -complete -F _pyflakes pyflakes + complete -F _pyflakes pyflakes # ex: filetype=sh diff --git a/completions/pylint b/completions/pylint index 35655964..8726f8bb 100644 --- a/completions/pylint +++ b/completions/pylint @@ -5,63 +5,66 @@ _pylint() local cur prev words cword split _init_completion -s || return - local python=python; [[ ${1##*/} == *3* ]] && python=python3 + local python=python + [[ ${1##*/} == *3* ]] && python=python3 case $prev in - --version|--help|--long-help|--help-msg|--init-hook|--ignore|--enable|\ - --evaluation|--max-line-length|--max-module-lines|\ - --indent-string|--min-similarity-lines|--max-args|\ - --ignored-argument-names|--max-locals|--max-returns|--max-branchs|\ - --max-statements|--max-parents|--max-attributes|--min-public-methods|\ - --max-public-methods|--required-attributes|--bad-functions|\ - --module-rgx|--const-rgx|--class-rgx|--function-rgx|--method-rgx|\ - --attr-rgx|--argument-rgx|--variable-rgx|--inlinevar-rgx|--good-names|\ - --bad-names|--no-docstring-rgx|--dummy-variables-rgx|\ - --additional-builtins|--notes|--ignored-classes|--generated-members|\ - --overgeneral-exceptions|--ignore-iface-methods|\ - --defining-attr-methods|--valid-classmethod-first-arg|\ - --valid-metaclass-classmethod-first-arg|-!(-*)[he]) + --version | --help | --long-help | --help-msg | --init-hook | --ignore | --enable | \ + --evaluation | --max-line-length | --max-module-lines | \ + --indent-string | --min-similarity-lines | --max-args | \ + --ignored-argument-names | --max-locals | --max-returns | --max-branchs | \ + --max-statements | --max-parents | --max-attributes | --min-public-methods | \ + --max-public-methods | --required-attributes | --bad-functions | \ + --module-rgx | --const-rgx | --class-rgx | --function-rgx | --method-rgx | \ + --attr-rgx | --argument-rgx | --variable-rgx | --inlinevar-rgx | --good-names | \ + --bad-names | --no-docstring-rgx | --dummy-variables-rgx | \ + --additional-builtins | --notes | --ignored-classes | --generated-members | \ + --overgeneral-exceptions | --ignore-iface-methods | \ + --defining-attr-methods | --valid-classmethod-first-arg | \ + --valid-metaclass-classmethod-first-arg | -!(-*)[he]) return ;; - --disable|-!(-*)d) - COMPREPLY=( $(compgen -W 'all' -- "$cur") ) + --disable | -!(-*)d) + COMPREPLY=($(compgen -W 'all' -- "$cur")) return ;; --rcfile) _filedir return ;; - --persistent|--include-ids|--symbols|--files-output|--reports|\ - --comment|--ignore-comments|--ignore-docstrings|--ignore-imports|\ - --init-import|--ignore-mixin-members|--zope|--suggestion-mode|\ - -!(-*)[isr]) - COMPREPLY=( $(compgen -W 'yes no' -- "$cur") ) + --persistent | --include-ids | --symbols | --files-output | --reports | \ + --comment | --ignore-comments | --ignore-docstrings | --ignore-imports | \ + --init-import | --ignore-mixin-members | --zope | --suggestion-mode | \ + -!(-*)[isr]) + COMPREPLY=($(compgen -W 'yes no' -- "$cur")) return ;; - --load-plugins|--deprecated-modules) - local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," + --load-plugins | --deprecated-modules) + local prefix= + [[ $cur == *,* ]] && prefix="${cur%,*}," cur="${cur##*,}" _xfunc python _python_modules $python - [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) return ;; - --jobs|-!(-*)j) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + --jobs | -!(-*)j) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; --confidence) - local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $(compgen -W "HIGH INFERENCE INFERENCE_FAILURE - UNDEFINED" -- "${cur##*,}") ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + local prefix= + [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=($(compgen -W "HIGH INFERENCE INFERENCE_FAILURE + UNDEFINED" -- "${cur##*,}")) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) return ;; - --format|-!(-*)f) - COMPREPLY=( $(compgen -W 'text parseable colorized json msvs' \ - -- "$cur") ) + --format | -!(-*)f) + COMPREPLY=($(compgen -W 'text parseable colorized json msvs' \ + -- "$cur")) return ;; - --import-graph|--ext-import-graph|--int-import-graph) + --import-graph | --ext-import-graph | --int-import-graph) _filedir dot return ;; @@ -70,15 +73,15 @@ _pylint() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W \ - '$(_parse_help "$1" --long-help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W \ + '$(_parse_help "$1" --long-help)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi [[ $cur == @(.|*/)* ]] || _xfunc python _python_modules $python _filedir py } && -complete -F _pylint pylint pylint-2 pylint-3 + complete -F _pylint pylint pylint-2 pylint-3 # ex: filetype=sh diff --git a/completions/pytest b/completions/pytest index 9239766c..7457a840 100644 --- a/completions/pytest +++ b/completions/pytest @@ -3,38 +3,46 @@ _pytest() { local cur prev words cword split - _init_completion -s || return + _init_completion -s -n : || return case $prev in - --help|--maxfail|--report|--junit-prefix|--doctest-glob|-!(-*)[hkmrp]) + --help | --maxfail | --report | --junit-prefix | --doctest-glob | -!(-*)[hkmorp]) return ;; --import-mode) - COMPREPLY=( $(compgen -W "prepend append" -- "$cur") ) + COMPREPLY=($(compgen -W "prepend append" -- "$cur")) return ;; --capture) - COMPREPLY=( $(compgen -W "fd sys no" -- "$cur") ) + COMPREPLY=($(compgen -W "fd sys no tee-sys" -- "$cur")) + return + ;; + --lfnf | --last-failed-no-failures) + COMPREPLY=($(compgen -W "all none" -- "$cur")) return ;; --tb) - COMPREPLY=( $(compgen -W "auto long short line native no" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "auto long short line native no" \ + -- "$cur")) + return + ;; + --show-capture) + COMPREPLY=($(compgen -W "no stdout stderr log all" -- "$cur")) return ;; --color) - COMPREPLY=( $(compgen -W "yes no auto" -- "$cur") ) + COMPREPLY=($(compgen -W "yes no auto" -- "$cur")) return ;; --pastebin) - COMPREPLY=( $(compgen -W "failed all" -- "$cur") ) + COMPREPLY=($(compgen -W "failed all" -- "$cur")) return ;; --junit-xml) _filedir xml return ;; - --result-log) + --result-log | --log-file) _filedir log return ;; @@ -42,45 +50,85 @@ _pytest() _filedir return ;; - --confcutdir|--basetemp|--rsyncdir) + --confcutdir | --basetemp | --rsyncdir | --rootdir) _filedir -d return ;; + --doctest-report) + COMPREPLY=($(compgen -W "none cdiff ndiff udiff only_first_failure" -- "$cur")) + return + ;; --assert) - COMPREPLY=( $(compgen -W "plain reinterp rewrite" -- "$cur") ) + COMPREPLY=($(compgen -W "plain reinterp rewrite" -- "$cur")) return ;; --genscript) _filedir py return ;; - --pythonwarnings|-!(-*)W) + --pythonwarnings | -!(-*)W) _xfunc python _python_warning_actions return ;; - --numprocesses|-!(-*)n) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)} auto" -- "$cur") ) + --numprocesses | -!(-*)n) + COMPREPLY=($(compgen -W "{1..$(_ncpus)} auto" -- "$cur")) return ;; --dist) - local modes=$("$1" --dist=nonexistent-distmode 2>&1 | \ + local modes=$("$1" --dist=nonexistent-distmode 2>&1 | command sed -e 's/[^[:space:][:alnum:]-]\{1,\}//g' \ - -ne 's/.*choose from //p') - COMPREPLY=( $(compgen -W '$modes' -- "$cur") ) + -ne 's/.*choose from //p') + COMPREPLY=($(compgen -W '$modes' -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace + return + fi + + if [[ $cur == *.py::*:* ]]; then + local file=${cur/.py:*/.py} + local class=${cur#*.py::} in_class=false + local line + class=${class%%:*} + while IFS= read -r line; do + if [[ $line =~ ^class[[:space:]]+${class}[[:space:]:\(] ]]; then + in_class=true + elif [[ $line =~ ^class[[:space:]] ]]; then + in_class=false + fi + if $in_class && [[ $line =~ ^[[:space:]]+(async[[:space:]]+)?def[[:space:]]+(test_[A-Za-z0-9_]+) ]]; then + COMPREPLY+=(${BASH_REMATCH[2]}) + fi + done 2>/dev/null <"$file" + ((!${#COMPREPLY[@]})) || + COMPREPLY=($(compgen -P "$file::$class::" -W '${COMPREPLY[@]}' \ + -- "${cur##*:?(:)}")) + __ltrim_colon_completions "$cur" + return + elif [[ $cur == *.py:* ]]; then + local file="${cur/.py:*/.py}" line + while IFS= read -r line; do + if [[ $line =~ ^class[[:space:]]+(Test[A-Za-z0-9_]+) ]]; then + COMPREPLY+=(${BASH_REMATCH[1]}) + elif [[ $line =~ ^(async[[:space:]]+)?def[[:space:]]+(test_[A-Za-z0-9_]+) ]]; then + COMPREPLY+=(${BASH_REMATCH[2]}) + fi + done 2>/dev/null <"$file" + ((!${#COMPREPLY[@]})) || + COMPREPLY=($(compgen -P "$file::" -W '${COMPREPLY[@]}' \ + -- "${cur##*.py:?(:)}")) + __ltrim_colon_completions "$cur" return fi _filedir py } && -complete -F _pytest pytest pytest-2 pytest-3 py.test py.test-2 py.test-3 + complete -F _pytest pytest pytest-2 pytest-3 py.test py.test-2 py.test-3 # ex: filetype=sh diff --git a/completions/python b/completions/python index 5e69ff12..d50c18f0 100644 --- a/completions/python +++ b/completions/python @@ -2,15 +2,15 @@ _python_modules() { - COMPREPLY+=( $(compgen -W \ + COMPREPLY+=($(compgen -W \ "$(${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python $cur \ - 2>/dev/null)" -- "$cur") ) + 2>/dev/null)" -- "$cur")) } _python_warning_actions() { - COMPREPLY+=( $(compgen -W "ignore default all module once error" \ - ${prefix:+-P "$prefix"} -- "$cur") ) + COMPREPLY+=($(compgen -W "ignore default all module once error" \ + ${prefix:+-P "$prefix"} -- "$cur")) } _python() @@ -23,11 +23,11 @@ _python() prefix=${cur:0:2} prev=$prefix cur=${cur:2} - ;; + ;; esac case $prev in - --help|--version|-!(-*)[?hVcX]) + --help | --version | -!(-*)[?hVcX]) return ;; -!(-*)m) @@ -35,8 +35,8 @@ _python() return ;; -!(-*)Q) - COMPREPLY=( $(compgen -W "old new warn warnall" -P "$prefix" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "old new warn warnall" -P "$prefix" \ + -- "$cur")) return ;; -!(-*)W) @@ -45,24 +45,23 @@ _python() ;; --jit) # TODO: quite a few others, parse from "--jit help" output? - COMPREPLY=( $(compgen -W "help off" -- "$cur") ) + COMPREPLY=($(compgen -W "help off" -- "$cur")) return ;; !(?(*/)python*([0-9.])|?(*/)pypy*([0-9.])|-?)) - [[ $cword -lt 2 || ${words[cword-2]} != -[QWX] ]] && _filedir + [[ $cword -lt 2 || ${words[cword - 2]} != -[QWX] ]] && _filedir ;; esac - # if -c or -m is already given, complete all kind of files. - if [[ "${words[*]::$cword}" == *\ -[cm]\ * ]]; then + if [[ ${words[*]::cword} == *\ -[cm]\ * ]]; then _filedir - elif [[ "$cur" != -* ]]; then + elif [[ $cur != -* ]]; then _filedir 'py?([cowz])' else - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) fi } && -complete -F _python python python2 python3 pypy pypy3 micropython + complete -F _python python python2 python2.7 python3 python3.{3..8} pypy pypy3 micropython # ex: filetype=sh diff --git a/completions/pyvenv b/completions/pyvenv index d5135e87..527a3840 100644 --- a/completions/pyvenv +++ b/completions/pyvenv @@ -6,20 +6,20 @@ _pyvenv() _init_completion -s || return case $prev in - -h|--help) + -h | --help) return ;; esac $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _longopt "$1" return fi _filedir -d } && -complete -F _pyvenv pyvenv pyvenv-3.{4..8} + complete -F _pyvenv pyvenv pyvenv-3.{4..8} # ex: filetype=sh diff --git a/completions/qdbus b/completions/qdbus index 9a22e800..5b5a5e37 100644 --- a/completions/qdbus +++ b/completions/qdbus @@ -5,10 +5,10 @@ _qdbus() local cur prev words cword _init_completion || return - [[ -n $cur ]] && unset "words[$((${#words[@]}-1))]" - COMPREPLY=( $(compgen -W '$(command ${words[@]} 2>/dev/null | \ - command sed "s/(.*)//")' -- "$cur") ) + [[ -n $cur ]] && unset "words[$((${#words[@]} - 1))]" + COMPREPLY=($(compgen -W '$(command ${words[@]} 2>/dev/null | \ + command sed "s/(.*)//")' -- "$cur")) } && -complete -F _qdbus qdbus dcop + complete -F _qdbus qdbus dcop # ex: filetype=sh diff --git a/completions/qemu b/completions/qemu index 8602cebd..83829812 100644 --- a/completions/qemu +++ b/completions/qemu @@ -6,88 +6,88 @@ _qemu() _init_completion || return case $prev in - -fd[ab]|-hd[abcd]|-cdrom|-option-rom|-kernel|-initrd|-bootp|-pidfile| \ - -loadvm|-mtdblock|-sd|-pflash|-bios) + -fd[ab] | -hd[abcd] | -cdrom | -option-rom | -kernel | -initrd | -bootp | -pidfile | \ + -loadvm | -mtdblock | -sd | -pflash | -bios) _filedir return ;; - -tftp|-smb|-L|-chroot) + -tftp | -smb | -L | -chroot) _filedir -d return ;; -boot) - COMPREPLY=( $(compgen -W 'a c d n' -- "$cur") ) + COMPREPLY=($(compgen -W 'a c d n' -- "$cur")) return ;; -k) - COMPREPLY=( $(compgen -W 'ar de-ch es fo fr-ca hu ja mk no pt-br + COMPREPLY=($(compgen -W 'ar de-ch es fo fr-ca hu ja mk no pt-br sv da en-gb et fr fr-ch is lt nl pl ru th de en-us fi fr-be hr - it lv nl-be pt sl tr' -- "$cur") ) + it lv nl-be pt sl tr' -- "$cur")) return ;; -soundhw) - COMPREPLY=( $(compgen -W "$($1 -soundhw ? | awk \ - '/^[[:lower:]]/ {print $1}') all" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 -soundhw help | awk \ + '/^[[:lower:]]/ {print $1}') all" -- "$cur")) return ;; - -M) - COMPREPLY=( $(compgen -W "$($1 -M ? | awk \ - '/^[[:lower:]]/ {print $1}')" -- "$cur") ) + -machine | -M) + COMPREPLY=($(compgen -W "$($1 $prev help | awk \ + '/^[[:lower:]]/ {print $1}')" -- "$cur")) return ;; -cpu) - COMPREPLY=( $(compgen -W "$($1 -cpu ? | awk '{print $2}')" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 -cpu help | awk '{print $2}')" \ + -- "$cur")) return ;; -usbdevice) - COMPREPLY=( $(compgen -W 'mouse tablet disk: host: serial: braille - net' -- "$cur") ) + COMPREPLY=($(compgen -W 'mouse tablet disk: host: serial: braille + net' -- "$cur")) return ;; -net) - COMPREPLY=( $(compgen -W 'nic user tap socket vde none dump' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'nic user tap socket vde none dump' \ + -- "$cur")) return ;; - -serial|-parallel|-monitor) - COMPREPLY=( $(compgen -W 'vc pty none null /dev/ file: stdio pipe: - COM udp: tcp: telnet: unix: mon: braille' -- "$cur") ) + -serial | -parallel | -monitor) + COMPREPLY=($(compgen -W 'vc pty none null /dev/ file: stdio pipe: + COM udp: tcp: telnet: unix: mon: braille' -- "$cur")) return ;; -redir) - COMPREPLY=( $(compgen -S":" -W 'tcp udp' -- "$cur") ) + COMPREPLY=($(compgen -S":" -W 'tcp udp' -- "$cur")) return ;; -bt) - COMPREPLY=( $(compgen -W 'hci vhci device' -- "$cur") ) + COMPREPLY=($(compgen -W 'hci vhci device' -- "$cur")) return ;; -vga) - COMPREPLY=( $(compgen -W 'cirrus std vmware xenfb none' -- "$cur") ) + COMPREPLY=($(compgen -W 'cirrus std vmware xenfb none' -- "$cur")) return ;; -drive) - COMPREPLY=( $(compgen -S"=" -W 'file if bus unit index media cyls - snapshot cache format serial addr' -- "$cur") ) + COMPREPLY=($(compgen -S"=" -W 'file if bus unit index media cyls + snapshot cache format serial addr' -- "$cur")) return ;; -balloon) - COMPREPLY=( $(compgen -W 'none virtio' -- "$cur") ) + COMPREPLY=($(compgen -W 'none virtio' -- "$cur")) return ;; -smbios) - COMPREPLY=( $(compgen -W 'file type' -- "$cur") ) + COMPREPLY=($(compgen -W 'file type' -- "$cur")) return ;; -watchdog) - COMPREPLY=( $(compgen -W "$($1 -watchdog ? 2>&1 | \ - awk '{print $1}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 -watchdog help 2>&1 | + awk '{print $1}')" -- "$cur")) return ;; -watchdog-action) - COMPREPLY=( $(compgen -W 'reset shutdown poweroff pause debug - none' -- "$cur") ) + COMPREPLY=($(compgen -W 'reset shutdown poweroff pause debug + none' -- "$cur")) return ;; -runas) @@ -96,14 +96,13 @@ _qemu() ;; esac - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help) -fd{a,b} - -hd{a..d}' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help) -fd{a,b} + -hd{a..d}' -- "$cur")) else _filedir fi } && -complete -F _qemu qemu qemu-kvm qemu-system-i386 qemu-system-x86_64 + complete -F _qemu qemu qemu-kvm qemu-system-i386 qemu-system-x86_64 # ex: filetype=sh diff --git a/completions/qrunner b/completions/qrunner index b0421a09..3919ea25 100644 --- a/completions/qrunner +++ b/completions/qrunner @@ -7,12 +7,12 @@ _qrunner() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--runner --once --list --verbose --subproc - --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--runner --once --list --verbose --subproc + --help' -- "$cur")) fi } && -complete -F _qrunner qrunner + complete -F _qrunner qrunner # ex: filetype=sh diff --git a/completions/querybts b/completions/querybts index 69c5aa08..edeba967 100644 --- a/completions/querybts +++ b/completions/querybts @@ -6,18 +6,18 @@ _querybts() _init_completion -s || return case $prev in - --bts|-!(-*)B) - COMPREPLY=( $(compgen -W "debian guug kde mandrake help" \ - -- "$cur") ) + --bts | -!(-*)B) + COMPREPLY=($(compgen -W "debian guug kde mandrake help" \ + -- "$cur")) return ;; - --ui|--interface|-!(-*)u) - COMPREPLY=( $(compgen -W "newt text gnome" -- "$cur") ) + --ui | --interface | -!(-*)u) + COMPREPLY=($(compgen -W "newt text gnome" -- "$cur")) return ;; --mbox-reader-cmd) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; esac @@ -25,16 +25,16 @@ _querybts() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - COMPREPLY=( $(compgen -W 'wnpp boot-floppies kernel bugs.debian.org + COMPREPLY=($(compgen -W '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 $(apt-cache pkgnames 2>/dev/null)' -- "$cur") ) + www.debian.org $(_xfunc apt-cache _apt_cache_packages)' -- "$cur")) fi } && -complete -F _querybts querybts + complete -F _querybts querybts # ex: filetype=sh diff --git a/completions/quota b/completions/quota index bf7319bc..f5f9cc82 100644 --- a/completions/quota +++ b/completions/quota @@ -5,35 +5,35 @@ _user_or_group() local i # complete on groups if -g was given - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -@(g|-group) ]]; then - COMPREPLY=( $(compgen -g -- "$cur") ) + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -@(g|-group) ]]; then + COMPREPLY=($(compgen -g -- "$cur")) return fi done # otherwise complete on users - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) } _quota_parse_help() { local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } _quota_formats() { - COMPREPLY=( $(compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur") ) + COMPREPLY=($(compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur")) } _filesystems() { # Only list filesystems starting with "/", otherwise we also get #+ "binfmt_misc", "proc", "tmpfs", ... - COMPREPLY=( $(compgen -W "$(awk '/^\// {print $1}' /etc/mtab)" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "$(awk '/^\// {print $1}' /etc/mtab)" \ + -- "$cur")) } _quota() @@ -42,24 +42,24 @@ _quota() _init_completion -s || return case $prev in - -F|--format) + -F | --format) _quota_formats return ;; - -h|--help|-V|--version) + -h | --help | -V | --version) return ;; esac $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _quota_parse_help "$1" else _user_or_group fi } && -complete -F _quota -o default quota + complete -F _quota -o default quota _setquota() { @@ -67,22 +67,22 @@ _setquota() _init_completion -s || return case $prev in - -F|--format) + -F | --format) _quota_formats return ;; - -p|--prototype) + -p | --prototype) _user_or_group return ;; - -h|--help|-V|--version) + -h | --help | -V | --version) return ;; esac $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _quota_parse_help "$1" else local args @@ -99,7 +99,7 @@ _setquota() fi } && -complete -F _setquota -o default setquota + complete -F _setquota -o default setquota _edquota() { @@ -107,32 +107,32 @@ _edquota() _init_completion -s || return case $prev in - -F|--format) + -F | --format) _quota_formats return ;; - -f|--filesystem) + -f | --filesystem) _filesystems return ;; - -p|--prototype) + -p | --prototype) _user_or_group return ;; - -h|--help|-V|--version) + -h | --help | -V | --version) return ;; esac $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _quota_parse_help "$1" else _user_or_group fi } && -complete -F _edquota -o default edquota + complete -F _edquota -o default edquota _quotacheck() { @@ -140,24 +140,24 @@ _quotacheck() _init_completion -s || return case $prev in - -F|--format) + -F | --format) _quota_formats return ;; - -h|--help|-V|--version) + -h | --help | -V | --version) return ;; esac $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _quota_parse_help "$1" else _filesystems fi } && -complete -F _quotacheck -o default quotacheck repquota + complete -F _quotacheck -o default quotacheck repquota _quotaon() { @@ -165,27 +165,27 @@ _quotaon() _init_completion -s || return case $prev in - -F|--format) + -F | --format) _quota_formats return ;; - -x|--xfs-command) - COMPREPLY=( $(compgen -W 'delete enforce' -- "$cur") ) + -x | --xfs-command) + COMPREPLY=($(compgen -W 'delete enforce' -- "$cur")) return ;; - -h|--help|-V|--version) + -h | --help | -V | --version) return ;; esac $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _quota_parse_help "$1" else _filesystems fi } && -complete -F _quotaon -o default quotaon quotaoff + complete -F _quotaon -o default quotaon quotaoff # ex: filetype=sh diff --git a/completions/radvdump b/completions/radvdump index 469c8f12..850628fd 100644 --- a/completions/radvdump +++ b/completions/radvdump @@ -6,17 +6,17 @@ _radvdump() _init_completion || return case $prev in - -h|--help|-v|--version) + -h | --help | -v | --version) return ;; - -d|--debug) - COMPREPLY=( $(compgen -W '{1..4}' -- "$cur") ) + -d | --debug) + COMPREPLY=($(compgen -W '{1..4}' -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) } && -complete -F _radvdump radvdump + complete -F _radvdump radvdump # ex: filetype=sh diff --git a/completions/rcs b/completions/rcs index cfad0211..c04d89d2 100644 --- a/completions/rcs +++ b/completions/rcs @@ -11,26 +11,26 @@ _rcs() dir=${cur%/*} # deal with relative directory - [[ $file == $dir ]] && dir=. + [[ $file == "$dir" ]] && dir=. - COMPREPLY=( $(compgen -f -- "$dir/RCS/$file") ) + COMPREPLY=($(compgen -f -- "$dir/RCS/$file")) - for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do - file=${COMPREPLY[$i]##*/} - dir=${COMPREPLY[$i]%RCS/*} - COMPREPLY[$i]=$dir$file + for i in ${!COMPREPLY[*]}; do + file=${COMPREPLY[i]##*/} + dir=${COMPREPLY[i]%RCS/*} + COMPREPLY[i]=$dir$file done - COMPREPLY+=( $(compgen -G "$dir/$file*,v") ) + COMPREPLY+=($(compgen -G "$dir/$file*,v")) - for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do - COMPREPLY[$i]=${COMPREPLY[$i]%,v} + for i in ${!COMPREPLY[*]}; do + COMPREPLY[i]=${COMPREPLY[i]%,v} done # default to files if nothing returned and we're checking in. # otherwise, default to directories [[ ${#COMPREPLY[@]} -eq 0 && $1 == *ci ]] && _filedir || _filedir -d } && -complete -F _rcs ci co rlog rcs rcsdiff + complete -F _rcs ci co rlog rcs rcsdiff # ex: filetype=sh diff --git a/completions/rdesktop b/completions/rdesktop index 5226a123..54c1ae66 100644 --- a/completions/rdesktop +++ b/completions/rdesktop @@ -7,34 +7,34 @@ _rdesktop() case $prev in -*k) - COMPREPLY=( $(command ls \ - /usr/share/rdesktop/keymaps 2>/dev/null | \ - command grep -E -v '(common|modifiers)') ) - COMPREPLY+=( $(command ls $HOME/.rdesktop/keymaps 2>/dev/null) ) - COMPREPLY+=( $(command ls ./keymaps 2>/dev/null) ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY=($(command ls \ + /usr/share/rdesktop/keymaps 2>/dev/null | + command grep -E -v '(common|modifiers)')) + COMPREPLY+=($(command ls $HOME/.rdesktop/keymaps 2>/dev/null)) + COMPREPLY+=($(command ls ./keymaps 2>/dev/null)) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) return ;; -*a) - COMPREPLY=( $(compgen -W '8 15 16 24' -- "$cur") ) + COMPREPLY=($(compgen -W '8 15 16 24' -- "$cur")) return ;; -*x) - COMPREPLY=( $(compgen -W 'broadband modem lan' -- "$cur") ) + COMPREPLY=($(compgen -W 'broadband modem lan' -- "$cur")) return ;; -*r) case $cur in sound:*) - COMPREPLY=( $(compgen -W 'local off remote' \ - -- "${cur#sound:}") ) - ;; - *:*) + COMPREPLY=($(compgen -W 'local off remote' \ + -- "${cur#sound:}")) ;; + *:*) ;; + *) - COMPREPLY=( $(compgen -W 'comport: disk: lptport: - printer: sound: lspci scard' -- "$cur") ) - [[ $COMPREPLY == *: ]] && compopt -o nospace + COMPREPLY=($(compgen -W 'comport: disk: lptport: + printer: sound: lspci scard' -- "$cur")) + [[ ${COMPREPLY-} == *: ]] && compopt -o nospace ;; esac return @@ -44,14 +44,14 @@ _rdesktop() ;; esac - if [[ "$cur" == -* ]]; then - local opts=( $(_parse_help "$1") ) - COMPREPLY=( $(compgen -W '${opts[@]%:}' -- "$cur") ) + if [[ $cur == -* ]]; then + local opts=($(_parse_help "$1")) + COMPREPLY=($(compgen -W '${opts[@]%:}' -- "$cur")) else _known_hosts_real -- "$cur" fi } && -complete -F _rdesktop rdesktop + complete -F _rdesktop rdesktop # ex: filetype=sh diff --git a/completions/remove_members b/completions/remove_members index c22286f1..db7ad0bc 100644 --- a/completions/remove_members +++ b/completions/remove_members @@ -6,7 +6,7 @@ _remove_members() _init_completion -s || return case $prev in - -f|--file) + -f | --file) _filedir return ;; @@ -14,14 +14,14 @@ _remove_members() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--file --all --fromall --nouserack - --noadminack --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--file --all --fromall --nouserack + --noadminack --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _remove_members remove_members + complete -F _remove_members remove_members # ex: filetype=sh diff --git a/completions/removepkg b/completions/removepkg index 77f414f6..a56beb07 100644 --- a/completions/removepkg +++ b/completions/removepkg @@ -4,20 +4,22 @@ _removepkg() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-copy -keep -preserve -warn' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-copy -keep -preserve -warn' -- "$cur")) return fi - if [[ "$cur" == */* ]]; then + if [[ $cur == */* ]]; then _filedir return fi local root=${ROOT:-/} - COMPREPLY=( $(cd "$root/var/log/packages" 2>/dev/null || return 1; \ - compgen -f -- "$cur") ) + COMPREPLY=($( + cd "$root/var/log/packages" 2>/dev/null || return 1 + compgen -f -- "$cur" + )) } && -complete -F _removepkg removepkg + complete -F _removepkg removepkg # ex: filetype=sh diff --git a/completions/reportbug b/completions/reportbug index f5eaadf3..69b12e98 100644 --- a/completions/reportbug +++ b/completions/reportbug @@ -6,65 +6,64 @@ _reportbug() _init_completion -s || return case $prev in - --class|--header|--pseudo-header|--mirror|--list-cc|--subject|\ - --http_proxy|--proxy|--email|--realname|--smtpuser|--smtppasswd|\ - --replyto|--reply-to|--justification|--package-version|--body|\ - --body-file|--timeout|--max-attachment-size|--envelope-from|\ - -!(-*)[CHPsjV]) + --class | --header | --pseudo-header | --mirror | --list-cc | --subject | \ + --http_proxy | --proxy | --email | --realname | --smtpuser | --smtppasswd | \ + --replyto | --reply-to | --justification | --package-version | --body | \ + --body-file | --timeout | --max-attachment-size | --envelope-from | \ + -!(-*)[CHPsjV]) return ;; - --filename|--include|--mta|--output|--attach|-[fioA]) + --filename | --include | --mta | --output | --attach | -[fioA]) _filedir return ;; - --keyid|-!(-*)K) - COMPREPLY=( $(compgen -W '$(IFS=: ; \ + --keyid | -!(-*)K) + COMPREPLY=($(compgen -W '$(IFS=: ; \ gpg --list-keys --with-colons 2>/dev/null \ | while read -ra row ; do [[ "${row[0]}" == [ps]ub && ${row[11]} == *s* ]] && \ printf "%s\n" "${row[4]}" - done)' -- "$cur") ) + done)' -- "$cur")) return ;; - --bts|-!(-*)B) - COMPREPLY=( $(compgen -W "debian guug kde mandrake help" -- \ - "$cur") ) + --bts | -!(-*)B) + COMPREPLY=($(compgen -W "debian guug kde mandrake help" -- \ + "$cur")) return ;; - --editor|--mua|--mbox-reader-cmd|-!(-*)e) - words=( words[0] "$cur" ) - cword=1 - _command + --editor | --mua | --mbox-reader-cmd | -!(-*)e) + compopt -o filenames + COMPREPLY=($(compgen -c -- "$cur")) return ;; --mode) - COMPREPLY=( $(compgen -W "novice standard expert" -- "$cur") ) + COMPREPLY=($(compgen -W "novice standard expert" -- "$cur")) return ;; - --severity|-!(-*)S) - COMPREPLY=( $(compgen -W "grave serious important normal minor - wishlist" -- "$cur") ) + --severity | -!(-*)S) + COMPREPLY=($(compgen -W "grave serious important normal minor + wishlist" -- "$cur")) return ;; - --ui|--interface|-!(-*)u) - COMPREPLY=( $(compgen -W "newt text gnome" -- "$cur") ) + --ui | --interface | -!(-*)u) + COMPREPLY=($(compgen -W "newt text gnome" -- "$cur")) return ;; - --type|-!(-*)t) - COMPREPLY=( $(compgen -W "gnats debbugs" -- "$cur") ) + --type | -!(-*)t) + COMPREPLY=($(compgen -W "gnats debbugs" -- "$cur")) return ;; - --tag|-!(-*)T) - COMPREPLY=( $(compgen -W "none woody potato sarge sarge-ignore + --tag | -!(-*)T) + COMPREPLY=($(compgen -W "none woody potato sarge sarge-ignore etch etch-ignore lenny lenny-ignore sid experimental confirmed d-i fixed fixed-in-experimental fixed-upstream help l10n moreinfo patch pending security unreproducible upstream wontfix - ipv6 lfs" -- "$cur") ) + ipv6 lfs" -- "$cur")) return ;; --from-buildd) - COMPREPLY=( $(compgen -S "_" -W '$(apt-cache dumpavail | \ - command grep "^Source: $cur" | sort -u | cut -f2 -d" ")') ) + COMPREPLY=($(compgen -S "_" -W '$(apt-cache dumpavail | \ + command grep "^Source: $cur" | sort -u | cut -f2 -d" ")')) return ;; --smtphost) @@ -80,18 +79,18 @@ _reportbug() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == -*= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == -*= ]] && compopt -o nospace return fi - COMPREPLY=( $(compgen -W 'wnpp boot-floppies kernel bugs.debian.org + COMPREPLY=($(compgen -W '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 $(apt-cache pkgnames 2>/dev/null)' -- "$cur") ) + www.debian.org $(_xfunc apt-cache _apt_cache_packages)' -- "$cur")) _filedir } && -complete -F _reportbug reportbug + complete -F _reportbug reportbug # ex: filetype=sh diff --git a/completions/resolvconf b/completions/resolvconf index b4659612..b407488c 100644 --- a/completions/resolvconf +++ b/completions/resolvconf @@ -6,16 +6,16 @@ _resolvconf() _init_completion || return case $prev in - -a|-d) + -a | -d) _available_interfaces return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-a -d -u' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-a -d -u' -- "$cur")) fi } && -complete -F _resolvconf resolvconf + complete -F _resolvconf resolvconf # ex: filetype=sh diff --git a/completions/ri b/completions/ri index 7d1e7cf9..9c34b27f 100644 --- a/completions/ri +++ b/completions/ri @@ -14,21 +14,21 @@ _ri_get_methods() regex=Class fi - COMPREPLY+=( \ + COMPREPLY+=( "$(ri "${classes[@]}" 2>/dev/null | ruby -ane \ - 'if /^'"$regex"' methods:/.../^------------------|^$/ and \ + 'if /^'"$regex"' methods:/.../^------------------|^$/ and \ /^ / then print $_.split(/, |,$/).grep(/^[^\[]*$/).join("\n"); \ - end' 2>/dev/null | sort -u)" ) + end' 2>/dev/null | sort -u)") else # older versions of ri didn't distinguish between class/module and # instance methods - COMPREPLY+=( \ + COMPREPLY+=( "$(ruby -W0 $ri_path "${classes[@]}" 2>/dev/null | ruby -ane \ - 'if /^-/.../^-/ and ! /^-/ and ! /^ +(class|module): / then \ + 'if /^-/.../^-/ and ! /^-/ and ! /^ +(class|module): / then \ print $_.split(/, |,$| +/).grep(/^[^\[]*$/).join("\n"); \ - end' | sort -u)" ) + end' | sort -u)") fi - COMPREPLY=( $(compgen $prefix -W '${COMPREPLY[@]}' -- $method) ) + COMPREPLY=($(compgen $prefix -W '${COMPREPLY[@]}' -- $method)) } # needs at least Ruby 1.8.0 in order to use -W0 @@ -38,14 +38,14 @@ _ri() _init_completion -s -n : || return case $prev in - --help|--width|-!(-*)[hw]) + --help | --width | -!(-*)[hw]) return ;; - --format|-!(-*)f) - COMPREPLY=( $(compgen -W 'ansi bs html rdoc' -- "$cur") ) + --format | -!(-*)f) + COMPREPLY=($(compgen -W 'ansi bs html rdoc' -- "$cur")) return ;; - --doc-dir|-!(-*)d) + --doc-dir | -!(-*)d) _filedir -d return ;; @@ -57,9 +57,9 @@ _ri() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -71,17 +71,17 @@ _ri() # -W0 is required here to stop warnings from older versions of ri # from being captured when used with Ruby 1.8.1 and later ri_version="$(ruby -W0 $ri_path -v 2>&1)" || ri_version=integrated - [[ $ri_version != ${ri_version%200*} ]] && ri_version=integrated + [[ $ri_version != "${ri_version%200*}" ]] && ri_version=integrated [[ $ri_version =~ ri[[:space:]]v?([0-9]+) ]] && ri_major=${BASH_REMATCH[1]} # need to also split on commas IFS=$', \n\t' - if [[ "$cur" == [A-Z]*[#.]* ]]; then - [[ "$cur" == *#* ]] && separator=# || separator=. + if [[ $cur == [A-Z]*[#.]* ]]; then + [[ $cur == *#* ]] && separator=# || separator=. # we're completing on class and method class=${cur%$separator*} method=${cur#*$separator} - classes=( $class ) + classes=($class) prefix="-P $class$separator" _ri_get_methods return @@ -89,24 +89,24 @@ _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) ) + classes=($(ri -c 2>/dev/null | ruby -ne 'if /^\s*$/..$stdin.eof then \ + if /^ +[A-Z]/ then print; end; end' 2>/dev/null)) elif [[ $ri_major && $ri_major -ge 3 ]]; then - classes=( $(ri -l 2>/dev/null) ) + classes=($(ri -l 2>/dev/null)) elif [[ $ri_version == "ri 1.8a" ]]; then - classes=( $(ruby -W0 $ri_path | \ + classes=($(ruby -W0 $ri_path | ruby -ne 'if /^'"'"'ri'"'"' has/..$stdin.eof then \ - if /^ .*[A-Z]/ then print; end; end') ) + if /^ .*[A-Z]/ then print; end; end')) else - classes=( $(ruby -W0 $ri_path | \ + classes=($(ruby -W0 $ri_path | ruby -ne 'if /^I have/..$stdin.eof then \ - if /^ .*[A-Z]/ then print; end; end') ) + if /^ .*[A-Z]/ then print; end; end')) fi - COMPREPLY=( $(compgen -W '${classes[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${classes[@]}' -- "$cur")) __ltrim_colon_completions "$cur" - if [[ "$cur" == [A-Z]* ]]; then + if [[ $cur == [A-Z]* ]]; then # we're completing on class or module alone return fi @@ -115,6 +115,6 @@ _ri() method=$cur _ri_get_methods } && -complete -F _ri ri + complete -F _ri ri # ex: filetype=sh diff --git a/completions/rmlist b/completions/rmlist index d096352c..0cc473a9 100644 --- a/completions/rmlist +++ b/completions/rmlist @@ -5,13 +5,13 @@ _rmlist() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--archives --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--archives --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _rmlist rmlist + complete -F _rmlist rmlist # ex: filetype=sh diff --git a/completions/rmmod b/completions/rmmod index 12f2334e..7ec29e6c 100644 --- a/completions/rmmod +++ b/completions/rmmod @@ -7,18 +7,18 @@ _rmmod() _init_completion || return case $prev in - -h|--help|-V|--version) + -h | --help | -V | --version) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _installed_modules "$cur" } && -complete -F _rmmod rmmod + complete -F _rmmod rmmod # ex: filetype=sh diff --git a/completions/route b/completions/route index a7c06d6d..f9b31964 100644 --- a/completions/route +++ b/completions/route @@ -17,14 +17,14 @@ _route() for opt in add del -host -net netmask metric mss window irtt reject mod \ dyn reinstate dev default gw; do found=false - for (( i=1; i < ${#words[@]}-1; i++ )); do - [[ ${words[i]} == $opt ]] && found=true && break + for ((i = 1; i < ${#words[@]} - 1; i++)); do + [[ ${words[i]} == "$opt" ]] && found=true && break done - $found || COMPREPLY[${#COMPREPLY[@]}]="$opt" + $found || COMPREPLY+=("$opt") done - COMPREPLY=( $(compgen -W '"${COMPREPLY[@]}"' -- "$cur") ) + COMPREPLY=($(compgen -W '"${COMPREPLY[@]}"' -- "$cur")) } && -complete -F _route route + complete -F _route route # ex: filetype=sh diff --git a/completions/rpcdebug b/completions/rpcdebug index ce4f9372..6e2b88c5 100644 --- a/completions/rpcdebug +++ b/completions/rpcdebug @@ -2,18 +2,18 @@ _rpcdebug_flags() { - local i module - for (( i=0; i < ${#words[@]}; i++ )); do + for ((i = 1; i < ${#words[@]}; i++)); do if [[ ${words[i]} == -m ]]; then - module=${words[i+1]} + module=${words[i + 1]} + break fi done if [[ -n $module ]]; then - COMPREPLY=( $(compgen -W "$(rpcdebug -vh 2>&1 | \ - command sed -ne 's/^'$module'[[:space:]]\{1,\}//p')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(rpcdebug -vh 2>&1 | + command sed -ne 's/^'$module'[[:space:]]\{1,\}//p')" -- "$cur")) fi } @@ -32,15 +32,15 @@ _rpcdebug() return ;; -*m) - COMPREPLY=( $(compgen -W 'rpc nfs nfsd nlm' -- "$cur") ) + COMPREPLY=($(compgen -W 'rpc nfs nfsd nlm' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" -h) -s -c' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h) -s -c' -- "$cur")) fi } && -complete -F _rpcdebug rpcdebug + complete -F _rpcdebug rpcdebug # ex: filetype=sh diff --git a/completions/rpm b/completions/rpm index b797e9fb..8299a37a 100644 --- a/completions/rpm +++ b/completions/rpm @@ -7,38 +7,38 @@ _rpm_installed_packages() if [[ -r /var/log/rpmpkgs && \ /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then # using RHL 7.2 or later - this is quicker than querying the DB - COMPREPLY=( $(compgen -W "$(command sed -ne \ + COMPREPLY=($(compgen -W "$(command sed -ne \ 's|^\([^[:space:]]\{1,\}\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \ - /var/log/rpmpkgs)" -- "$cur") ) - elif type rpmqpack &>/dev/null ; then + /var/log/rpmpkgs)" -- "$cur")) + elif type rpmqpack &>/dev/null; then # SUSE's rpmqpack is faster than rpm -qa - COMPREPLY=( $(compgen -W '$(rpmqpack)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(rpmqpack)' -- "$cur")) else - COMPREPLY=( $(${1:-rpm} -qa --nodigest --nosignature \ - --queryformat='%{NAME} ' "$cur*" 2>/dev/null) ) + COMPREPLY=($(${1:-rpm} -qa --nodigest --nosignature \ + --queryformat='%{NAME} ' "$cur*" 2>/dev/null)) fi } _rpm_groups() { local IFS=$'\n' - COMPREPLY=( $(compgen -W "$(${1:-rpm} -qa --nodigest --nosignature \ - --queryformat='%{GROUP}\n' 2>/dev/null)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(${1:-rpm} -qa --nodigest --nosignature \ + --queryformat='%{GROUP}\n' 2>/dev/null)" -- "$cur")) } _rpm_macros() { # get a list of macros - COMPREPLY=( $(compgen -W "$(${1:-rpm} --showrc | command sed -ne \ + COMPREPLY=($(compgen -W "$(${1:-rpm} --showrc | command sed -ne \ 's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p')" \ - -- "$cur") ) + -- "$cur")) } _rpm_buildarchs() { - COMPREPLY=( $(compgen -W "$(${1:-rpm} --showrc | command sed -ne \ + COMPREPLY=($(compgen -W "$(${1:-rpm} --showrc | command sed -ne \ 's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p')" \ - -- "$cur") ) + -- "$cur")) } # rpm(8) completion @@ -48,35 +48,35 @@ _rpm() local cur prev words cword split _init_completion -s || return - if [[ $cword -eq 1 ]]; then + if ((cword == 1)); then # first parameter on line case $cur in --*) - COMPREPLY=( $(compgen -W '--help --version --initdb + COMPREPLY=($(compgen -W '--help --version --initdb --checksig --addsign --delsign --rebuilddb --showrc --setperms --setugids --eval --install --upgrade --query --freshen --erase --verify --querytags --import' \ - -- "$cur") ) + -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W '-e -E -F -i -q -t -U -V' -- "$cur") ) + COMPREPLY=($(compgen -W '-e -E -F -i -q -t -U -V' -- "$cur")) ;; esac return fi case $prev in - --dbpath|--excludepath|--prefix|--relocate|--root|-!(-*)r) + --dbpath | --excludepath | --prefix | --relocate | --root | -!(-*)r) _filedir -d return ;; - --eval|-!(-*)E) + --eval | -!(-*)E) _rpm_macros $1 return ;; --pipe) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; --rcfile) @@ -88,28 +88,28 @@ _rpm() _filedir spec return ;; - --whatenhances|--whatprovides|--whatrecommends|--whatrequires|\ - --whatsuggests|--whatsupplements) - if [[ "$cur" == */* ]]; then + --whatenhances | --whatprovides | --whatrecommends | --whatrequires | \ + --whatsuggests | --whatsupplements) + if [[ $cur == */* ]]; then _filedir else # complete on capabilities local IFS=$'\n' fmt case $prev in - *enhances) fmt=ENHANCENAME ;; - *provides) fmt=PROVIDENAME ;; - *recommends) fmt=RECOMMENDNAME ;; - *requires) fmt=REQUIRENAME ;; - *suggests) fmt=SUGGESTNAME ;; - *supplements) fmt=SUPPLEMENTNAME ;; + *enhances) fmt="%{ENHANCENAME}" ;; + *provides) fmt="%{PROVIDENAME}" ;; + *recommends) fmt="%{RECOMMENDNAME}" ;; + *requires) fmt="%{REQUIRENAME}" ;; + *suggests) fmt="%{SUGGESTNAME}" ;; + *supplements) fmt="%{SUPPLEMENTNAME}" ;; esac - COMPREPLY=( $(compgen -W "$($1 -qa --nodigest --nosignature \ - --queryformat=\"%{$fmt}\\n\" 2>/dev/null | - command grep -vF '(none)')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 -qa --nodigest --nosignature \ + --queryformat=\"$fmt\\n\" 2>/dev/null | + command grep -vF '(none)')" -- "$cur")) fi return ;; - --define|--fileid|--hdrid|--pkgid|-!(-*)D) + --define | --fileid | --hdrid | --pkgid | -!(-*)D) # argument required but no completions available return ;; @@ -122,28 +122,28 @@ _rpm() --quiet --pipe --verbose" case ${words[1]} in - -[iFU]*|--install|--freshen|--upgrade) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$opts --percent --force --test + -[iFU]* | --install | --freshen | --upgrade) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W "$opts --percent --force --test --replacepkgs --replacefiles --root --excludedocs --includedocs --noscripts --ignorearch --dbpath --prefix= --ignoreos --nodeps --allfiles --ftpproxy --ftpport --justdb --httpproxy --httpport --noorder --relocate= --badreloc --notriggers --excludepath= --ignoresize --oldpackage --queryformat --repackage - --nosuggests" -- "$cur") ) + --nosuggests" -- "$cur")) else _filedir '[rs]pm' fi ;; - -e|--erase) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$opts --allmatches --noscripts - --notriggers --nodeps --test --repackage" -- "$cur") ) + -e | --erase) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W "$opts --allmatches --noscripts + --notriggers --nodeps --test --repackage" -- "$cur")) else _rpm_installed_packages $1 fi ;; - -q*|--query) + -q* | --query) # options common to all query types opts+=" --changelog --configfiles --conflicts --docfiles --dump --enhances --filesbypkg --filecaps --fileclass --filecolor @@ -152,85 +152,85 @@ _rpm() --scripts --suggests --triggers --xml --recommends --supplements --filetriggers --licensefiles" - if [[ "${words[*]}" == *\ -@(*([^ -])f|-file )* ]]; then + if [[ ${words[*]} == *\ -@(*([^ -])f|-file )* ]]; then # -qf completion - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$opts --dbpath --fscontext - --last --root --state" -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W "$opts --dbpath --fscontext + --last --root --state" -- "$cur")) else _filedir fi - elif [[ "${words[*]}" == *\ -@(*([^ -])g|-group )* ]]; then + elif [[ ${words[*]} == *\ -@(*([^ -])g|-group )* ]]; then # -qg completion _rpm_groups $1 - elif [[ "${words[*]}" == *\ -@(*([^ -])p|-package )* ]]; then + elif [[ ${words[*]} == *\ -@(*([^ -])p|-package )* ]]; then # -qp; uninstalled package completion - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$opts --ftpport --ftpproxy - --httpport --httpproxy --nomanifest" -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W "$opts --ftpport --ftpproxy + --httpport --httpproxy --nomanifest" -- "$cur")) else _filedir '[rs]pm' fi else # -q; installed package completion - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$opts --all --file --fileid + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W "$opts --all --file --fileid --dbpath --fscontext --ftswalk --group --hdrid --last --package --pkgid --root= --specfile --state --triggeredby --whatenhances --whatprovides --whatrecommends --whatrequires --whatsuggests --whatsupplements" \ - -- "$cur") ) - elif [[ "${words[*]}" != *\ -@(*([^ -])a|-all )* ]]; then + -- "$cur")) + elif [[ ${words[*]} != *\ -@(*([^ -])a|-all )* ]]; then _rpm_installed_packages $1 fi fi ;; - -K*|--checksig) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$opts --nopgp --nogpg --nomd5" \ - -- "$cur") ) + -K* | --checksig) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W "$opts --nopgp --nogpg --nomd5" \ + -- "$cur")) else _filedir '[rs]pm' fi ;; - -[Vy]*|--verify) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$opts --root= --dbpath --nodeps + -[Vy]* | --verify) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W "$opts --root= --dbpath --nodeps --nogroup --nolinkto --nomode --nomtime --nordev --nouser --nofiles --noscripts --nomd5 --querytags --specfile --whatenhances --whatprovides --whatrecommends --whatrequires --whatsuggests --whatsupplements" \ - -- "$cur") ) + -- "$cur")) # check whether we're doing file completion - elif [[ "${words[*]}" == *\ -@(*([^ -])f|-file )* ]]; then + elif [[ ${words[*]} == *\ -@(*([^ -])f|-file )* ]]; then _filedir - elif [[ "${words[*]}" == *\ -@(*([^ -])g|-group )* ]]; then + elif [[ ${words[*]} == *\ -@(*([^ -])g|-group )* ]]; then _rpm_groups $1 - elif [[ "${words[*]}" == *\ -@(*([^ -])p|-package )* ]]; then + elif [[ ${words[*]} == *\ -@(*([^ -])p|-package )* ]]; then _filedir '[rs]pm' else _rpm_installed_packages $1 fi ;; - --resign|--addsign|--delsign) + --resign | --addsign | --delsign) _filedir '[rs]pm' ;; - --setperms|--setgids) + --setperms | --setgids) _rpm_installed_packages $1 ;; - --import|--dbpath|--root) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--import --dbpath --root=' \ - -- "$cur") ) + --import | --dbpath | --root) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--import --dbpath --root=' \ + -- "$cur")) else _filedir fi ;; esac - [[ $COMPREPLY == *= ]] && compopt -o nospace + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _rpm rpm + complete -F _rpm rpm _rpmbuild() { @@ -238,33 +238,33 @@ _rpmbuild() _init_completion -s || return local rpm="${1%build*}" - [[ $rpm == $1 ]] || ! type $rpm &>/dev/null && rpm= + [[ $rpm == "$1" ]] || ! type $rpm &>/dev/null && rpm= case $prev in - --buildroot|--root|--dbpath|-!(-*)r) + --buildroot | --root | --dbpath | -!(-*)r) _filedir -d return ;; --target) - _rpm_buildarchs + _rpm_buildarchs $rpm return ;; - --eval|-!(-*)E) + --eval | -!(-*)E) _rpm_macros $rpm return ;; - --macros|--rcfile) + --macros | --rcfile) _filedir return ;; --buildpolicy) local cfgdir=$($rpm --eval '%{_rpmconfigdir}' 2>/dev/null) if [[ $cfgdir ]]; then - COMPREPLY=( $(compgen -W "$(command ls $cfgdir 2>/dev/null \ - | command sed -ne 's/^brp-//p')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(command ls $cfgdir 2>/dev/null | + command sed -ne 's/^brp-//p')" -- "$cur")) fi ;; - --define|--with|--without|-!(-*)D) + --define | --with | --without | -!(-*)D) return ;; esac @@ -272,8 +272,8 @@ _rpmbuild() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W "$(_parse_help "$1")" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -281,15 +281,15 @@ _rpmbuild() local word ext for word in "${words[@]}"; do case $word in - -b?|--clean|--nobuild) + -b? | --clean | --nobuild) ext=spec break ;; - -t?|--tarbuild) + -t? | --tarbuild) ext='@(t?(ar.)@([gx]z|bz?(2))|tar?(.@(lzma|Z)))' break ;; - --rebuild|--recompile) + --rebuild | --recompile) ext='@(?(no)src.r|s)pm' break ;; @@ -297,6 +297,6 @@ _rpmbuild() done [[ -n $ext ]] && _filedir $ext } && -complete -F _rpmbuild rpmbuild rpmbuild-md5 + complete -F _rpmbuild rpmbuild rpmbuild-md5 # ex: filetype=sh diff --git a/completions/rpm2tgz b/completions/rpm2tgz index da4b7e5e..5ddcfd59 100644 --- a/completions/rpm2tgz +++ b/completions/rpm2tgz @@ -5,13 +5,13 @@ _rpm2tgz() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-s -S -n -r -d -c' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-s -S -n -r -d -c' -- "$cur")) return fi _filedir "rpm" } && -complete -F _rpm2tgz rpm2tgz rpm2txz rpm2targz + complete -F _rpm2tgz rpm2tgz rpm2txz rpm2targz # ex: filetype=sh diff --git a/completions/rpmcheck b/completions/rpmcheck index f8577c4e..cf4ed958 100644 --- a/completions/rpmcheck +++ b/completions/rpmcheck @@ -12,13 +12,13 @@ _rpmcheck() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-explain -failures -successes -dump - -dump-all -base -help -compressed-input' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-explain -failures -successes -dump + -dump-all -base -help -compressed-input' -- "$cur")) else _filedir fi } && -complete -F _rpmcheck rpmcheck + complete -F _rpmcheck rpmcheck # ex: filetype=sh diff --git a/completions/rrdtool b/completions/rrdtool index c8214a49..dcb9ce67 100644 --- a/completions/rrdtool +++ b/completions/rrdtool @@ -1,17 +1,17 @@ # bash completion for rrdtool -*- shell-script -*- -_rrdtool () +_rrdtool() { local cur prev words cword _init_completion || return - if [[ ${#words[@]} -eq 2 ]]; then - COMPREPLY=( $(compgen -W 'create update updatev graph dump restore - last lastupdate first info fetch tune resize xport' -- "$cur") ) + if ((${#words[@]} == 2)); then + COMPREPLY=($(compgen -W 'create update updatev graph dump restore + last lastupdate first info fetch tune resize xport' -- "$cur")) else _filedir rrd fi } && -complete -F _rrdtool rrdtool + complete -F _rrdtool rrdtool # ex: filetype=sh diff --git a/completions/rsync b/completions/rsync index 03495244..0bf53898 100644 --- a/completions/rsync +++ b/completions/rsync @@ -6,26 +6,26 @@ _rsync() _init_completion -s -n : || return case $prev in - --config|--password-file|--include-from|--exclude-from|--files-from|\ - --log-file|--write-batch|--only-write-batch|--read-batch) + --config | --password-file | --include-from | --exclude-from | --files-from | \ + --log-file | --write-batch | --only-write-batch | --read-batch) compopt +o nospace _filedir return ;; - --temp-dir|--compare-dest|--backup-dir|--partial-dir|--copy-dest|\ - --link-dest|-!(-*)T) + --temp-dir | --compare-dest | --backup-dir | --partial-dir | --copy-dest | \ + --link-dest | -!(-*)T) compopt +o nospace _filedir -d return ;; - --rsh|-!(-*)e) + --rsh | -!(-*)e) compopt +o nospace - COMPREPLY=( $(compgen -W 'rsh ssh' -- "$cur") ) + COMPREPLY=($(compgen -W 'rsh ssh' -- "$cur")) return ;; --compress-level) compopt +o nospace - COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..9}' -- "$cur")) return ;; esac @@ -36,7 +36,7 @@ _rsync() case $cur in -*) - COMPREPLY=( $(compgen -W '--verbose --quiet --no-motd --checksum + COMPREPLY=($(compgen -W '--verbose --quiet --no-motd --checksum --archive --recursive --relative --no-implied-dirs --backup --backup-dir= --suffix= --update --inplace --append --append-verify --dirs --old-dirs --links --copy-links @@ -61,15 +61,15 @@ _rsync() --out-format= --log-file= --log-file-format= --password-file= --list-only --bwlimit= --write-batch= --only-write-batch= --read-batch= --protocol= --iconv= --ipv4 --ipv6 --version - --help --daemon --config= --no-detach' -- "$cur") ) - [[ $COMPREPLY == *= ]] || compopt +o nospace + --help --daemon --config= --no-detach' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] || compopt +o nospace ;; *:*) # find which remote shell is used local i shell=ssh - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -@(e|-rsh) ]]; then - shell=${words[i+1]} + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -@(e|-rsh) ]]; then + shell=${words[i + 1]} break fi done @@ -81,6 +81,6 @@ _rsync() ;; esac } && -complete -F _rsync -o nospace rsync + complete -F _rsync -o nospace rsync # ex: filetype=sh diff --git a/completions/sbcl b/completions/sbcl index a8dd5345..22a93e4a 100644 --- a/completions/sbcl +++ b/completions/sbcl @@ -8,14 +8,14 @@ _sbcl() _init_completion || return # completing an option (may or may not be separated by a space) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--core --noinform --help --version + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--core --noinform --help --version --sysinit --userinit --eval --noprint --disable-debugger - --end-runtime-options --end-toplevel-options ' -- "$cur") ) + --end-runtime-options --end-toplevel-options ' -- "$cur")) else _filedir fi } && -complete -F _sbcl sbcl sbcl-mt + complete -F _sbcl sbcl sbcl-mt # ex: filetype=sh diff --git a/completions/sbopkg b/completions/sbopkg index 1504a54e..16bd58f9 100644 --- a/completions/sbopkg +++ b/completions/sbopkg @@ -5,14 +5,14 @@ _sbopkg() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) - [[ $COMPREPLY ]] && return + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + [[ ${COMPREPLY-} ]] && return fi case "$prev" in -e) - COMPREPLY=( $(compgen -W 'ask continue stop' -- "$cur") ) + COMPREPLY=($(compgen -W 'ask continue stop' -- "$cur")) return ;; -f) @@ -24,12 +24,12 @@ _sbopkg() return ;; -V) - COMPREPLY=( $(compgen -W "? - $(sbopkg -V ? 2>&1 | cut -s -f1)" -- "$cur") ) + COMPREPLY=($(compgen -W "? + $(sbopkg -V '?' 2>&1 | cut -s -f1)" -- "$cur")) return ;; - -i|-b) - ;; + -i | -b) ;; + *) return ;; @@ -37,34 +37,37 @@ _sbopkg() local i config config="/etc/sbopkg/sbopkg.conf" - for (( i=${#words[@]}-1; i>0; i-- )); do - if [[ "${words[i]}" == -f ]]; then - config="${words[i+1]}" + for ((i = ${#words[@]} - 1; i > 0; i--)); do + if [[ ${words[i]} == -f ]]; then + config="${words[i + 1]}" __expand_tilde_by_ref config break fi done - [[ -r "$config" ]] || return + [[ -r $config ]] || return . $config - for (( i=1; i<${#words[@]}; i++ )); do + for ((i = 1; i < ${#words[@]}; i++)); do case "${words[i]}" in -V) - REPO_NAME="${words[i+1]%%/*}" - REPO_BRANCH="${words[i+1]#*/}" + REPO_NAME="${words[i + 1]%%/*}" + REPO_BRANCH="${words[i + 1]#*/}" ;; -d) - REPO_ROOT="${words[i+1]}" + REPO_ROOT="${words[i + 1]}" ;; esac done [[ -r $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ]] || return - COMPREPLY=( $(command sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\ + COMPREPLY=($(command sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}" \ $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT) - $(cd $QUEUEDIR; compgen -f -X "!*.sqf" -- "$cur") ) + $( + cd $QUEUEDIR + compgen -f -X "!*.sqf" -- "$cur" + )) } && -complete -F _sbopkg sbopkg + complete -F _sbopkg sbopkg # ex: filetype=sh diff --git a/completions/screen b/completions/screen index 17642863..651ca2c9 100644 --- a/completions/screen +++ b/completions/screen @@ -2,11 +2,11 @@ _screen_sessions() { - local sessions=( $(command screen -ls | command sed -ne \ - 's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p') ) + local sessions=($(command screen -ls | command sed -ne \ + 's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p')) if [[ $cur == +([0-9])?(.*) ]]; then # Complete sessions including pid prefixes - COMPREPLY=( $(compgen -W '${sessions[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${sessions[@]}' -- "$cur")) else # Create unique completions, dropping pids where possible local -A res @@ -15,106 +15,109 @@ _screen_sessions() res[${i/#+([0-9])./}]+=" $i" done for i in "${!res[@]}"; do - [[ ${res[$i]} == \ *\ * ]] && tmp+=" ${res[$i]}" || tmp+=" $i" + [[ ${res[i]} == \ *\ * ]] && tmp+=" ${res[i]}" || tmp+=" $i" done - COMPREPLY=( $(compgen -W '$tmp' -- "$cur") ) + COMPREPLY=($(compgen -W '$tmp' -- "$cur")) fi } && -_screen() -{ - local cur prev words cword - _init_completion || return + _screen() + { + local cur prev words cword + _init_completion || return - if ((cword == 1)); then - if [[ $cur == /dev* ]]; then - COMPREPLY=( $(compgen -W "$(shopt -s nullglob; printf '%s\n' \ - /dev/serial/by-id/* /dev/ttyUSB* /dev/ttyACM* 2>/dev/null)" \ - -- "$cur") ) - return + if ((cword == 1)); then + if [[ $cur == /dev* ]]; then + COMPREPLY=($(compgen -W "$( + shopt -s nullglob + printf '%s\n' \ + /dev/serial/by-id/* /dev/ttyUSB* /dev/ttyACM* 2>/dev/null + )" \ + -- "$cur")) + return + fi + if [[ $cur == //* ]]; then + COMPREPLY=($(compgen -W '//telnet' -- "$cur")) + return + fi fi - if [[ $cur == //* ]]; then - COMPREPLY=( $(compgen -W '//telnet' -- "$cur") ) - return + + case ${words[1]} in + /dev*) + if ((cword == 2)); then + COMPREPLY=($(compgen -W '110 300 600 1200 2400 4800 9600 \ + 14400 19200 38400 57600 115200 128000 256000' -- "$cur")) + # TODO more, comma separated options + fi + return + ;; + //telnet) + ((cword == 2)) && _known_hosts_real -- "$cur" + return + ;; + esac + + if ((cword > 2)); then + case ${words[cword - 2]} in + -*[dD]) + _screen_sessions + return + ;; + esac fi - fi - case ${words[1]} in - /dev*) - if ((cword == 2)); then - COMPREPLY=( $(compgen -W '110 300 600 1200 2400 4800 9600 \ - 14400 19200 38400 57600 115200 128000 256000' -- "$cur") ) - # TODO more, comma separated options - fi - return - ;; - //telnet) - ((cword == 2)) && _known_hosts_real -- "$cur" + local i + for ((i = 1; i <= cword; i++)); do + case ${words[i]} in + -*[rRdDxscTehpSt]) + ((i++)) + continue + ;; + -*) + continue + ;; + esac + + _command_offset $i return - ;; - esac + done - if ((cword > 2)); then - case ${words[cword-2]} in + case $prev in + -*[rR]) + # list detached + _screen_sessions 'Detached' + return + ;; -*[dD]) + # list attached + _screen_sessions 'Attached' + return + ;; + -*x) + # list both _screen_sessions return ;; - esac - fi - - local i - for (( i=1; i <= cword; i++ )); do - case ${words[i]} in - -*[rRdDxscTehpSt]) - (( i++ )) - continue + -*s) + _shells + return ;; - -*) - continue + -*c) + _filedir + return + ;; + -T) + _terms + return + ;; + -*[ehpSt]) + return ;; esac - _command_offset $i - return - done - - case $prev in - -*[rR]) - # list detached - _screen_sessions 'Detached' - return - ;; - -*[dD]) - # list attached - _screen_sessions 'Attached' - return - ;; - -*x) - # list both - _screen_sessions - return - ;; - -*s) - _shells - return - ;; - -*c) - _filedir - return - ;; - -T) - _terms - return - ;; - -*[ehpSt]) - return - ;; - esac - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - fi -} && -complete -F _screen screen + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + fi + } && + complete -F _screen screen # ex: filetype=sh diff --git a/completions/scrub b/completions/scrub index 7fca6077..bbb37be4 100644 --- a/completions/scrub +++ b/completions/scrub @@ -6,16 +6,16 @@ _scrub() _init_completion -s || return case $prev in - --version|--help|--blocksize|--device-size|--dirent|-!(-*)[vhbsD]) + --version | --help | --blocksize | --device-size | --dirent | -!(-*)[vhbsD]) return ;; - --pattern|-!(-*)p) - COMPREPLY=( $(compgen -W '$("$1" --help 2>&1 | + --pattern | -!(-*)p) + COMPREPLY=($(compgen -W '$("$1" --help 2>&1 | awk "/^Available/{flag=1;next}/^ /&&flag{print \$1}")' \ - -- "$cur") ) + -- "$cur")) return ;; - --freespace|-!(-*)X) + --freespace | -!(-*)X) _filedir -d return ;; @@ -24,13 +24,13 @@ _scrub() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _scrub scrub + complete -F _scrub scrub # ex: filetype=sh diff --git a/completions/secret-tool b/completions/secret-tool new file mode 100644 index 00000000..5462fc06 --- /dev/null +++ b/completions/secret-tool @@ -0,0 +1,50 @@ +# bash completion for secret-tool(1) -*- shell-script -*- + +_secret_tool() +{ + local cur prev words cword split + _init_completion -s || return + + $split && return + + local -i i + local mode word + for i in ${!words[*]}; do + if [[ $i -gt 0 && ${words[i]} != -* ]]; then + ((i != cword)) && mode=${words[i]} + break + fi + done + if [[ ! -v mode ]]; then + local -a modes + modes=($("$1" nonexistent-mode 2>&1 | + while read -r first second third rest; do + if [[ $first == "${1##*/}" ]]; then + printf "%s\n" "$second" + elif [[ $first == usage: && $second == "${1##*/}" ]]; then + printf "%s\n" "$third" + fi + done)) + COMPREPLY=($(compgen -W '${modes[@]}' -- "$cur")) + return + fi + + case $mode in + store) + if [[ ${words[*]} != *\ --label[\ =]* ]]; then + COMPREPLY=($(compgen -W "--label=" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace + fi + ;; + search) + local -A opts=([--all]="" [--unlock]="") + for word in "${words[@]:2}"; do + [[ $word ]] && unset opts["$word"] + done + COMPREPLY=($(compgen -W '${opts[@]}' -- "$cur")) + ;; + esac +} && + complete -F _secret_tool secret-tool + +# ex: filetype=sh diff --git a/completions/sh b/completions/sh index 93f00952..5624ffa3 100644 --- a/completions/sh +++ b/completions/sh @@ -9,28 +9,28 @@ _sh() -c) return ;; - -o|+o) - COMPREPLY=( $(compgen -W 'allexport errexit ignoreeof monitor + -o | +o) + COMPREPLY=($(compgen -W 'allexport errexit ignoreeof monitor noclobber noglob noexec nolog notify nounset verbose vi - xtrace' -- "$cur") ) + xtrace' -- "$cur")) return ;; esac local opts="-a -b -C -e -f -h -i -m -n -o -u -v -x" - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$opts -c -s" -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W "$opts -c -s" -- "$cur")) return - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W "${opts//-/+}" -- "$cur") ) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W "${opts//-/+}" -- "$cur")) return fi local args ext= _count_args "" "@(-c|[-+]o)" - [[ $args -eq 1 ]] && ext=sh + ((args == 1)) && ext="sh" _filedir $ext } && -complete -F _sh sh + complete -F _sh sh # ex: filetype=sh diff --git a/completions/shellcheck b/completions/shellcheck index 4a40c8f9..6421d7b6 100644 --- a/completions/shellcheck +++ b/completions/shellcheck @@ -2,9 +2,9 @@ _shellcheck_optarg() { - local args=$("$1" --help 2>&1 | \ + local args=$("$1" --help 2>&1 | command sed -e 's/,/ /g' -ne 's/^.*'$2'\>.*(\([^)]*\)).*/\1/p') - COMPREPLY+=( $(compgen -W '$args' -- "$cur") ) + COMPREPLY+=($(compgen -W '$args' -- "$cur")) } _shellcheck() @@ -13,51 +13,51 @@ _shellcheck() _init_completion -s || return case $prev in - --version|-!(-*)V*) + --version | -!(-*)V*) return ;; - --exclude|--include|-!(-*)[ei]) + --exclude | --include | -!(-*)[ei]) return ;; - --format|-!(-*)f) - local args=$("$1" --format=nonexistent-format /dev/null 2>&1 | \ - command sed -ne '/^Supported formats/,//p' | \ + --format | -!(-*)f) + local args=$("$1" --format=nonexistent-format /dev/null 2>&1 | + command sed -ne '/^Supported formats/,//p' | command sed -ne '/^[[:space:]]/p') - COMPREPLY=( $(compgen -W '$args' -- "$cur") ) + COMPREPLY=($(compgen -W '$args' -- "$cur")) return ;; - --color|-!(-*)C) + --color | -!(-*)C) _shellcheck_optarg "$1" --color return ;; - --shell|-!(-*)s) + --shell | -!(-*)s) _shellcheck_optarg "$1" --shell return ;; - --enable|-!(-*)o) - COMPREPLY=( $(compgen -W 'all' -- "$cur") ) # TODO others? + --enable | -!(-*)o) + COMPREPLY=($(compgen -W 'all' -- "$cur")) # TODO others? return ;; - --source-path|-!(-*)P) + --source-path | -!(-*)P) _filedir -d - COMPREPLY+=( $(compgen -W 'SCRIPTDIR' -- "$cur") ) + COMPREPLY+=($(compgen -W 'SCRIPTDIR' -- "$cur")) return ;; - --wiki-link-count|-!(-*)W) + --wiki-link-count | -!(-*)W) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _shellcheck shellcheck + complete -F _shellcheck shellcheck # ex: filetype=sh diff --git a/completions/sitecopy b/completions/sitecopy index dae0548d..85156875 100644 --- a/completions/sitecopy +++ b/completions/sitecopy @@ -9,17 +9,17 @@ _sitecopy() _init_completion -s || return case $prev in - --debug|-!(-*)d) - COMPREPLY=( $(compgen -W "socket files rcfile ftp http httpbody - rsh sftp xml xmlparse cleartext" -- "$cur") ) + --debug | -!(-*)d) + COMPREPLY=($(compgen -W "socket files rcfile ftp http httpbody + rsh sftp xml xmlparse cleartext" -- "$cur")) compopt -o nospace return ;; - --logfile|--rcfile|-!(-*)[gr]) + --logfile | --rcfile | -!(-*)[gr]) _filedir return ;; - --storepath|-!(-*)p) + --storepath | -!(-*)p) _filedir -d return ;; @@ -27,24 +27,24 @@ _sitecopy() case $cur in --*) - COMPREPLY=( $(compgen -W "$(_parse_help $1)" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W "$(_parse_help $1)" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return ;; # only complete long options -) compopt -o nospace - COMPREPLY=( -- ) + COMPREPLY=(--) return ;; esac if [[ -r ~/.sitecopyrc ]]; then - COMPREPLY=( $(compgen -W "$($1 -v | \ - command sed -n '/^Site:/s/Site: //p')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 -v | + command sed -n '/^Site:/s/Site: //p')" -- "$cur")) fi } && -complete -F _sitecopy -o default sitecopy + complete -F _sitecopy -o default sitecopy # ex: filetype=sh diff --git a/completions/slackpkg b/completions/slackpkg index a1d500dc..1d879280 100644 --- a/completions/slackpkg +++ b/completions/slackpkg @@ -7,23 +7,23 @@ _slackpkg() _init_completion -n = || return local split=false - if [[ "$cur" == -?*=* ]]; then + if [[ $cur == -?*=* ]]; then prev="${cur%%?(\\)=*}" cur="${cur#*=}" split=true fi case "$prev" in - -delall|-checkmd5|-checkgpg|-checksize|-postinst|-onoff|-download_all|\ - -dialog|-batch|-only_new_dotnew|-use_includes|-spinning) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + -delall | -checkmd5 | -checkgpg | -checksize | -postinst | -onoff | -download_all | \ + -dialog | -batch | -only_new_dotnew | -use_includes | -spinning) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; -default_answer) - COMPREPLY=( $(compgen -W 'yes no' -- "$cur") ) + COMPREPLY=($(compgen -W 'yes no' -- "$cur")) return ;; - -dialog_maxargs|-mirror) + -dialog_maxargs | -mirror) # argument required but no completions available return ;; @@ -31,77 +31,82 @@ _slackpkg() $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then compopt -o nospace - COMPREPLY=( $(compgen -W '-delall= -checkmd5= -checkgpg= + COMPREPLY=($(compgen -W '-delall= -checkmd5= -checkgpg= -checksize= -postinst= -onoff= -download_all= -dialog= -dialog_maxargs= -batch= -only_new_dotnew= -use_includes= - -spinning= -default_answer= -mirror=' -- "$cur") ) + -spinning= -default_answer= -mirror=' -- "$cur")) return fi local confdir="/etc/slackpkg" local config="$confdir/slackpkg.conf" - [[ -r "$config" ]] || return + [[ -r $config ]] || return . "$config" local i action - for (( i=1; i<${#words[@]}; i++ )); do - if [[ "${words[i]}" != -* ]]; then + for ((i = 1; i < ${#words[@]}; i++)); do + if [[ ${words[i]} != -* ]]; then action="${words[i]}" break fi done case "$action" in - generate-template|search|file-search) + generate-template | search | file-search) # argument required but no completions available return ;; - install-template|remove-template) + install-template | remove-template) if [[ -e $confdir/templates ]]; then - COMPREPLY=( $(cd "$confdir/templates"; \ - compgen -f -X "!*.template" -- "$cur") ) - COMPREPLY=( ${COMPREPLY[@]%.template} ) + COMPREPLY=($( + cd "$confdir/templates" + compgen -f -X "!*.template" -- "$cur" + )) + COMPREPLY=(${COMPREPLY[@]%.template}) fi return ;; remove) _filedir - COMPREPLY+=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x - xap xfce y' -- "$cur") ) - COMPREPLY+=( $(cd /var/log/packages; compgen -f -- "$cur") ) + COMPREPLY+=($(compgen -W 'a ap d e f k kde kdei l n t tcl x + xap xfce y' -- "$cur")) + COMPREPLY+=($( + cd /var/log/packages + compgen -f -- "$cur" + )) return ;; - install|reinstall|upgrade|blacklist|download) + install | reinstall | upgrade | blacklist | download) _filedir - COMPREPLY+=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x - xap xfce y' -- "$cur") ) - COMPREPLY+=( $(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null | \ - command grep "^$cur") ) + COMPREPLY+=($(compgen -W 'a ap d e f k kde kdei l n t tcl x + xap xfce y' -- "$cur")) + COMPREPLY+=($(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null | + command grep "^$cur")) return ;; info) - COMPREPLY=( $(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null | \ - command grep "^$cur") ) + COMPREPLY=($(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null | + command grep "^$cur")) return ;; update) # we should complete the same as the next `list` + "gpg" - COMPREPLY=( $(compgen -W 'gpg' -- "$cur") ) + COMPREPLY=($(compgen -W 'gpg' -- "$cur")) ;& *) - COMPREPLY+=( $(compgen -W 'install reinstall upgrade remove + COMPREPLY+=($(compgen -W 'install reinstall upgrade remove blacklist download update install-new upgrade-all clean-system new-config check-updates help generate-template install-template remove-template search file-search info' -- \ - "$cur") ) + "$cur")) return ;; esac } && -complete -F _slackpkg slackpkg + complete -F _slackpkg slackpkg # ex: filetype=sh diff --git a/completions/slapt-get b/completions/slapt-get index 9b249f19..14c2dbea 100644 --- a/completions/slapt-get +++ b/completions/slapt-get @@ -6,25 +6,27 @@ _slapt_get() _init_completion || return case "$prev" in - --config|-c) + --config | -c) _filedir return ;; - --retry|--search) + --retry | --search) # argument required but no completions available return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - [[ $COMPREPLY ]] && return + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + if [[ ${COMPREPLY-} ]]; then + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi fi local i t # search for last action (--install|--install-set|--remove|--show|--filelist) - for (( i=${#words[@]}-1; i>0; i-- )); do + for ((i = ${#words[@]} - 1; i > 0; i--)); do if [[ ${words[i]} == --show ]]; then t="all" break @@ -42,40 +44,43 @@ _slapt_get() local config="/etc/slapt-get/slapt-getrc" # default config location # search for config - for (( i=${#words[@]}-1; i>0; i-- )); do + for ((i = ${#words[@]} - 1; i > 0; i--)); do if [[ ${words[i]} == -@(c|-config) ]]; then - config="${words[i+1]}" + config="${words[i + 1]}" __expand_tilde_by_ref config break fi done - [[ -r "$config" ]] || return + [[ -r $config ]] || return case $t in all) # --show # slapt-get will fail to search for "^name-version" # it can search for names only local name=${cur%%-*} - COMPREPLY=( $(LC_ALL=C "$1" -c "$config" --search "^$name" \ - 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}") ) + COMPREPLY=($(LC_ALL=C "$1" -c "$config" --search "^$name" \ + 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}")) return ;; avl) # --install|-i| - COMPREPLY=( $(LC_ALL=C "$1" -c "$config" --available \ - 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}") ) + COMPREPLY=($(LC_ALL=C "$1" -c "$config" --available \ + 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}")) return ;; ins) # --remove|--filelist - COMPREPLY=( $(cd /var/log/packages; compgen -f -- "$cur") ) + COMPREPLY=($( + cd /var/log/packages + compgen -f -- "$cur" + )) return ;; set) # --install-set - COMPREPLY=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x - xap xfce y' -- "$cur") ) + COMPREPLY=($(compgen -W 'a ap d e f k kde kdei l n t tcl x + xap xfce y' -- "$cur")) return ;; esac } && -complete -F _slapt_get slapt-get + complete -F _slapt_get slapt-get # ex: filetype=sh diff --git a/completions/slapt-src b/completions/slapt-src index 64458bab..1e3828c0 100644 --- a/completions/slapt-src +++ b/completions/slapt-src @@ -6,11 +6,11 @@ _slapt_src() _init_completion -s -n : || return case "$prev" in - --config|-c) + --config | -c) _filedir return ;; - --search|-s|--postprocess|-p) + --search | -s | --postprocess | -p) # argument required but no completions available return ;; @@ -18,15 +18,17 @@ _slapt_src() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - [[ $COMPREPLY ]] && return + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + if [[ ${COMPREPLY-} ]]; then + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi fi local i t # search for last action (-i|-w|-b|-f) - for (( i=${#words[@]}-1; i>0; i-- )); do + for ((i = ${#words[@]} - 1; i > 0; i--)); do if [[ ${words[i]} == -@([iwfb]|-install|-show|-build|-fetch) ]]; then t="all" break @@ -38,9 +40,9 @@ _slapt_src() local config="/etc/slapt-get/slapt-srcrc" # default config location # search for config - for (( i=${#words[@]}-1; i>0; i-- )); do + for ((i = ${#words[@]} - 1; i > 0; i--)); do if [[ ${words[i]} == -@(c|-config) ]]; then - config="${words[i+1]}" + config="${words[i + 1]}" __expand_tilde_by_ref config break fi @@ -49,19 +51,18 @@ _slapt_src() break fi done - [[ -r "$config" ]] || return + [[ -r $config ]] || return - if [[ "$cur" == *:* ]]; then + if [[ $cur == *:* ]]; then local name=${cur%:*} - local version=${cur##*:} - COMPREPLY=( $(LC_ALL=C "$1" --config "$config" --search "^$name" \ + COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$name" \ 2>/dev/null | LC_ALL=C command sed -ne \ - "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p}") ) + "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p}")) else - COMPREPLY=( $(LC_ALL=C "$1" --config "$config" --search "^$cur" \ - 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}") ) + COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$cur" \ + 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}")) fi } && -complete -F _slapt_src slapt-src + complete -F _slapt_src slapt-src # ex: filetype=sh diff --git a/completions/smartctl b/completions/smartctl index ecef0b99..ee45a7c3 100644 --- a/completions/smartctl +++ b/completions/smartctl @@ -2,25 +2,27 @@ _smartctl_quietmode() { - COMPREPLY=( $(compgen -W 'errorsonly silent noserial' -- "$cur") ) + COMPREPLY=($(compgen -W 'errorsonly silent noserial' -- "$cur")) } _smartctl_device() { case $cur in - areca*|3ware*|megaraid*|cciss*) - COMPREPLY+=( ${cur%%,*},{0..31} ) - COMPREPLY=( $(compgen -W '"${COMPREPLY[@]}"' -- "$cur") ) + areca* | 3ware* | megaraid* | cciss*) + # shellcheck disable=SC2054 + COMPREPLY+=(${cur%%,*},{0..31}) + COMPREPLY=($(compgen -W '"${COMPREPLY[@]}"' -- "$cur")) ;; hpt*) - COMPREPLY+=( hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5} ) - COMPREPLY=( $(compgen -W '"${COMPREPLY[@]}"' -- "$cur") ) + # shellcheck disable=SC2054 + COMPREPLY+=(hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5}) + COMPREPLY=($(compgen -W '"${COMPREPLY[@]}"' -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W "ata scsi sat usbcypress usbjmicron + COMPREPLY=($(compgen -W "ata scsi sat usbcypress usbjmicron usbsunplus marvell areca 3ware hpt megaraid cciss auto test" \ - -- "$cur") ) + -- "$cur")) case "${COMPREPLY[@]}" in - areca|3ware|hpt|megaraid|cciss) + areca | 3ware | hpt | megaraid | cciss) compopt -o nospace ;; esac @@ -29,54 +31,54 @@ _smartctl_device() } _smartctl_tolerance() { - COMPREPLY=( $(compgen -W 'normal conservative permissive verypermissive' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'normal conservative permissive verypermissive' \ + -- "$cur")) } _smartctl_badsum() { - COMPREPLY=( $(compgen -W 'warn exit ignore' -- "$cur") ) + COMPREPLY=($(compgen -W 'warn exit ignore' -- "$cur")) } _smartctl_report() { - COMPREPLY=( $(compgen -W 'ioctl ataioctl scsiioctl' -- "$cur") ) + COMPREPLY=($(compgen -W 'ioctl ataioctl scsiioctl' -- "$cur")) } _smartctl_powermode() { - COMPREPLY=( $(compgen -W 'never sleep standby idle' -- "$cur") ) + COMPREPLY=($(compgen -W 'never sleep standby idle' -- "$cur")) } _smartctl_feature() { - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) } _smartctl_log() { - COMPREPLY=( $(compgen -W 'error selftest selective directory background + COMPREPLY=($(compgen -W 'error selftest selective directory background sasphy sasphy,reset sataphy sataphy,reset scttemp scttempsts - scttemphist scterc gplog smartlog xerror xselftest' -- "$cur") ) + scttemphist scterc gplog smartlog xerror xselftest' -- "$cur")) } _smartctl_vendorattribute() { - COMPREPLY=( $(compgen -W 'help 9,minutes 9,seconds 9,halfminutes 9,temp + COMPREPLY=($(compgen -W 'help 9,minutes 9,seconds 9,halfminutes 9,temp 192,emergencyretractcyclect 193,loadunload 194,10xCelsius 194,unknown 198,offlinescanuncsectorct 200,writeerrorcount 201,detectedtacount - 220,temp' -- "$cur") ) + 220,temp' -- "$cur")) } _smartctl_firmwarebug() { - COMPREPLY=( $(compgen -W 'none samsung samsung2 samsung3 swapid' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'none samsung samsung2 samsung3 swapid' \ + -- "$cur")) } _smartctl_presets() { - COMPREPLY=( $(compgen -W 'use ignore show showall' -- "$cur") ) + COMPREPLY=($(compgen -W 'use ignore show showall' -- "$cur")) } _smartctl_test() { [[ $cur == @(pending|scttempint|vendor), ]] && return - COMPREPLY=( $(compgen -W 'offline short long conveyance select, + COMPREPLY=($(compgen -W 'offline short long conveyance select, select,redo select,next afterselect,on afterselect,off pending, - scttempint, vendor,' -- "$cur") ) - [[ $COMPREPLY == *, ]] && compopt -o nospace + scttempint, vendor,' -- "$cur")) + [[ ${COMPREPLY-} == *, ]] && compopt -o nospace } _smartctl_drivedb() { @@ -86,7 +88,7 @@ _smartctl_drivedb() cur="${cur#+}" fi _filedir h - [[ -n $prefix ]] && COMPREPLY=( "${COMPREPLY[@]/#/$prefix}" ) + [[ -n $prefix ]] && COMPREPLY=("${COMPREPLY[@]/#/$prefix}") } _smartctl() @@ -95,54 +97,54 @@ _smartctl() _init_completion -s || return case $prev in - --quietmode|-!(-*)q) + --quietmode | -!(-*)q) _smartctl_quietmode ;; - --device|-!(-*)d) + --device | -!(-*)d) _smartctl_device return ;; - --tolerance|-!(-*)T) + --tolerance | -!(-*)T) _smartctl_tolerance return ;; - --badsum|-!(-*)b) + --badsum | -!(-*)b) _smartctl_badsum return ;; - --report|-!(-*)r) + --report | -!(-*)r) _smartctl_report return ;; - --nocheck|-!(-*)n) + --nocheck | -!(-*)n) _smartctl_powermode return ;; - --smart|--offlineauto|--saveauto|-!(-*)[soS]) + --smart | --offlineauto | --saveauto | -!(-*)[soS]) _smartctl_feature return ;; - --log|-!(-*)l) + --log | -!(-*)l) _smartctl_log return ;; - --vendorattribute|-!(-*)v) + --vendorattribute | -!(-*)v) _smartctl_vendorattribute return ;; - --firmwarebug|-!(-*)F) + --firmwarebug | -!(-*)F) _smartctl_firmwarebug return ;; - --presets|-!(-*)P) + --presets | -!(-*)P) _smartctl_presets return ;; - --drivedb|-!(-*)B) + --drivedb | -!(-*)B) _smartctl_drivedb return ;; - --test|-!(-*)t) + --test | -!(-*)t) _smartctl_test return ;; @@ -150,14 +152,14 @@ _smartctl() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else cur=${cur:=/dev/} _filedir fi } && -complete -F _smartctl smartctl + complete -F _smartctl smartctl # ex: filetype=sh diff --git a/completions/smbclient b/completions/smbclient index c896ce42..cea21076 100644 --- a/completions/smbclient +++ b/completions/smbclient @@ -2,40 +2,41 @@ _samba_resolve_order() { - COMPREPLY=( $(compgen -W 'lmhosts host wins bcast' -- "$cur") ) + COMPREPLY=($(compgen -W 'lmhosts host wins bcast' -- "$cur")) } _samba_domains() { if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then - COMPREPLY=( $(compgen -W '$(smbtree -N -D)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(smbtree -N -D)' -- "$cur")) fi } _samba_hosts() { if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then - COMPREPLY=( $(compgen -W "$(smbtree -N -S | \ - command sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' \ - )" -- "$cur") ) + COMPREPLY=($(compgen -W "$( + smbtree -N -S | + command sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' + )" -- "$cur")) fi } _samba_debuglevel() { - COMPREPLY=( $(compgen -W '{0..10}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..10}' -- "$cur")) } _samba_sockopts() { - COMPREPLY=( $(compgen -W 'SO_KEEPALIVE SO_REUSEADDR SO_BROADCAST + COMPREPLY=($(compgen -W 'SO_KEEPALIVE SO_REUSEADDR SO_BROADCAST TCP_NODELAY IPTOS_LOWDELAY IPTOS_THROUGHPUT SO_SNDBUF SO_RCVBUF - SO_SNDLOWAT SO_RCVLOWAT' -- "$cur") ) + SO_SNDLOWAT SO_RCVLOWAT' -- "$cur")) } _samba_signing() { - COMPREPLY=( $(compgen -W 'on off required' -- "$cur") ) + COMPREPLY=($(compgen -W 'on off required' -- "$cur")) } _smbclient() @@ -44,64 +45,64 @@ _smbclient() _init_completion -s || return case $prev in - --name-resolve|-!(-*)R) + --name-resolve | -!(-*)R) _samba_resolve_order return ;; -!(-*)t) - COMPREPLY=( $(compgen -W 'SJIS EUC JIS7 JIS8 JUNET HEX CAP' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'SJIS EUC JIS7 JIS8 JUNET HEX CAP' \ + -- "$cur")) return ;; - --configfile|--authentication-file|-!(-*)[sA]) + --configfile | --authentication-file | -!(-*)[sA]) _filedir return ;; - --log-basename|--directory|-!(-*)[lD]) + --log-basename | --directory | -!(-*)[lD]) _filedir -d return ;; - --socket-options|-!(-*)O) + --socket-options | -!(-*)O) _samba_sockopts return ;; -!(-*)T) - COMPREPLY=( $(compgen -W 'c x I X F b g q r N a' -- "$cur") ) + COMPREPLY=($(compgen -W 'c x I X F b g q r N a' -- "$cur")) return ;; - --workgroup|-!(-*)W) + --workgroup | -!(-*)W) _samba_domains return ;; - --debuglevel|-!(-*)d) + --debuglevel | -!(-*)d) _samba_debuglevel return ;; - --list|-!(-*)L) + --list | -!(-*)L) _samba_hosts return ;; - --signing|-!(-*)S) + --signing | -!(-*)S) _samba_signing return ;; - --port|--message|--ip-address|--send-buffer|--user|--netbiosname|\ - --scope|--tar|--command|--max-protocol|-!(-*)[pMIbUniTcm]) + --port | --message | --ip-address | --send-buffer | --user | --netbiosname | \ + --scope | --tar | --command | --max-protocol | -!(-*)[pMIbUniTcm]) return ;; - --help|--version|-!(-*)[?V]) + --help | --version | -!(-*)[?V]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _smbclient smbclient + complete -F _smbclient smbclient _smbget() { @@ -109,31 +110,31 @@ _smbget() _init_completion -s || return case $prev in - --outputfile|--rcfile|-!(-*)[of]) + --outputfile | --rcfile | -!(-*)[of]) _filedir return ;; - --debuglevel|-!(-*)d) + --debuglevel | -!(-*)d) _samba_debuglevel return ;; - --workgroup|-!(-*)w) + --workgroup | -!(-*)w) _samba_domains return ;; - --username|--password|--blocksize|-!(-*)[upb]) + --username | --password | --blocksize | -!(-*)[upb]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _smbget smbget + complete -F _smbget smbget _smbcacls() { @@ -141,15 +142,15 @@ _smbcacls() _init_completion -s || return case $prev in - --configfile|--authentication-file|-!(-*)[As]) + --configfile | --authentication-file | -!(-*)[As]) _filedir return ;; - --log-basename|-!(-*)l) + --log-basename | -!(-*)l) _filedir -d return ;; - --debuglevel|-!(-*)d) + --debuglevel | -!(-*)d) _samba_debuglevel return ;; @@ -157,28 +158,28 @@ _smbcacls() _samba_signing return ;; - --socket-options|-!(-*)O) + --socket-options | -!(-*)O) _samba_sockopts return ;; - --workgroup|-!(-*)W) + --workgroup | -!(-*)W) _samba_domains return ;; - --help|--usage|--delete|--modify|--add|--set|--chown|--chgrp|\ - --netbiosname|--scope|--user|-!(-*)[?DMaSCGniU]) + --help | --usage | --delete | --modify | --add | --set | --chown | --chgrp | \ + --netbiosname | --scope | --user | -!(-*)[?DMaSCGniU]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _smbcacls smbcacls + complete -F _smbcacls smbcacls _smbcquotas() { @@ -186,15 +187,15 @@ _smbcquotas() _init_completion -s || return case $prev in - --configfile|--authentication-file|-!(-*)[sA]) + --configfile | --authentication-file | -!(-*)[sA]) _filedir return ;; - --log-basename|-!(-*)l) + --log-basename | -!(-*)l) _filedir -d return ;; - --debuglevel|-!(-*)d) + --debuglevel | -!(-*)d) _samba_debuglevel return ;; @@ -202,19 +203,19 @@ _smbcquotas() _samba_signing return ;; - --help|--usage|--user|--set|-!(-*)[?UuS]) + --help | --usage | --user | --set | -!(-*)[?UuS]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _smbcquotas smbcquotas + complete -F _smbcquotas smbcquotas _smbpasswd() { @@ -243,11 +244,11 @@ _smbpasswd() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) fi } && -complete -F _smbpasswd smbpasswd + complete -F _smbpasswd smbpasswd _smbtar() { @@ -276,11 +277,11 @@ _smbtar() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _smbtar smbtar + complete -F _smbtar smbtar _smbtree() { @@ -288,34 +289,34 @@ _smbtree() _init_completion -s || return case $prev in - --configfile|--authentication-file|-!(-*)[sA]) + --configfile | --authentication-file | -!(-*)[sA]) _filedir return ;; - --log-basename|-!(-*)l) + --log-basename | -!(-*)l) _filedir -d return ;; - --debuglevel|-!(-*)d) + --debuglevel | -!(-*)d) _samba_debuglevel return ;; - --signing|-!(-*)S) + --signing | -!(-*)S) _samba_signing return ;; - --help|--usage|--user|-!(-*)[?U]) + --help | --usage | --user | -!(-*)[?U]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _smbtree smbtree + complete -F _smbtree smbtree # ex: filetype=sh diff --git a/completions/snownews b/completions/snownews index 3938454f..5b585d92 100644 --- a/completions/snownews +++ b/completions/snownews @@ -5,11 +5,11 @@ _snownews() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # return list of available options - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _snownews snownews + complete -F _snownews snownews # ex: filetype=sh diff --git a/completions/sqlite3 b/completions/sqlite3 index a7005489..26d38a1f 100644 --- a/completions/sqlite3 +++ b/completions/sqlite3 @@ -8,8 +8,8 @@ _sqlite3() local dbexts='@(sqlite?(3)|?(s?(3))db)' case $prev in - -help|-version|-lookaside|-mmap|-newline|-nullvalue|-pagecache|\ - -scratch|-separator|*.$dbexts) + -help | -version | -lookaside | -mmap | -newline | -nullvalue | -pagecache | \ + -scratch | -separator | *.$dbexts) return ;; -init) @@ -18,21 +18,21 @@ _sqlite3() ;; -cmd) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; esac - [[ $cword -gt 2 && ${words[cword-2]} == -@(lookaside|pagecache|scratch) ]] \ - && return + [[ $cword -gt 2 && ${words[cword - 2]} == -@(lookaside|pagecache|scratch) ]] && + return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) return fi _filedir "$dbexts" } && -complete -F _sqlite3 sqlite3 + complete -F _sqlite3 sqlite3 # ex: filetype=sh diff --git a/completions/ss b/completions/ss index 05e4e4b2..4a27d514 100644 --- a/completions/ss +++ b/completions/ss @@ -6,23 +6,24 @@ _ss() _init_completion -s || return case $prev in - --help|--version|-!(-*)[hV]) + --help | --version | -!(-*)[hV]) return ;; - --family|-!(-*)f) - COMPREPLY=( $(compgen -W 'unix inet inet6 link netlink' \ - -- "$cur") ) + --family | -!(-*)f) + COMPREPLY=($(compgen -W 'unix inet inet6 link netlink' \ + -- "$cur")) return ;; - --query|-!(-*)A) - local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $(compgen -W '$("$1" --help | \ + --query | -!(-*)A) + local prefix= + [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=($(compgen -W '$("$1" --help | \ command sed -e "s/|/ /g" -ne "s/.*QUERY := {\([^}]*\)}.*/\1/p")' \ - -- "${cur##*,}") ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + -- "${cur##*,}")) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) return ;; - --diag|--filter|-!(-*)[DF]) + --diag | --filter | -!(-*)[DF]) _filedir return ;; @@ -31,10 +32,10 @@ _ss() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _ss ss + complete -F _ss ss # ex: filetype=sh diff --git a/completions/ssh b/completions/ssh index ecbd5896..907c0390 100644 --- a/completions/ssh +++ b/completions/ssh @@ -2,9 +2,12 @@ _ssh_queries() { - COMPREPLY+=( $(compgen -W \ - "cipher cipher-auth mac kex key key-cert key-plain protocol-version sig" \ - -- "$cur") ) + COMPREPLY+=($(compgen -W \ + "cipher cipher-auth help mac kex key key-cert key-plain key-sig + protocol-version compression sig + ciphers macs kexalgorithms pubkeyacceptedkeytypes + hostkeyalgorithms hostbasedkeytypes hostbasedacceptedkeytypes" \ + -- "${cur,,}")) } _ssh_query() @@ -18,7 +21,7 @@ _ssh_ciphers() [[ $ciphers ]] || ciphers="3des-cbc aes128-cbc aes192-cbc aes256-cbc aes128-ctr aes192-ctr aes256-ctr arcfour128 arcfour256 arcfour blowfish-cbc cast128-cbc" - COMPREPLY+=( $(compgen -W "$ciphers" -- "$cur") ) + COMPREPLY+=($(compgen -W "$ciphers" -- "$cur")) } _ssh_macs() @@ -26,7 +29,7 @@ _ssh_macs() local macs='$(_ssh_query "$1" mac)' [[ $macs ]] || macs="hmac-md5 hmac-sha1 umac-64@openssh.com hmac-ripemd160 hmac-sha1-96 hmac-md5-96" - COMPREPLY+=( $(compgen -W "$macs" -- "$cur") ) + COMPREPLY+=($(compgen -W "$macs" -- "$cur")) } _ssh_options() @@ -55,19 +58,20 @@ _ssh_options() ServerAliveInterval SmartcardDevice StreamLocalBindMask StreamLocalBindUnlink StrictHostKeyChecking SyslogFacility TCPKeepAlive Tunnel TunnelDevice UpdateHostKeys UsePrivilegedPort User - UserKnownHostsFile VerifyHostKeyDNS VisualHostKey XAuthLocation ) + UserKnownHostsFile VerifyHostKeyDNS VisualHostKey XAuthLocation) local protocols=$(_ssh_query "$1" protocol-version) if [[ -z $protocols || $protocols == *1* ]]; then - opts+=( Cipher CompressionLevel Protocol RhostsRSAAuthentication - RSAAuthentication ) + opts+=(Cipher CompressionLevel Protocol RhostsRSAAuthentication + RSAAuthentication) fi compopt -o nospace - local IFS=$' \t\n' reset=$(shopt -p nocasematch); shopt -s nocasematch + local IFS=$' \t\n' reset=$(shopt -p nocasematch) + shopt -s nocasematch local option - COMPREPLY=( $(for option in "${opts[@]}"; do - [[ $option == "$cur"* ]] && printf '%s=\n' "$option" - done) ) + COMPREPLY=($(for option in "${opts[@]}"; do + [[ $option == "$cur"* ]] && printf '%s=\n' "$option" + done)) $reset } @@ -82,68 +86,68 @@ _ssh_suboption() local prev=${1%%=*} cur=${1#*=} case ${prev,,} in - batchmode|canonicaldomains|canonicalizefallbacklocal|\ - challengeresponseauthentication|checkhostip|\ - clearallforwardings|controlpersist|compression|enablesshkeysign|\ - exitonforwardfailure|forwardagent|forwardx11|forwardx11trusted|\ - gatewayports|gssapiauthentication|gssapikeyexchange|\ - gssapidelegatecredentials|gssapirenewalforcesrekey|gssapitrustdns|\ - hashknownhosts|hostbasedauthentication|identitiesonly|\ - kbdinteractiveauthentication|kbdinteractivedevices|\ - nohostauthenticationforlocalhost|passwordauthentication|permitlocalcommand|\ - proxyusefdpass|pubkeyauthentication|rhostsrsaauthentication|\ - rsaauthentication|streamlocalbindunlink|\ - tcpkeepalive|useprivilegedport|visualhostkey) - COMPREPLY=( $(compgen -W 'yes no' -- "$cur") ) + batchmode | canonicaldomains | canonicalizefallbacklocal | \ + challengeresponseauthentication | checkhostip | \ + clearallforwardings | controlpersist | compression | enablesshkeysign | \ + exitonforwardfailure | forwardagent | forwardx11 | forwardx11trusted | \ + gatewayports | gssapiauthentication | gssapikeyexchange | \ + gssapidelegatecredentials | gssapirenewalforcesrekey | gssapitrustdns | \ + hashknownhosts | hostbasedauthentication | identitiesonly | \ + kbdinteractiveauthentication | kbdinteractivedevices | \ + nohostauthenticationforlocalhost | passwordauthentication | permitlocalcommand | \ + proxyusefdpass | pubkeyauthentication | rhostsrsaauthentication | \ + rsaauthentication | streamlocalbindunlink | \ + tcpkeepalive | useprivilegedport | visualhostkey) + COMPREPLY=($(compgen -W 'yes no' -- "$cur")) ;; addkeystoagent) - COMPREPLY=( $(compgen -W 'yes ask confirm no' -- "$cur") ) + COMPREPLY=($(compgen -W 'yes ask confirm no' -- "$cur")) ;; addressfamily) - COMPREPLY=( $(compgen -W 'any inet inet6' -- "$cur") ) + COMPREPLY=($(compgen -W 'any inet inet6' -- "$cur")) ;; bindaddress) _ip_addresses ;; canonicalizehostname) - COMPREPLY=( $(compgen -W 'yes no always' -- "$cur") ) + COMPREPLY=($(compgen -W 'yes no always' -- "$cur")) ;; identityfile) _ssh_identityfile ;; - *file|identityagent|include|controlpath|revokedhostkeys|xauthlocation) + *file | identityagent | include | controlpath | revokedhostkeys | xauthlocation) _filedir ;; casignaturealgorithms) - COMPREPLY=( $(compgen -W '$(_ssh_query "$2" sig)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_ssh_query "$2" sig)' -- "$cur")) ;; cipher) - COMPREPLY=( $(compgen -W 'blowfish des 3des' -- "$cur") ) + COMPREPLY=($(compgen -W 'blowfish des 3des' -- "$cur")) ;; ciphers) _ssh_ciphers "$2" ;; controlmaster) - COMPREPLY=( $(compgen -W 'yes ask auto autoask no' -- "$cur") ) + COMPREPLY=($(compgen -W 'yes ask auto autoask no' -- "$cur")) ;; compressionlevel) - COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..9}' -- "$cur")) ;; fingerprinthash) - COMPREPLY=( $(compgen -W 'md5 sha256' -- "$cur") ) + COMPREPLY=($(compgen -W 'md5 sha256' -- "$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") ) + COMPREPLY=($(compgen -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3} + cs{0..7} ef lowdelay throughput reliability' -- "$cur")) ;; - hostbasedkeytypes|hostkeyalgorithms) - COMPREPLY=( $(compgen -W '$(_ssh_query "$2" key)' -- "$cur") ) + hostbasedkeytypes | hostkeyalgorithms) + COMPREPLY=($(compgen -W '$(_ssh_query "$2" key)' -- "$cur")) ;; kexalgorithms) - COMPREPLY=( $(compgen -W '$(_ssh_query "$2" kex)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_ssh_query "$2" kex)' -- "$cur")) ;; loglevel) - COMPREPLY=( $(compgen -W 'QUIET FATAL ERROR INFO VERBOSE DEBUG{,1,2,3}' -- "$cur") ) + COMPREPLY=($(compgen -W 'QUIET FATAL ERROR INFO VERBOSE DEBUG{,1,2,3}' -- "$cur")) ;; macs) _ssh_macs "$2" @@ -152,40 +156,40 @@ _ssh_suboption() _filedir so ;; preferredauthentications) - COMPREPLY=( $(compgen -W 'gssapi-with-mic host-based publickey - keyboard-interactive password' -- "$cur") ) + COMPREPLY=($(compgen -W 'gssapi-with-mic host-based publickey + keyboard-interactive password' -- "$cur")) ;; protocol) - local protocols=( $(_ssh_query "$2" protocol-version) ) + local protocols=($(_ssh_query "$2" protocol-version)) [[ $protocols ]] || protocols=(1 2) - if [[ ${#protocols[@]} -gt 1 ]]; then - COMPREPLY=( $(compgen -W '${protocols[@]}' -- "$cur") ) + if ((${#protocols[@]} > 1)); then + COMPREPLY=($(compgen -W '${protocols[@]}' -- "$cur")) fi ;; proxyjump) - _known_hosts_real -a -F "$configfile" -- "$cur" + _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur" ;; - proxycommand|remotecommand|localcommand) - COMPREPLY=( $(compgen -c -- "$cur") ) + proxycommand | remotecommand | localcommand) + COMPREPLY=($(compgen -c -- "$cur")) ;; pubkeyacceptedkeytypes) - COMPREPLY=( $(compgen -W '$(_ssh_query "$2" key)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_ssh_query "$2" key)' -- "$cur")) ;; requesttty) - COMPREPLY=( $(compgen -W 'no yes force auto' -- "$cur") ) + COMPREPLY=($(compgen -W 'no yes force auto' -- "$cur")) ;; stricthostkeychecking) - COMPREPLY=( $(compgen -W 'accept-new ask no off' -- "$cur") ) + COMPREPLY=($(compgen -W 'accept-new ask no off' -- "$cur")) ;; syslogfacility) - COMPREPLY=( $(compgen -W 'DAEMON USER AUTH LOCAL{0..7}' -- "$cur") ) + COMPREPLY=($(compgen -W 'DAEMON USER AUTH LOCAL{0..7}' -- "$cur")) ;; tunnel) - COMPREPLY=( $(compgen -W 'yes no point-to-point ethernet' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'yes no point-to-point ethernet' \ + -- "$cur")) ;; - updatehostkeys|verifyhostkeydns) - COMPREPLY=( $(compgen -W 'yes no ask' -- "$cur") ) + updatehostkeys | verifyhostkeydns) + COMPREPLY=($(compgen -W 'yes no ask' -- "$cur")) ;; esac return 0 @@ -197,7 +201,7 @@ _ssh_suboption() _ssh_suboption_check() { # Get prev and cur words without splitting on = - local cureq=`_get_cword :=` preveq=`_get_pword :=` + local cureq=$(_get_cword :=) preveq=$(_get_pword :=) if [[ $cureq == *=* && $preveq == -*o ]]; then _ssh_suboption $cureq "$1" return $? @@ -209,13 +213,13 @@ _ssh_suboption_check() _ssh_configfile() { set -- "${words[@]}" - while [[ $# -gt 0 ]]; do + while (($# > 0)); do if [[ $1 == -F* ]]; then - if [[ ${#1} -gt 2 ]]; then + if ((${#1} > 2)); then configfile="$(dequote "${1:2}")" else shift - [[ $1 ]] && configfile="$(dequote "$1")" + [[ ${1-} ]] && configfile="$(dequote "$1")" fi break fi @@ -224,13 +228,14 @@ _ssh_configfile() } # With $1 set, look for public key files, else private +# shellcheck disable=SC2120 _ssh_identityfile() { [[ -z $cur && -d ~/.ssh ]] && cur=~/.ssh/id _filedir - if (( ${#COMPREPLY[@]} > 0 )); then - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' \ - -X "${1:+!}*.pub" -- "$cur") ) + if ((${#COMPREPLY[@]} > 0)); then + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' \ + -X "${1:+!}*.pub" -- "$cur")) fi } @@ -239,8 +244,6 @@ _ssh() local cur prev words cword _init_completion -n : || return - local -a config - local configfile _ssh_configfile @@ -249,12 +252,6 @@ _ssh() local ipvx case $prev in - -*4*) - ipvx=-4 - ;; - -*6*) - ipvx=-6 - ;; -*b) _ip_addresses return @@ -279,11 +276,11 @@ _ssh() return ;; -*J) - _known_hosts_real -a -F "$configfile" -- "$cur" + _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur" return ;; -*l) - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) return ;; -*m) @@ -291,7 +288,7 @@ _ssh() return ;; -*O) - COMPREPLY=( $(compgen -W 'check forward cancel exit stop' -- "$cur") ) + COMPREPLY=($(compgen -W 'check forward cancel exit stop' -- "$cur")) return ;; -*o) @@ -306,28 +303,34 @@ _ssh() _available_interfaces return ;; + -*4*) + ipvx=-4 + ;; + -*6*) + ipvx=-6 + ;; esac - if [[ "$cur" == -F* ]]; then + if [[ $cur == -F* ]]; then cur=${cur#-F} _filedir # Prefix completions with '-F' - COMPREPLY=( "${COMPREPLY[@]/#/-F}" ) - cur=-F$cur # Restore cur - elif [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=("${COMPREPLY[@]/#/-F}") + cur=-F$cur # Restore cur + elif [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) else - _known_hosts_real $ipvx -a -F "$configfile" -- "$cur" + _known_hosts_real ${ipvx-} -a ${configfile:+-F "$configfile"} -- "$cur" local args _count_args - if [[ $args -gt 1 ]]; then + if ((args > 1)); then compopt -o filenames - COMPREPLY+=( $(compgen -c -- "$cur") ) + COMPREPLY+=($(compgen -c -- "$cur")) fi fi } && -shopt -u hostcomplete && complete -F _ssh ssh slogin autossh sidedoor + shopt -u hostcomplete && complete -F _ssh ssh slogin autossh sidedoor # sftp(1) completion # @@ -344,12 +347,6 @@ _sftp() local ipvx case $prev in - -*4*) - ipvx=-4 - ;; - -*6*) - ipvx=-6 - ;; -*[BDlPRs]) return ;; @@ -366,7 +363,7 @@ _sftp() return ;; -*J) - _known_hosts_real -a -F "$configfile" -- "$cur" + _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur" return ;; -*o) @@ -374,30 +371,39 @@ _sftp() return ;; -*S) - _command + compopt -o filenames + COMPREPLY=($(compgen -c -- "$cur")) return ;; + -*4*) + ipvx=-4 + ;; + -*6*) + ipvx=-6 + ;; esac - if [[ "$cur" == -F* ]]; then + if [[ $cur == -F* ]]; then cur=${cur#-F} _filedir # Prefix completions with '-F' - COMPREPLY=( "${COMPREPLY[@]/#/-F}" ) - cur=-F$cur # Restore cur - elif [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=("${COMPREPLY[@]/#/-F}") + cur=-F$cur # Restore cur + elif [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) else - _known_hosts_real $ipvx -a -F "$configfile" -- "$cur" + _known_hosts_real ${ipvx-} -a ${configfile:+-F "$configfile"} -- "$cur" fi } && -shopt -u hostcomplete && complete -F _sftp sftp + shopt -u hostcomplete && complete -F _sftp sftp # things we want to backslash escape in scp paths -_scp_path_esc='[][(){}<>",:;^&!$=?`|\\'"'"'[:space:]]' +# shellcheck disable=SC2089 +_scp_path_esc='[][(){}<>"'"'"',:;^&!$=?`\\|[:space:]]' # Complete remote files with ssh. If the first arg is -d, complete on dirs # only. Returns paths escaped with three backslashes. +# shellcheck disable=SC2120 _scp_remote_files() { local IFS=$'\n' @@ -409,6 +415,7 @@ _scp_remote_files() local path=${cur#*:} # unescape (3 backslashes to 1 for chars we escaped) + # shellcheck disable=SC2090 path=$(command sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path") # default to home dir of specified user on remote host @@ -419,18 +426,20 @@ _scp_remote_files() local files if [[ $1 == -d ]]; then # escape problematic characters; remove non-dirs + # shellcheck disable=SC2090 files=$(ssh -o 'Batchmode yes' $userhost \ - command ls -aF1dL "$path*" 2>/dev/null | \ + command ls -aF1dL "$path*" 2>/dev/null | command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e '/[^\/]$/d') else # escape problematic characters; remove executables, aliases, pipes # and sockets; add space at end of file names + # shellcheck disable=SC2090 files=$(ssh -o 'Batchmode yes' $userhost \ - command ls -aF1dL "$path*" 2>/dev/null | \ + command ls -aF1dL "$path*" 2>/dev/null | command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e 's/[*@|=]$//g' \ - -e 's/[^\/]$/& /g') + -e 's/[^\/]$/& /g') fi - COMPREPLY+=( $files ) + COMPREPLY+=($files) } # This approach is used instead of _filedir to get a space appended @@ -442,18 +451,18 @@ _scp_local_files() local IFS=$'\n' local dirsonly=false - if [[ $1 == -d ]]; then + if [[ ${1-} == -d ]]; then dirsonly=true shift fi - if $dirsonly ; then - COMPREPLY+=( $(command ls -aF1dL $cur* 2>/dev/null | \ - command sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/$1/") ) + if $dirsonly; then + COMPREPLY+=($(command ls -aF1dL $cur* 2>/dev/null | + command sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/${1-}/")) else - COMPREPLY+=( $(command ls -aF1dL $cur* 2>/dev/null | \ + COMPREPLY+=($(command ls -aF1dL $cur* 2>/dev/null | command sed -e "s/$_scp_path_esc/\\\\&/g" -e 's/[*@|=]$//g' \ - -e 's/[^\/]$/& /g' -e "s/^/$1/") ) + -e 's/[^\/]$/& /g' -e "s/^/${1-}/")) fi } @@ -468,22 +477,16 @@ _scp() _ssh_configfile _ssh_suboption_check && { - COMPREPLY=( "${COMPREPLY[@]/%/ }" ) + COMPREPLY=("${COMPREPLY[@]/%/ }") return } local ipvx case $prev in - -*4*) - ipvx=-4 - ;; - -*6*) - ipvx=-6 - ;; -*c) _ssh_ciphers - COMPREPLY=( "${COMPREPLY[@]/%/ }" ) + COMPREPLY=("${COMPREPLY[@]/%/ }") return ;; -*F) @@ -497,7 +500,7 @@ _scp() return ;; -*J) - _known_hosts_real -a -F "$configfile" -- "$cur" + _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur" return ;; -*[lP]) @@ -508,43 +511,53 @@ _scp() return ;; -*S) - _command - compopt +o nospace + compopt +o nospace -o filenames + COMPREPLY=($(compgen -c -- "$cur")) return ;; + -*4*) + ipvx=-4 + ;; + -*6*) + ipvx=-6 + ;; esac _expand || return case $cur in - !(*:*)/*|[.~]*) ;; # looks like a path - *:*) _scp_remote_files ; return ;; + !(*:*)/* | [.~]*) ;; # looks like a path + *:*) + _scp_remote_files + return + ;; esac local prefix - if [[ "$cur" == -F* ]]; then + if [[ $cur == -F* ]]; then cur=${cur#-F} prefix=-F else case $cur in -*) - COMPREPLY=( $(compgen -W '$(_parse_usage "${words[0]}")' \ - -- "$cur") ) - COMPREPLY=( "${COMPREPLY[@]/%/ }" ) + COMPREPLY=($(compgen -W '$(_parse_usage "${words[0]}")' \ + -- "$cur")) + COMPREPLY=("${COMPREPLY[@]/%/ }") return ;; - */*|[.~]*) + */* | [.~]*) # not a known host, pass through ;; *) - _known_hosts_real $ipvx -c -a -F "$configfile" -- "$cur" + _known_hosts_real ${ipvx-} -c -a \ + ${configfile:+-F "$configfile"} -- "$cur" ;; esac fi - _scp_local_files "$prefix" + _scp_local_files "${prefix-}" } && -complete -F _scp -o nospace scp + complete -F _scp -o nospace scp # ex: filetype=sh diff --git a/completions/ssh-add b/completions/ssh-add index f35c7d00..d8f74926 100644 --- a/completions/ssh-add +++ b/completions/ssh-add @@ -7,7 +7,7 @@ _ssh_add() case $prev in -*E) - COMPREPLY=( $(compgen -W 'md5 sha256' -- "$cur") ) + COMPREPLY=($(compgen -W 'md5 sha256' -- "$cur")) return ;; -*t) @@ -24,12 +24,12 @@ _ssh_add() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" "-\?")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" "-\?")' -- "$cur")) return fi _filedir } && -complete -F _ssh_add ssh-add + complete -F _ssh_add ssh-add # ex: filetype=sh diff --git a/completions/ssh-copy-id b/completions/ssh-copy-id index ebfc46e6..f6281947 100644 --- a/completions/ssh-copy-id +++ b/completions/ssh-copy-id @@ -21,12 +21,12 @@ _ssh_copy_id() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _known_hosts_real -a -- "$cur" fi } && -complete -F _ssh_copy_id ssh-copy-id + complete -F _ssh_copy_id ssh-copy-id # ex: filetype=sh diff --git a/completions/ssh-keygen b/completions/ssh-keygen index 36fa2cad..0e629a56 100644 --- a/completions/ssh-keygen +++ b/completions/ssh-keygen @@ -3,14 +3,30 @@ _ssh_keygen() { local cur prev words cword - _init_completion -n = || return + _init_completion -n := || return case $prev in - -*[abCIJjMNnrPSVWz]) + -*[aCIJjMNPSVWz]) + return + ;; + -*b) + local -a sizes + case "${words[*]}" in + *" -t dsa"?( *)) + sizes=(1024) + ;; + *" -t ecdsa"?( *)) + sizes=(256 384 521) + ;; + *" -t rsa"?( *)) + sizes=(1024 2048 3072 4096) + ;; + esac + COMPREPLY=($(compgen -W '${sizes[@]}' -- "$cur")) return ;; -*E) - COMPREPLY=( $(compgen -W 'md5 sha256' -- "$cur") ) + COMPREPLY=($(compgen -W 'md5 sha256' -- "$cur")) return ;; -*[FR]) @@ -18,7 +34,7 @@ _ssh_keygen() _known_hosts_real -- "$cur" return ;; - -*D) + -*[Dw]) _filedir so return ;; @@ -27,37 +43,81 @@ _ssh_keygen() return ;; -*m) - COMPREPLY=( $(compgen -W 'PEM PKCS8 RFC4716' -- "$cur") ) + COMPREPLY=($(compgen -W 'PEM PKCS8 RFC4716' -- "$cur")) + return + ;; + -*n) + [[ ${words[*]} != *\ -*Y\ * ]] || return + local prefix= + [[ $cur == *,* ]] && prefix="${cur%,*}," + if [[ ${words[*]} == *\ -*h\ * ]]; then + _known_hosts_real -- "${cur##*,}" + else + COMPREPLY=($(compgen -u -- "${cur##*,}")) + fi + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) return ;; -*O) if [[ $cur != *=* ]]; then - COMPREPLY=( $(compgen -W 'clear force-command= + COMPREPLY=($(compgen -W ' + clear critical: extension: force-command= no-agent-forwarding no-port-forwarding no-pty no-user-rc no-x11-forwarding permit-agent-forwarding permit-port-forwarding permit-pty permit-user-rc - permit-x11-forwarding source-address=' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + permit-X11-forwarding no-touch-required source-address= + + lines= start-line= checkpoint= memory= start= generator= + + application challenge= device resident user + write-attestation-path + ' -- "$cur")) + [[ ${COMPREPLY-} == *[:=] ]] && compopt -o nospace + __ltrim_colon_completions "$cur" + else + case $cur in + force-command=*) + compopt -o filenames + COMPREPLY=($(compgen -c -- "${cur#*=}")) + ;; + checkpoint=* | challenge=*) + cur=${cur#*=} + _filedir + ;; + esac fi return ;; + -*r) + [[ ${words[*]} != *\ -*Y\ * ]] || _filedir + return + ;; -*t) local protocols=$(_xfunc ssh _ssh_query "$1" protocol-version) - local types='dsa ecdsa ed25519 rsa' + local types='dsa ecdsa ecdsa-sk ed25519 ed25519-sk rsa' if [[ $protocols == *1* ]]; then types+=' rsa1' fi - COMPREPLY=( $(compgen -W "$types" -- "$cur") ) + COMPREPLY=($(compgen -W "$types" -- "$cur")) + return + ;; + -*Y) + COMPREPLY=($(compgen -W 'find-principals check-novalidate sign + verify' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then local opts=$(_parse_usage "$1" "-?") - [[ -z "$opts" ]] && opts=$(_parse_help "$1" "-?") # OpenSSH < 7 - COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) + [[ -z $opts ]] && opts=$(_parse_help "$1" "-?") # OpenSSH < 7 + COMPREPLY=($(compgen -W "$opts" -- "$cur")) + fi + + if [[ ${words[*]} == *\ -*s\ * ]]; then + _filedir pub fi } && -complete -F _ssh_keygen ssh-keygen + complete -F _ssh_keygen ssh-keygen # ex: filetype=sh diff --git a/completions/sshfs b/completions/sshfs index 4afcc994..223d029b 100644 --- a/completions/sshfs +++ b/completions/sshfs @@ -5,21 +5,19 @@ _sshfs() local cur prev words cword _init_completion -n : || return - local userhost path - _expand || return - if [[ "$cur" == *:* ]]; then + if [[ $cur == *:* ]]; then _xfunc ssh _scp_remote_files -d # unlike scp and rsync, sshfs works with 1 backslash instead of 3 - COMPREPLY=( "${COMPREPLY[@]//\\\\\\/\\}" ) + COMPREPLY=("${COMPREPLY[@]//\\\\\\/\\}") return fi - [[ "$cur" == @(*/|[.~])* ]] || _known_hosts_real -c -a -- "$cur" + [[ $cur == @(*/|[.~])* ]] || _known_hosts_real -c -a -- "$cur" _xfunc ssh _scp_local_files -d } && -complete -F _sshfs -o nospace sshfs + complete -F _sshfs -o nospace sshfs # ex: filetype=sh diff --git a/completions/sshmitm b/completions/sshmitm index 8b320fa8..ee893e59 100644 --- a/completions/sshmitm +++ b/completions/sshmitm @@ -5,13 +5,13 @@ _sshmitm() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) else _known_hosts_real -- "$cur" fi } && -complete -F _sshmitm sshmitm + complete -F _sshmitm sshmitm # ex: filetype=sh diff --git a/completions/sshow b/completions/sshow index e9ea9c2d..917444ea 100644 --- a/completions/sshow +++ b/completions/sshow @@ -16,11 +16,11 @@ _sshow() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) fi } && -complete -F _sshow sshow + complete -F _sshow sshow # ex: filetype=sh diff --git a/completions/strace b/completions/strace index 339780b6..2b46ce8e 100644 --- a/completions/strace +++ b/completions/strace @@ -7,10 +7,10 @@ _strace() # check if we're still completing strace local offset=0 i - for (( i=1; i <= cword; i++ )); do - case ${words[$i]} in - -o|-e|-p) - (( i++ )) + for ((i = 1; i <= cword; i++)); do + case ${words[i]} in + -o | -e | -p) + ((i++)) continue ;; -*) @@ -21,13 +21,13 @@ _strace() break done - if [[ $offset -gt 0 ]]; then + if ((offset > 0)); then _command_offset $offset else case $prev in -*e) - if [[ "$cur" == *=* ]]; then + if [[ $cur == *=* ]]; then prev=${cur/=*/} cur=${cur/*=/} @@ -39,33 +39,33 @@ _strace() local -A syscalls while read -r define syscall rest; do [[ $define == "#define" && \ - $syscall =~ ^__NR_(.+) ]] && \ + $syscall =~ ^__NR_(.+) ]] && syscalls[${BASH_REMATCH[1]}]=1 done 2>/dev/null </usr/include/asm/unistd.h if [[ ! $syscalls ]]; then local unistd arch=$(command uname -m) - if [[ "$arch" == *86 ]]; then + if [[ $arch == *86 ]]; then unistd=/usr/include/asm/unistd_32.h else unistd=/usr/include/asm/unistd_64.h fi while read -r define syscall rest; do [[ $define == "#define" && \ - $syscall =~ ^__NR_(.+) ]] && \ + $syscall =~ ^__NR_(.+) ]] && syscalls[${BASH_REMATCH[1]}]=1 done 2>/dev/null <$unistd fi - COMPREPLY=( $(compgen -W '${!syscalls[@]} file + COMPREPLY=($(compgen -W '${!syscalls[@]} file process network signal ipc desc all none' \ - -- "$cur") ) + -- "$cur")) return ;; esac else compopt -o nospace - COMPREPLY=( $(compgen -S"=" -W 'trace abbrev verbose raw - signal read write' -- "$cur") ) + COMPREPLY=($(compgen -S"=" -W 'trace abbrev verbose raw + signal read write' -- "$cur")) fi return ;; @@ -78,7 +78,7 @@ _strace() return ;; -*S) - COMPREPLY=( $(compgen -W 'time calls name nothing' -- "$cur") ) + COMPREPLY=($(compgen -W 'time calls name nothing' -- "$cur")) return ;; -*u) @@ -87,13 +87,13 @@ _strace() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) else - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) fi fi } && -complete -F _strace -o default strace + complete -F _strace -o default strace # ex: filetype=sh diff --git a/completions/strings b/completions/strings index b4e13ab6..059f5571 100644 --- a/completions/strings +++ b/completions/strings @@ -6,21 +6,21 @@ _strings() _init_completion -s || return case $prev in - --help|--version|--bytes|-!(-*)[hvVn]) + --help | --version | --bytes | -!(-*)[hvVn]) return ;; - --radix|-!(-*)t) - COMPREPLY=( $(compgen -W 'o d x' -- "$cur") ) + --radix | -!(-*)t) + COMPREPLY=($(compgen -W 'o d x' -- "$cur")) return ;; - --target|-!(-*)T) - COMPREPLY=( $(compgen -W '$(LC_ALL=C "$1" --help 2>/dev/null | \ + --target | -!(-*)T) + COMPREPLY=($(compgen -W '$(LC_ALL=C "$1" --help 2>/dev/null | \ command sed -ne "s/: supported targets: \(.*\)/\1/p")' \ - -- "$cur") ) + -- "$cur")) return ;; - --encoding|-!(-*)e) - COMPREPLY=( $(compgen -W 's S b l B L' -- "$cur") ) + --encoding | -!(-*)e) + COMPREPLY=($(compgen -W 's S b l B L' -- "$cur")) return ;; esac @@ -28,18 +28,18 @@ _strings() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return elif [[ $cur == @* ]]; then cur=${cur:1} _filedir - COMPREPLY=( "${COMPREPLY[@]/#/@}" ) + COMPREPLY=("${COMPREPLY[@]/#/@}") return fi _filedir } && -complete -F _strings strings + complete -F _strings strings # ex: filetype=sh diff --git a/completions/sudo b/completions/sudo index 1b8e508f..c9a806ba 100644 --- a/completions/sudo +++ b/completions/sudo @@ -9,48 +9,48 @@ _sudo() [[ $1 == *sudoedit ]] && mode=edit [[ $mode == normal ]] && - for (( i=1; i <= cword; i++ )); do - if [[ ${words[i]} != -* ]]; then - local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin - local root_command=${words[i]} - _command_offset $i - return - fi - if [[ ${words[i]} == -@(!(-*)e*|-edit) ]]; then - mode=edit - break - fi - [[ ${words[i]} == \ - -@(user|other-user|group|close-from|prompt|!(-*)[uUgCp]) ]] \ - && ((i++)) - done + for ((i = 1; i <= cword; i++)); do + if [[ ${words[i]} != -* ]]; then + local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin + local root_command=${words[i]} + _command_offset $i + return + fi + if [[ ${words[i]} == -@(!(-*)e*|-edit) ]]; then + mode=edit + break + fi + [[ ${words[i]} == \ + -@(user|other-user|group|close-from|prompt|!(-*)[uUgCp]) ]] && + ((i++)) + done case "$prev" in - --user|--other-user|-!(-*)[uU]) - COMPREPLY=( $(compgen -u -- "$cur") ) + --user | --other-user | -!(-*)[uU]) + COMPREPLY=($(compgen -u -- "$cur")) return ;; - --group|-!(-*)g) - COMPREPLY=( $(compgen -g -- "$cur") ) + --group | -!(-*)g) + COMPREPLY=($(compgen -g -- "$cur")) return ;; - --close-from|--prompt|-!(-*)[Cp]) + --close-from | --prompt | -!(-*)[Cp]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi if [[ $mode == edit ]]; then _filedir fi } && -complete -F _sudo sudo sudoedit + complete -F _sudo sudo sudoedit # ex: filetype=sh diff --git a/completions/svcadm b/completions/svcadm index f23af1ff..5269c7be 100644 --- a/completions/svcadm +++ b/completions/svcadm @@ -20,14 +20,14 @@ # began to type svc:. In that case we will propose only the complete FMRI beginning with the # pattern # -_smf_complete_fmri () +_smf_complete_fmri() { local cur="$1" prefix="$2" local cur_prefix fmri fmri_list="" local exact_mode pattern - if [[ "$cur" == $prefix* ]]; then - [[ "$cur" == $prefix ]] && cur+="/" + if [[ $cur == $prefix* ]]; then + [[ $cur == "$prefix" ]] && cur+="/" pattern="$cur*" exact_mode=1 else @@ -38,18 +38,21 @@ _smf_complete_fmri () for fmri in $(svcs -H -o FMRI "$pattern" 2>/dev/null); do local fmri_part_list fmri_part - if [[ -z "$exact_mode" ]]; then + if [[ -z $exact_mode ]]; then fmri=${fmri#$prefix/} # we generate all possibles abbrevations for the FMRI # no need to have a generic loop as we will have a finite # number of components - local OIFS="$IFS"; IFS="/"; set -- $fmri; IFS="$OIFS" + local ifs="$IFS" + IFS="/" + set -- $fmri + IFS=$ifs case $# in - 1) fmri_part_list=" $1";; - 2) fmri_part_list=" $2 $1/$2";; - 3) fmri_part_list=" $3 $2/$3 $1/$2/$3";; - 4) fmri_part_list=" $4 $3/$4 $2/$3/$4 $1/$2/$3/$4";; + 1) fmri_part_list=" $1" ;; + 2) fmri_part_list=" $2 $1/$2" ;; + 3) fmri_part_list=" $3 $2/$3 $1/$2/$3" ;; + 4) fmri_part_list=" $4 $3/$4 $2/$3/$4 $1/$2/$3/$4" ;; esac else fmri_part_list="$fmri" @@ -58,28 +61,28 @@ _smf_complete_fmri () # Here we make sure the completions begins with the pattern and # we cut them at the first slash for fmri_part in $fmri_part_list; do - [[ "$fmri_part" == $cur* ]] || continue + [[ $fmri_part == $cur* ]] || continue local first_part=${fmri_part#$cur_prefix} first_part=$cur_prefix${first_part%%/*} - [[ "$first_part" != "$fmri_part" ]] && first_part+="/" + [[ $first_part != "$fmri_part" ]] && first_part+="/" fmri_list+=" $first_part" done done - COMPREPLY=( $fmri_list ) + COMPREPLY=($fmri_list) # here we want to detect if there only one completion proposed and that # it ends with a slash. That means the users will still have to complete # after, so we gain him one tab keystroke by immediately proposing the # next completion alternatives local i=${#COMPREPLY[*]} - if [[ $i -gt 0 ]] && [[ "${COMPREPLY[$((--i))]}" == */ ]]; then + if [[ $i -gt 0 && ${COMPREPLY[--i]} == */ ]]; then # we have to iterate through the list as we may have duplicate - while [[ $i -ne 0 ]]; do - [[ "${COMPREPLY[$i]}" != "${COMPREPLY[$((i - 1))]}" ]] && break + while ((i != 0)); do + [[ ${COMPREPLY[i]} != "${COMPREPLY[i - 1]}" ]] && break ((i--)) done - if [[ $i -eq 0 ]]; then + if ((i == 0)); then _smf_complete_fmri "${COMPREPLY[0]}" "$prefix" return fi @@ -90,12 +93,12 @@ _smf_complete_fmri () # it from darcs completion code :) local colonprefixes=${cur%"${cur##*:}"} local i=${#COMPREPLY[*]} - while [ $((--i)) -ge 0 ]; do - COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"} + while ((i-- > 0)); do + COMPREPLY[i]=${COMPREPLY[i]#"$colonprefixes"} done } -_svcadm () +_svcadm() { local cur prev words cword _init_completion -n : || return @@ -103,34 +106,38 @@ _svcadm () local command_list="enable disable restart refresh clear mark milestone" local command i - for (( i=1; i < $cword; i++ )); do + for ((i = 1; i < cword; i++)); do if [[ ${words[i]} == @(enable|disable|restart|refresh|clear|mark|milestone) ]]; then command=${words[i]} fi done - if [[ -z "$command" ]]; then - if [[ ${cur} == -* ]] ; then - COMPREPLY=( $(compgen -W "-v" -- ${cur}) ) + if [[ ! -v command ]]; then + if [[ ${cur} == -* ]]; then + COMPREPLY=($(compgen -W "-v" -- ${cur})) else - COMPREPLY=( $(compgen -W "$command_list" -- ${cur}) ) + COMPREPLY=($(compgen -W "$command_list" -- ${cur})) fi else if [[ ${cur} == -* ]]; then case "$command" in enable) - COMPREPLY=( $(compgen -W "-r -s -t" -- ${cur}) );; + COMPREPLY=($(compgen -W "-r -s -t" -- ${cur})) + ;; disable) - COMPREPLY=( $(compgen -W "-s -t" -- ${cur}) );; + COMPREPLY=($(compgen -W "-s -t" -- ${cur})) + ;; mark) - COMPREPLY=( $(compgen -W "-I -t" -- ${cur}) );; + COMPREPLY=($(compgen -W "-I -t" -- ${cur})) + ;; milestone) - COMPREPLY=( $(compgen -W "-d" -- ${cur}) );; + COMPREPLY=($(compgen -W "-d" -- ${cur})) + ;; esac else - if [[ "$command" == "mark" ]] && [[ "$prev" != @(degraded|maintenance) ]]; then - COMPREPLY=( $(compgen -W "degraded maintenance" -- ${cur}) ) - elif [[ "$command" == "milestone" ]]; then + if [[ $command == "mark" ]] && [[ $prev != @(degraded|maintenance) ]]; then + COMPREPLY=($(compgen -W "degraded maintenance" -- ${cur})) + elif [[ $command == "milestone" ]]; then _smf_complete_fmri "${cur}" "svc:/milestone" else _smf_complete_fmri "${cur}" "svc:" @@ -138,6 +145,6 @@ _svcadm () fi fi } && -complete -F _svcadm svcadm + complete -F _svcadm svcadm # ex: filetype=sh diff --git a/completions/svk b/completions/svk index f94356e1..9079df1c 100644 --- a/completions/svk +++ b/completions/svk @@ -14,15 +14,15 @@ _svk() propget pg pget proplist pl plist propset ps pset pull push resolved revert smerge sm status st stat switch sw sync sy update up verify' - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--version' -- "$cur")) else - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + COMPREPLY=($(compgen -W "$commands" -- "$cur")) fi else case $prev in - -F|--file|--targets) + -F | --file | --targets) _filedir return ;; @@ -34,50 +34,50 @@ _svk() command=${words[1]} - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # possible options for the command case $command in add) options=' --non-recursive -N -q --quiet' ;; - blame|annotate|ann|praise) + blame | annotate | ann | praise) options='-r --revisions -x --cross' ;; cat) options='-r --revision' ;; - checkout|co) + checkout | co) options='-r --revision -q --quiet -N --non-recursive -l --list -d --detach --export --relocate --purge' ;; cleanup) options='-a --all' ;; - cmerge|cm) + cmerge | cm) options='-c --change -l --log -r --revision -a --auto --verbatim --no-ticket -m --message -F --file --template --encoding -P --patch -S --sign -C --check-only --direct' ;; - commit|ci) + commit | ci) options='--import -m --message -F --file --encoding --template -P --patch -S --sign -C --check-only -N --non-recursive --direct' ;; - copy|cp) + copy | cp) options='-r --revision -p --parent -q --quiet -m --message -F --file --template --encoding -P --patch -S --sign -C --check-only --direct' ;; - delete|del|remove|rm) + delete | del | remove | rm) options='-k --keep-local -m --message -F --file --encoding --template -P --patch -S --sign -C --check-only --direct' ;; - depotmap|depot) + depotmap | depot) options='-i --init -l --list -d --detach --relocate' ;; - diff|di) + diff | di) options='-r --revision -s --summarize -b --verbose -N --non-recursive' ;; @@ -86,7 +86,7 @@ _svk() -F --file --template --encoding -P --patch -S --sign -C --check-only -N --non-recursive --direct' ;; - list|ls) + list | ls) options='-r --revision -v --verbose -R --recursive -d --depth -f --full-path' ;; @@ -101,7 +101,7 @@ _svk() --template --encoding -P --patch -S --sign -C --check-only --direct' ;; - mirror|mi) + mirror | mi) options='-l --list -d --detach --relocate --recover --unlock --upgrade' ;; @@ -110,7 +110,7 @@ _svk() --encoding -P --patch -S --sign -C --check-only --direct' ;; - move|mv|rename|ren) + move | mv | rename | ren) options='-r --revision -p --parent -q --quiet -m --message -F --file --encoding --template -P --patch -S --sign -C --check-only --direct' @@ -118,20 +118,20 @@ _svk() patch) options='--depot' ;; - propdel|propset|pdel|pset|pd|ps) + propdel | propset | pdel | pset | pd | ps) options='-R --recursive -r --revision --revprop -m --message -F --file --template --encoding -P --patch -S --sign -C --check-only -q --quiet --direct' ;; - propedit|pedit|pe) + propedit | pedit | pe) options='-R --recursive -r --revision --revprop -m --message -F --file --template --encoding -P --patch -S --sign -C --check-only --direct' ;; - propget|pget|pg) + propget | pget | pg) options='-R --recursive -r --revision --revprop --strict' ;; - proplist|plist|pl) + proplist | plist | pl) options='-R --recursive -v --verbose -r --revision --revprop' ;; @@ -148,59 +148,59 @@ _svk() revert) options='-R --recursive -q --quiet' ;; - smerge|sm) + smerge | sm) options='-I --incremental -l --log -B --baseless -b --base -s --sync -t --to -f --from --verbatim --no-ticket --track-rename --host --remoterev -m --message -F --file --template --encoding -P --patch -S --sign -C --check-only --direct' ;; - status|stat|st) + status | stat | st) options='-q --quiet --no-ignore -N --non-recursive -v --verbose' ;; - switch|sw) + switch | sw) options='-r --revision -d --detach -q --quiet' ;; - sync|sy) + sync | sy) options='-a --all -s --skipto -t --torev' ;; - update|up) + update | up) options='-r --revision -N --non-recursive -C --check-only -s --sync -m --merge -q --quiet' ;; esac options+=" --help -h" - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) else case $command in - help|h|\?) - COMPREPLY=( $(compgen -W "$commands environment commands - intro" -- "$cur") ) + help | h | \?) + COMPREPLY=($(compgen -W "$commands environment commands + intro" -- "$cur")) ;; admin) - COMPREPLY=( $(compgen -W 'help deltify dump hotcopy + COMPREPLY=($(compgen -W 'help deltify dump hotcopy list-dblogs list-unused-dblogs load lstxns recover - rmtxns setlog verify rmcache' -- "$cur") ) + rmtxns setlog verify rmcache' -- "$cur")) ;; patch) - COMPREPLY=( $(compgen -W '--ls --list --cat --view + COMPREPLY=($(compgen -W '--ls --list --cat --view --regen --regenerate --up --update --apply --rm - --delete' -- "$cur") ) + --delete' -- "$cur")) ;; sync) - COMPREPLY=( $(compgen -W "$($1 mirror --list \ - 2>/dev/null | awk '/^\//{print $1}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 mirror --list \ + 2>/dev/null | awk '/^\//{print $1}')" -- "$cur")) ;; - co|checkout|push|pull) - if [[ "$cur" == //*/* ]]; then + co | checkout | push | pull) + if [[ $cur == //*/* ]]; then path=${cur%/*}/ else path=// fi - COMPREPLY=( $(compgen -W "$($1 list $path 2>/dev/null | \ - command sed -e 's|\(.*\)|'$path'\1|')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 list $path 2>/dev/null | + command sed -e 's|\(.*\)|'$path'\1|')" -- "$cur")) ;; *) _filedir @@ -209,6 +209,6 @@ _svk() fi fi } && -complete -F _svk svk + complete -F _svk svk # ex: filetype=sh diff --git a/completions/sync_members b/completions/sync_members index 653c0ea9..397f8b08 100644 --- a/completions/sync_members +++ b/completions/sync_members @@ -6,11 +6,11 @@ _sync_members() _init_completion -s || return case $prev in - -w|-g|-d|--welcome-msg|--goodbye-msg|--digest) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + -w | -g | -d | --welcome-msg | --goodbye-msg | --digest) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - -d|--file) + --file) _filedir return ;; @@ -18,14 +18,14 @@ _sync_members() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--no-change --welcome-msg --goodbye-msg - --digest --notifyadmin --file --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--no-change --welcome-msg --goodbye-msg + --digest --notifyadmin --file --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _sync_members sync_members + complete -F _sync_members sync_members # ex: filetype=sh diff --git a/completions/synclient b/completions/synclient index e7371cb7..c4a0d42f 100644 --- a/completions/synclient +++ b/completions/synclient @@ -6,19 +6,19 @@ _synclient() _init_completion -n = || return case $prev in - -\?|-h|-V) + -\? | -h | -V) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) elif [[ $cur != *=?* ]]; then - COMPREPLY=( $(compgen -S = -W '$($1 -l 2>/dev/null | \ - awk "/^[ \t]/ { print \$1 }")' -- "$cur") ) + COMPREPLY=($(compgen -S = -W '$($1 -l 2>/dev/null | \ + awk "/^[ \t]/ { print \$1 }")' -- "$cur")) compopt -o nospace fi } && -complete -F _synclient synclient + complete -F _synclient synclient # ex: filetype=sh diff --git a/completions/sysbench b/completions/sysbench index fc942048..0af7cc33 100644 --- a/completions/sysbench +++ b/completions/sysbench @@ -6,84 +6,84 @@ _sysbench() _init_completion -s || return case $prev in - --num-threads|--max-requests|--max-time|--thread-stack-size| \ - --help|--version|help|version) + --num-threads | --max-requests | --max-time | --thread-stack-size | \ + --help | --version | help | version) return ;; - --init-rng|--debug|--validate) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + --init-rng | --debug | --validate) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; --test) - COMPREPLY=( $(compgen -W 'fileio cpu memory threads mutex oltp' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'fileio cpu memory threads mutex oltp' \ + -- "$cur")) return ;; --cpu-max-prime) return ;; --file-test-mode) - COMPREPLY=( $(compgen -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' \ + -- "$cur")) return ;; --file-io-mode) - COMPREPLY=( $(compgen -W 'sync async fastmmap slowmmap' -- "$cur") ) + COMPREPLY=($(compgen -W 'sync async fastmmap slowmmap' -- "$cur")) return ;; --file-extra-flags) - COMPREPLY=( $(compgen -W 'sync dsync direct' -- "$cur") ) + COMPREPLY=($(compgen -W 'sync dsync direct' -- "$cur")) return ;; - --file-fsync-all|--file-fsync-end) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + --file-fsync-all | --file-fsync-end) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; --file-fsync-mode) - COMPREPLY=( $(compgen -W 'fsync fdatasync' -- "$cur") ) + COMPREPLY=($(compgen -W 'fsync fdatasync' -- "$cur")) return ;; --memory-scope) - COMPREPLY=( $(compgen -W 'global local' -- "$cur") ) + COMPREPLY=($(compgen -W 'global local' -- "$cur")) return ;; --memory-hugetlb) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; --memory-oper) - COMPREPLY=( $(compgen -W 'read write none' -- "$cur") ) + COMPREPLY=($(compgen -W 'read write none' -- "$cur")) return ;; --memory-access-mode) - COMPREPLY=( $(compgen -W 'seq rnd' -- "$cur") ) + COMPREPLY=($(compgen -W 'seq rnd' -- "$cur")) return ;; --oltp-test-mode) - COMPREPLY=( $(compgen -W 'simple complex nontrx sp' -- "$cur") ) + COMPREPLY=($(compgen -W 'simple complex nontrx sp' -- "$cur")) return ;; - --oltp-read-only|--oltp-skip-trx|--oltp-quto-inc|--mysql-ssl) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + --oltp-read-only | --oltp-skip-trx | --oltp-quto-inc | --mysql-ssl) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; --oltp-nontrx-mode) - COMPREPLY=( $(compgen -W 'select update_key update_nokey insert - delete' -- "$cur") ) + COMPREPLY=($(compgen -W 'select update_key update_nokey insert + delete' -- "$cur")) return ;; --oltp-dist-type) - COMPREPLY=( $(compgen -W 'uniform gaussian special' -- "$cur") ) + COMPREPLY=($(compgen -W 'uniform gaussian special' -- "$cur")) return ;; --db-driver) - COMPREPLY=( $(compgen -W "$($1 --test=oltp help 2>/dev/null | + COMPREPLY=($(compgen -W "$($1 --test=oltp help 2>/dev/null | command sed -e '/^.*database drivers:/,/^$/!d' \ - -ne 's/^ *\([^ ]*\) .*/\1/p')" -- "$cur") ) + -ne 's/^ *\([^ ]*\) .*/\1/p')" -- "$cur")) return ;; --db-ps-mode) - COMPREPLY=( $(compgen -W 'auto disable' -- "$cur") ) + COMPREPLY=($(compgen -W 'auto disable' -- "$cur")) return ;; --mysql-socket) @@ -91,12 +91,12 @@ _sysbench() return ;; --mysql-table-engine) - COMPREPLY=( $(compgen -W 'myisam innodb bdb heap ndbcluster - federated' -- "$cur") ) + COMPREPLY=($(compgen -W 'myisam innodb bdb heap ndbcluster + federated' -- "$cur")) return ;; --mysql-engine-trx) - COMPREPLY=( $(compgen -W 'yes no auto' -- "$cur") ) + COMPREPLY=($(compgen -W 'yes no auto' -- "$cur")) return ;; --*) @@ -106,7 +106,8 @@ _sysbench() # find out which test we're running local i test - for (( i=1 ; $i < ${#words[@]}-1 ; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do + # TODO --test= is deprecated, bare test name preferred if [[ ${words[i]} == --test* ]]; then test=${words[i]#*=} break @@ -114,18 +115,18 @@ _sysbench() done local opts=$(_parse_help "$1") - if [[ $test ]]; then - local help=( $(_parse_help "$1" "--test=$test help") ) - opts="${opts[@]/--test=/} ${help[@]} prepare run cleanup help version" + if [[ -v test ]]; then + local help=($(_parse_help "$1" "--test=$test help")) + opts="${opts/--test=/} ${help[*]} prepare run cleanup help version" fi - if [[ "$cur" == -* || ! $test ]]; then - COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* || ! -v test ]]; then + COMPREPLY=($(compgen -W "$opts" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - COMPREPLY=( $(compgen -W "prepare run cleanup help version" -- "$cur") ) + COMPREPLY=($(compgen -W "prepare run cleanup help version" -- "$cur")) fi } && -complete -F _sysbench sysbench + complete -F _sysbench sysbench # ex: filetype=sh diff --git a/completions/sysctl b/completions/sysctl index 6eb3f391..005452da 100644 --- a/completions/sysctl +++ b/completions/sysctl @@ -6,10 +6,10 @@ _sysctl() _init_completion || return case $prev in - --help|--version|--pattern|-!(-*)[hVr]) + --help | --version | --pattern | -!(-*)[hVr]) return ;; - --load|-!(-*)[pf]) + --load | -!(-*)[pf]) _filedir conf return ;; @@ -17,15 +17,15 @@ _sysctl() if [[ $cur == -* ]]; then local opts="$(_parse_help "$1")" - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) else local suffix= [[ $prev == -w ]] && suffix="=" - COMPREPLY=( $(compgen -S "$suffix" -W \ - "$(PATH="$PATH:/sbin" $1 -N -a 2>/dev/null)" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -S "$suffix" -W \ + "$(PATH="$PATH:/sbin" $1 -N -a 2>/dev/null)" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _sysctl sysctl + complete -F _sysctl sysctl # ex: filetype=sh diff --git a/completions/tar b/completions/tar index fda739c4..04b7fc07 100644 --- a/completions/tar +++ b/completions/tar @@ -47,10 +47,11 @@ __gtar_parse_help_opt() separator=" " case "$opt" in - --*) - ;; + --*) ;; + -\?) - return ;; + return + ;; -*) opttype=short opt=${opt##-} @@ -76,7 +77,6 @@ __gtar_parse_help_opt() eval "$optvar=\"\$$optvar$separator\"\"$opt\"" } - __gtar_parse_help_line() { local i @@ -84,18 +84,18 @@ __gtar_parse_help_line() for i in $1; do case "$i" in # regular options - --*|-*) + --* | -*) __gtar_parse_help_opt "$i" "$2" ;; # end once there is single non-option word *) break + ;; esac done } - __gnu_tar_parse_help() { local str line arg @@ -104,7 +104,7 @@ __gnu_tar_parse_help() # options on lines beginning with spaces. After that, there is one # or more options separated by ', ' separator string. We are matching # like this then: ^<spaces>(<separator>?<option>)+<whatever>$ - if [[ "$line" =~ \ + if [[ $line =~ \ ^[[:blank:]]{1,10}(((,[[:blank:]])?(--?([\]\[a-zA-Z0-9?=-]+))(,[[:space:]])?)+).*$ ]]; then line=${BASH_REMATCH[1]} @@ -115,8 +115,8 @@ __gnu_tar_parse_help() # description in GNU help output mentions arguments. So the $line # variable may contain e.g. '-X, --XXX[=NAME], -XXX2[=NAME]'. arg=none - if [[ "$line" =~ --[A-Za-z0-9-]+(\[?)= ]]; then - [[ -n "${BASH_REMATCH[1]}" ]] && arg=opt || arg=req + if [[ $line =~ --[A-Za-z0-9-]+(\[?)= ]]; then + [[ -n ${BASH_REMATCH[1]} ]] && arg=opt || arg=req fi __gtar_parse_help_line "$str" "$arg" @@ -124,14 +124,11 @@ __gnu_tar_parse_help() done <<<"$(tar --help)" long_opts="\ - $long_arg_none\ - $long_arg_opt\ - $long_arg_req" + $long_arg_none $long_arg_opt $long_arg_req" short_opts="$short_arg_none$short_arg_opt$short_arg_req" } - # Hack: parse --warning keywords from tar's error output __gtar_parse_warnings() { @@ -143,32 +140,30 @@ __gtar_parse_warnings() done } - # Helper to obtain last character of string. __tar_last_char() { - echo "${1: $(( ${#1} - 1))}" + echo "${1:$((${#1} - 1))}" } - __tar_parse_old_opt() { local first_word char # current word is the first word - [[ "$cword" -eq 1 && -n "$cur" && "${cur:0:1}" != '-' ]] \ - && old_opt_progress=1 + [[ $cword -eq 1 && -n $cur && ${cur:0:1} != '-' ]] && + old_opt_progress=1 # check that first argument does not begin with "-" first_word=${words[1]} - [[ -n "$first_word" && "${first_word:0:1}" != "-" ]] \ - && old_opt_used=1 + [[ -n $first_word && ${first_word:0:1} != "-" ]] && + old_opt_used=1 # parse the old option (if present) contents to allow later code expect # corresponding arguments - if [[ $old_opt_used -eq 1 ]]; then + if ((old_opt_used == 1)); then char=${first_word:0:1} - while [[ -n "$char" ]]; do + while [[ -n $char ]]; do if __tar_is_argreq "$char"; then old_opt_parsed+=("$char") fi @@ -178,11 +173,10 @@ __tar_parse_old_opt() fi } - # Make the analysis of whole command line. __tar_preparse_cmdline() { - local first_arg my_args tmparg i modes="ctxurdA" + local first_arg i modes="ctxurdA" shift # progname @@ -191,7 +185,7 @@ __tar_preparse_cmdline() first_arg=1 for i in "$@"; do case "$i" in - --delete|--test-label) + --delete | --test-label) tar_mode=${i:2:100} tar_mode_arg=$i break @@ -207,7 +201,7 @@ __tar_preparse_cmdline() ;; *[$modes]*) # Only the first arg may be "MODE" without leading dash - if [[ $first_arg -eq 1 ]]; then + if ((first_arg == 1)); then tar_mode=${i//[^$modes]/} tar_mode=${tar_mode:0:1} tar_mode_arg=$i @@ -218,7 +212,6 @@ __tar_preparse_cmdline() done } - # Generate completions for -f/--file. __tar_file_option() { @@ -235,7 +228,6 @@ __tar_file_option() esac } - # Returns truth if option requires argument. No equal sign must be pasted. # Accepts option in format: 'c', '-c', '--create' __tar_is_argreq() @@ -244,29 +236,28 @@ __tar_is_argreq() opt=$1 case "$opt" in -[A-Za-z0-9?]) - [[ "$short_arg_req" =~ ${opt##-} ]] && return 0 + [[ $short_arg_req =~ ${opt##-} ]] && return 0 ;; [A-Za-z0-9?]) - [[ "$short_arg_req" =~ ${opt} ]] && return 0 + [[ $short_arg_req =~ ${opt} ]] && return 0 ;; --*) - [[ "$long_arg_req" =~ [[:blank:]]$opt=[[:blank:]] ]] && return 0 + [[ $long_arg_req =~ [[:blank:]]$opt=[[:blank:]] ]] && return 0 ;; esac return 1 } - # Called only for short parameter __tar_complete_mode() { - local short_modes has_mode rawopt generated \ - allshort_raw_unused allshort_raw \ - filler i + local short_modes rawopt generated \ + allshort_raw_unused allshort_raw \ + filler i short_modes="ctx" - [[ -z "$basic_tar" ]] && short_modes="ctxurdA" + [[ ! -v basic_tar ]] && short_modes="ctxurdA" # Remove prefix when needed rawopt=${cur#-} @@ -275,95 +266,92 @@ __tar_complete_mode() allshort_raw=${short_opts//[- ]/} # init the 'mode' option if no option is in ${cur} - if [[ "$tar_mode" == none ]]; then + if [[ $tar_mode == none ]]; then # when user passed something like 'tar cf' do not put the '-' before filler= - if [[ -z "$cur" && -z "$basic_tar" ]]; then + if [[ -z $cur && ! -v basic_tar ]]; then filler=- fi generated="" - for (( i=0 ; 1; i++ )); do - local c="${short_modes:$i:1}" - [[ -z "$c" ]] && break + for ((i = 0; 1; i++)); do + local c="${short_modes:i:1}" + [[ -z $c ]] && break generated+=" $filler$cur$c" done - COMPREPLY=( $(compgen -W "$generated" ) ) + COMPREPLY=($(compgen -W "$generated")) return 0 fi # The last short option requires argument, like '-cf<TAB>'. Cut the # completion here to enforce argument processing. - if [[ "$old_opt_progress" -eq 0 ]] \ - && __tar_is_argreq "$(__tar_last_char "$cur")"; then - COMPREPLY=( "$cur" ) && return 0 + if ((old_opt_progress == 0)) && + __tar_is_argreq "$(__tar_last_char "$cur")"; then + COMPREPLY=("$cur") && return 0 fi allshort_raw_unused=${allshort_raw//[$rawopt]/} - if [[ "$tar_mode" != none ]]; then - allshort_raw_unused=${allshort_raw_unused//[$short_modes]} + if [[ $tar_mode != none ]]; then + allshort_raw_unused=${allshort_raw_unused//[$short_modes]/} fi generated= - for (( i=0 ; 1; i++ )); do - local c="${allshort_raw_unused:$i:1}" - [[ -z "$c" ]] && break + for ((i = 0; 1; i++)); do + local c="${allshort_raw_unused:i:1}" + [[ -z $c ]] && break generated+=" $cur$c" done - COMPREPLY=( $(compgen -W "$generated") ) + COMPREPLY=($(compgen -W "$generated")) return 0 } - __gtar_complete_lopts() { local rv - COMPREPLY=( $(compgen -W "$long_opts" -- "$cur") ) + COMPREPLY=($(compgen -W "$long_opts" -- "$cur")) rv=$? - [[ $COMPREPLY == *= ]] && compopt -o nospace + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return $rv } - __gtar_complete_sopts() { local generated short_mode_opts i c short_mode_opts="ctxurdA" generated=${short_opts//[$short_mode_opts]/} - for (( i=0 ; 1; i++ )); do - c="${allshort_raw_unused:$i:1}" - [[ -z "$c" ]] && break + for ((i = 0; 1; i++)); do + c="${allshort_raw_unused:i:1}" + [[ -z $c ]] && break generated+=" $cur$c" done - COMPREPLY=( $(compgen -W "$generated" -- "$cur") ) + COMPREPLY=($(compgen -W "$generated" -- "$cur")) } - __tar_try_mode() { case "$cur" in --*) # posix tar does not support long opts - [[ -n "$basic_tar" ]] && return 0 + [[ -v basic_tar ]] && return 0 __gtar_complete_lopts return $? ;; -*) # posix tar does not support short optios - [[ -n "$basic_tar" ]] && return 0 + [[ -v basic_tar ]] && return 0 __tar_complete_mode && return 0 ;; *) - if [[ "$cword" -eq 1 || "$tar_mode" == none ]]; then + if [[ $cword -eq 1 || $tar_mode == none ]]; then __tar_complete_mode && return 0 fi ;; @@ -371,31 +359,27 @@ __tar_try_mode() return 1 } - __tar_adjust_PREV_from_old_option() { # deal with old style arguments here # $ tar cfTC # expects this sequence of arguments: # $ tar cfTC ARCHIVE_FILE PATTERNS_FILE CHANGE_DIR - if [[ "$old_opt_used" -eq 1 && "$cword" -gt 1 \ - && "$cword" -lt $(( ${#old_opt_parsed[@]} + 2 )) ]]; - then + if ((old_opt_used == 1 && cword > 1 && \ + cword < ${#old_opt_parsed[@]} + 2)); then # make e.g. 'C' option from 'cffCT' - prev="-${old_opt_parsed[ $cword - 2 ]}" + prev="-${old_opt_parsed[cword - 2]}" fi } - __tar_extract_like_mode() { local i for i in x d t delete; do - [[ "$tar_mode" == "$i" ]] && return 0 + [[ $tar_mode == "$i" ]] && return 0 done return 1 } - __tar_try_list_archive() { local tarball tarbin untar i @@ -416,13 +400,13 @@ __tar_try_list_archive() break fi done - if [[ -n "$tarball" ]]; then + if [[ -n $tarball ]]; then local IFS=$'\n' COMPREPLY=($(compgen -o filenames -W "$( $tarbin $untar "$tarball" 2>/dev/null | - while read line; do - printf "%q\n" "$(printf %q"\n" "$line")" - done + while read line; do + printf "%q\n" "$(printf %q"\n" "$line")" + done )" -- "$(printf "%q\n" "$cur")")) return 0 fi @@ -430,7 +414,7 @@ __tar_try_list_archive() __tar_cleanup_prev() { - if [[ "$prev" =~ ^-[a-zA-Z0-9?]*$ ]]; then + if [[ $prev =~ ^-[a-zA-Z0-9?]*$ ]]; then # transform '-caf' ~> '-f' prev="-$(__tar_last_char "$prev")" fi @@ -448,11 +432,11 @@ __tar_detect_ext() ?(-)*[cr]*f) ext='@(tar|gem|spkg)' case ${words[1]} in - *a*) ext="$tars" ;; - *z*) ext='t?(ar.)gz' ;; - *Z*) ext='ta@(r.Z|z)' ;; + *a*) ext="$tars" ;; + *z*) ext='t?(ar.)gz' ;; + *Z*) ext='ta@(r.Z|z)' ;; *[jy]*) ext='t@(?(ar.)bz?(2)|b2)' ;; - *J*) ext='t?(ar.)xz' ;; + *J*) ext='t?(ar.)xz' ;; esac ;; +([^ZzJjy])f) @@ -470,14 +454,13 @@ __tar_detect_ext() esac } - _gtar() { - local long_opts short_opts \ - long_arg_none long_arg_opt long_arg_req \ - short_arg_none short_arg_opt short_arg_req \ - tar_mode tar_mode_arg old_opt_progress=0 \ - old_opt_used=0 old_opt_parsed=() + local long_opts short_opts \ + long_arg_none="" long_arg_opt="" long_arg_req="" \ + short_arg_none="" short_arg_opt="" short_arg_req="" \ + tar_mode tar_mode_arg old_opt_progress=0 \ + old_opt_used=0 old_opt_parsed=() # Main mode, e.g. -x or -c (extract/creation) local tar_mode=none @@ -486,9 +469,9 @@ _gtar() # FIXME: handle long options local tar_mode_arg= - if [[ "$_TAR_OPT_DEBUG" == 1 ]]; then + if [[ -v BASHCOMP_TAR_OPT_DEBUG ]]; then set -x - PS4="\$BASH_SOURCE:\$LINENO: " + PS4='$BASH_SOURCE:$LINENO: ' fi local cur prev words cword split @@ -500,7 +483,7 @@ _gtar() __tar_preparse_cmdline "${words[@]}" - local ext tar untar + local ext __tar_detect_ext @@ -513,53 +496,53 @@ _gtar() # user (TODO: is there any sane way to deal with this?). This case # statement successes only if there already is PREV. case $prev in - --directory|-!(-*)C) + --directory | -!(-*)C) _filedir -d break ;; --atime-preserve) - COMPREPLY=( $(compgen -W 'replace system' -- "$cur") ) + COMPREPLY=($(compgen -W 'replace system' -- "$cur")) break ;; --group) - COMPREPLY=( $(compgen -g -- "$cur") ) + COMPREPLY=($(compgen -g -- "$cur")) break ;; --owner) - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) break ;; - --info-script|--new-volume-script|--rmt-command|--rsh-command|\ - --use-compress-program|-!(-*)[FI]) + --info-script | --new-volume-script | --rmt-command | --rsh-command | \ + --use-compress-program | -!(-*)[FI]) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) break ;; - --volno-file|--add-file|--files-from|--exclude-from|\ - --index-file|--listed-incremental|-!(-*)[TXg]) + --volno-file | --add-file | --files-from | --exclude-from | \ + --index-file | --listed-incremental | -!(-*)[TXg]) _filedir break ;; - --format|-!(-*)H) - COMPREPLY=( $(compgen -W 'gnu oldgnu pax posix ustar v7' \ - -- "$cur") ) + --format | -!(-*)H) + COMPREPLY=($(compgen -W 'gnu oldgnu pax posix ustar v7' \ + -- "$cur")) break ;; --quoting-style) - COMPREPLY=( $(compgen -W 'literal shell shell-always c c-maybe - escape locale clocale' -- "$cur") ) + COMPREPLY=($(compgen -W 'literal shell shell-always c c-maybe + escape locale clocale' -- "$cur")) break ;; --totals) - COMPREPLY=( $(compgen -W 'SIGHUP SIGQUIT SIGINT SIGUSR1 SIGUSR2' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'SIGHUP SIGQUIT SIGINT SIGUSR1 SIGUSR2' \ + -- "$cur")) break ;; --warning) - COMPREPLY=( $(compgen -W "$(__gtar_parse_warnings)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(__gtar_parse_warnings)" -- "$cur")) break ;; - --file|-!(-*)f) + --file | -!(-*)f) __tar_file_option "$ext" break ;; @@ -581,7 +564,7 @@ _gtar() ;; -!(-*)[a-zA-Z0-9?]) # argument required but no completion yet - [[ "$short_arg_req" =~ ${prev##-} ]] && break + [[ $short_arg_req =~ ${prev##-} ]] && break ;; esac @@ -612,7 +595,7 @@ _gtar() # the first argument must be "mode" argument or --param, if any of those # was truth - the 'break' statement would have been already called - [[ "$cword" -eq 1 ]] && break + ((cword == 1)) && break __tar_try_list_archive && break @@ -624,13 +607,12 @@ _gtar() break done # just-for-easy-break while - if [[ "$_TAR_OPT_DEBUG" == 1 ]]; then + if [[ -v BASHCOMP_TAR_OPT_DEBUG ]]; then set +x unset PS4 fi } - __tar_posix_prev_handle() { case "$prev" in @@ -640,19 +622,19 @@ __tar_posix_prev_handle() ;; -b) return 0 + ;; esac return 1 } - _posix_tar() { - local long_opts short_opts basic_tar \ - long_arg_none long_arg_opt long_arg_req \ - short_arg_none short_arg_opt short_arg_req \ - tar_mode tar_mode_arg old_opt_progress=0 \ - old_opt_used=1 old_opt_parsed=() + local long_opts short_opts basic_tar \ + long_arg_none="" long_arg_opt long_arg_req="" \ + short_arg_none short_arg_opt short_arg_req \ + tar_mode tar_mode_arg old_opt_progress=0 \ + old_opt_used=1 old_opt_parsed=() # Main mode, e.g. -x or -c (extract/creation) local tar_mode=none @@ -675,7 +657,7 @@ _posix_tar() __tar_preparse_cmdline "${words[@]}" - local ext tar untar + local ext __tar_detect_ext @@ -691,23 +673,22 @@ _posix_tar() _filedir } - _tar() { local cmd=${COMP_WORDS[0]} func line line="$($cmd --version 2>/dev/null)" case "$line" in - *GNU*) - func=_gtar - ;; - *) - func=_posix_tar - ;; + *GNU*) + func=_gtar + ;; + *) + func=_posix_tar + ;; esac $func "$@" # Install real completion for subsequent completions - if [ -n "${COMP_TAR_INTERNAL_PATHS:-}" ]; then + if [[ ${COMP_TAR_INTERNAL_PATHS-} ]]; then complete -F $func -o dirnames tar else complete -F $func tar @@ -715,17 +696,16 @@ _tar() unset -f _tar } - -if [ -n "${COMP_TAR_INTERNAL_PATHS:-}" ]; then - complete -F _tar -o dirnames tar - complete -F _gtar -o dirnames gtar - complete -F _posix_tar -o dirnames bsdtar - complete -F _posix_tar -o dirnames star +if [[ ${COMP_TAR_INTERNAL_PATHS-} ]]; then + complete -F _tar -o dirnames tar + complete -F _gtar -o dirnames gtar + complete -F _posix_tar -o dirnames bsdtar + complete -F _posix_tar -o dirnames star else - complete -F _tar tar - complete -F _gtar gtar - complete -F _posix_tar bsdtar - complete -F _posix_tar star + complete -F _tar tar + complete -F _gtar gtar + complete -F _posix_tar bsdtar + complete -F _posix_tar star fi # ex: filetype=sh diff --git a/completions/tcpdump b/completions/tcpdump index d93c8795..9a7c2e9c 100644 --- a/completions/tcpdump +++ b/completions/tcpdump @@ -10,7 +10,7 @@ _tcpdump() _filedir return ;; - --interface|-!(-*)i) + --interface | -!(-*)i) _available_interfaces -a return ;; @@ -19,46 +19,46 @@ _tcpdump() return ;; -!(-*)T) - COMPREPLY=( $(compgen -W 'aodv carp cnfp lmp pgm pgm_zmtp1 radius + COMPREPLY=($(compgen -W 'aodv carp cnfp lmp pgm pgm_zmtp1 radius resp rpc rtcp rtp rtcp snmp tftp vat vxlan wb zmtp1' \ - -- "$cur") ) + -- "$cur")) return ;; -!(-*)z) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; - --relinquish-privileges|-!(-*)Z) + --relinquish-privileges | -!(-*)Z) _allowed_users return ;; -!(-*)[BcCDEGMsWy]) return ;; - --time-stamp-type|-!(-*)j) - COMPREPLY=( $(compgen -W 'host host_lowprec host_hiprec adapter - adapter_unsynced' -- "$cur") ) + --time-stamp-type | -!(-*)j) + COMPREPLY=($(compgen -W 'host host_lowprec host_hiprec adapter + adapter_unsynced' -- "$cur")) return ;; - --direction|-!(-*)Q) - COMPREPLY=( $(compgen -W 'in out inout' -- "$cur") ) + --direction | -!(-*)Q) + COMPREPLY=($(compgen -W 'in out inout' -- "$cur")) return ;; --time-stamp-precision) - COMPREPLY=( $(compgen -W 'micro nano' -- "$cur") ) + COMPREPLY=($(compgen -W 'micro nano' -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _tcpdump tcpdump + complete -F _tcpdump tcpdump # ex: filetype=sh diff --git a/completions/tcpkill b/completions/tcpkill index 200cfc38..189d928e 100644 --- a/completions/tcpkill +++ b/completions/tcpkill @@ -12,11 +12,11 @@ _tcpkill() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-i -1 -2 -3 -4 -5 -6 -7 -8 -9' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-i -1 -2 -3 -4 -5 -6 -7 -8 -9' -- "$cur")) fi } && -complete -F _tcpkill tcpkill + complete -F _tcpkill tcpkill # ex: filetype=sh diff --git a/completions/tcpnice b/completions/tcpnice index 0302d46d..c6a94d6b 100644 --- a/completions/tcpnice +++ b/completions/tcpnice @@ -12,11 +12,11 @@ _tcpnice() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) fi } && -complete -F _tcpnice tcpnice + complete -F _tcpnice tcpnice # ex: filetype=sh diff --git a/completions/timeout b/completions/timeout index bcc9a865..32ff2e36 100644 --- a/completions/timeout +++ b/completions/timeout @@ -5,8 +5,8 @@ _timeout() local cur prev words cword split i found=false _init_completion -s || return - for (( i=1; i <= COMP_CWORD; i++ )); do - if [[ ${COMP_WORDS[i]} != -* && ${COMP_WORDS[i-1]} != = ]]; then + for ((i = 1; i <= COMP_CWORD; i++)); do + if [[ ${COMP_WORDS[i]} != -* && ${COMP_WORDS[i - 1]} != = ]]; then if $found; then _command_offset $i return @@ -17,10 +17,10 @@ _timeout() done case $prev in - --help|--version|--kill-after|-!(-*)k) + --help | --version | --kill-after | -!(-*)k) return ;; - --signal|-!(-*)s) + --signal | -!(-*)s) _signals return ;; @@ -30,10 +30,10 @@ _timeout() if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _timeout timeout + complete -F _timeout timeout # ex: filetype=sh diff --git a/completions/tipc b/completions/tipc index 830040d9..44ade360 100644 --- a/completions/tipc +++ b/completions/tipc @@ -1,20 +1,22 @@ # tipc(8) completion -*- shell-script -*- -_tipc_media() { +_tipc_media() +{ local optind=$1 - if [[ $cword -eq $optind ]]; then - COMPREPLY=( $(compgen -W 'media' -- $cur) ) + if ((cword == optind)); then + COMPREPLY=($(compgen -W 'media' -- $cur)) return 0 - elif [[ $cword -eq $optind+1 ]]; then - COMPREPLY=( $(compgen -W 'udp eth ib' -- $cur) ) + elif ((cword == optind + 1)); then + COMPREPLY=($(compgen -W 'udp eth ib' -- $cur)) return 0 fi return 1 } -_tipc_bearer() { +_tipc_bearer() +{ local optind=$1 local media i @@ -22,52 +24,54 @@ _tipc_bearer() { return fi - for ((i = 0; i < $cword; i++)); do - if [[ ${words[$i]} == 'media' ]]; then - media=${words[$(($i + 1))]} + for ((i = 0; i < cword; i++)); do + if [[ ${words[i]} == 'media' ]]; then + media=${words[i + 1]} fi done - if [[ $cword -eq $optind+2 ]]; then + if ((cword == optind + 2)); then case "$media" in - "udp") - COMPREPLY=( $(compgen -W 'name' -- $cur) ) - ;; - "eth" | "ib") - COMPREPLY=( $(compgen -W 'device' -- $cur) ) - ;; + "udp") + COMPREPLY=($(compgen -W 'name' -- $cur)) + ;; + "eth" | "ib") + COMPREPLY=($(compgen -W 'device' -- $cur)) + ;; esac - elif [[ $cword -eq $optind+3 ]]; then + elif ((cword == optind + 3)); then case "$media" in - "udp") - local names=$(tipc bearer list 2>/dev/null | awk -F: '/^udp:/ {print $2}') - COMPREPLY=( $(compgen -W '$names' -- $cur) ) - ;; - "eth") - local interfaces=$(command ls /sys/class/net/) - COMPREPLY=( $(compgen -W '$interfaces' -- $cur) ) - ;; + "udp") + local names=$(tipc bearer list 2>/dev/null | awk -F: '/^udp:/ {print $2}') + COMPREPLY=($(compgen -W '$names' -- $cur)) + ;; + "eth") + local interfaces=$(command ls /sys/class/net/) + COMPREPLY=($(compgen -W '$interfaces' -- $cur)) + ;; esac fi } -_tipc_link_opts() { - COMPREPLY=( $(compgen -W 'priority tolerance window' -- $cur) ) +_tipc_link_opts() +{ + COMPREPLY=($(compgen -W 'priority tolerance window' -- $cur)) } -_tipc_link() { +_tipc_link() +{ local optind=$1 local filter=$2 - if [[ $cword -eq $optind ]]; then - COMPREPLY=( $(compgen -W 'link' -- $cur) ) - elif [[ $cword -eq $optind+1 ]]; then + if ((cword == optind)); then + COMPREPLY=($(compgen -W 'link' -- $cur)) + elif ((cword == optind + 1)); then # awk drops link state and last trailing : - local links=$(tipc link list 2>/dev/null | \ + local links=$(tipc link list 2>/dev/null | awk '{print substr($1, 0, length($1))}') local -a exclude - [[ $filter == peers ]] && exclude=( -X broadcast-link ) - COMPREPLY=( $(compgen "${exclude[@]}" -W '$links' -- $cur) ) + [[ $filter == peers ]] && exclude=(-X broadcast-link) + COMPREPLY=($(compgen "${exclude[@]}" -W '$links' -- $cur)) fi } @@ -82,203 +86,204 @@ _tipc() # Flags can be placed anywhere in the commandline case "$cur" in -*) - COMPREPLY=( $(compgen -W '-h --help' -- $cur) ) + COMPREPLY=($(compgen -W '-h --help' -- $cur)) return ;; esac - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'bearer link media nametable node socket' -- $cur) ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'bearer link media nametable node socket' -- $cur)) return fi - case "${words[$optind]}" in - bearer) - (( optind++ )) + case "${words[optind]}" in + bearer) + ((optind++)) - if [[ $cword -eq $optind ]]; then - COMPREPLY=( $(compgen -W 'enable disable set get list' -- $cur) ) - return - fi - - case "${words[$optind]}" in - enable) - local media params - (( optind++ )) - - if [[ $cword -lt $optind+4 ]]; then - _tipc_bearer $optind + if ((cword == optind)); then + COMPREPLY=($(compgen -W 'enable disable set get list' -- $cur)) return fi - for ((i = 0; i < $cword; i++)); do - if [[ ${words[$i]} == 'media' ]]; then - media=${words[$(($i + 1))]} - fi - done - case "$media" in - "udp") - declare -a params=("localip" "localport" "remoteip" - "remoteport" "domain" "priority") - ;; - "eth" | "ib") - declare -a params=("domain" "priority") + case "${words[optind]}" in + enable) + local media params + ((optind++)) + + if ((cword < optind + 4)); then + _tipc_bearer $optind + return + fi + + for ((i = 0; i < cword; i++)); do + if [[ ${words[i]} == 'media' ]]; then + media=${words[i + 1]} + fi + done + case "$media" in + "udp") + declare -a params=("localip" "localport" "remoteip" + "remoteport" "domain" "priority") + ;; + "eth" | "ib") + declare -a params=("domain" "priority") + ;; + *) + return + ;; + esac + + # If the previous word was a known parameter, we assume a value for + # that key. Note that this would break if the user attempts to use + # a known key as value. + for i in "${params[@]}"; do + if [[ $prev == "$i" ]]; then + return + fi + done + + # In order not to print already used options, we remove them + for p in "${words[@]}"; do + for i in "${params[@]}"; do + if [[ $p == "$i" ]]; then + params=("${params[@]/$i/}") + fi + done + done + + COMPREPLY=($(compgen -W '${params[@]}' -- $cur)) ;; - *) - return + disable) + ((optind++)) + + _tipc_bearer $optind ;; - esac + get) + ((optind++)) - # If the previous word was a known paramater we assume a value for - # that key Note that this would break if the user attempts to use a - # kown key as value - for i in "${params[@]}"; do - if [[ $prev == $i ]]; then - return - fi - done - - # In order not to print already used options we remove them - for p in "${words[@]}"; do - for i in "${params[@]}"; do - if [[ $p == $i ]]; then - params=( "${params[@]/$i}" ) + if ((cword == optind)); then + _tipc_link_opts + elif ((cword >= optind + 1)); then + _tipc_bearer $((optind + 1)) fi - done - done - - COMPREPLY=( $(compgen -W '${params[@]}' -- $cur) ) - ;; - disable) - (( optind++ )) + ;; + set) + ((optind++)) - _tipc_bearer $optind + if ((cword == optind)); then + _tipc_link_opts + elif ((cword >= optind + 2)); then + _tipc_bearer $((optind + 2)) + fi + ;; + esac ;; - get) - (( optind++ )) + link) + ((optind++)) - if [[ $cword -eq $optind ]]; then - _tipc_link_opts - elif [[ $cword -ge $optind+1 ]]; then - _tipc_bearer $(($optind + 1)) + if ((cword == optind)); then + COMPREPLY=($(compgen -W 'get set list statistics' -- $cur)) + return fi - ;; - set) - (( optind++ )) - if [[ $cword -eq $optind ]]; then - _tipc_link_opts - elif [[ $cword -ge $optind+2 ]]; then - _tipc_bearer $(($optind + 2)) - fi - ;; - esac - ;; - link) - (( optind++ )) + case "${words[optind]}" in + get) + ((optind++)) - if [[ $cword -eq $optind ]]; then - COMPREPLY=( $(compgen -W 'get set list statistics' -- $cur) ) - return - fi + if ((cword == optind)); then + _tipc_link_opts + elif ((cword >= optind + 1)); then + _tipc_link $((optind + 1)) "peers" + fi + ;; + set) + ((optind++)) - case "${words[$optind]}" in - get) - (( optind++ )) + if ((cword == optind)); then + _tipc_link_opts + elif ((cword >= optind + 2)); then + _tipc_link $((optind + 2)) "peers" + fi + ;; + statistics) + ((optind++)) - if [[ $cword -eq $optind ]]; then - _tipc_link_opts - elif [[ $cword -ge $optind+1 ]]; then - _tipc_link $(($optind + 1)) "peers" - fi - ;; - set) - (( optind++ )) + if ((cword == optind)); then + COMPREPLY=($(compgen -W 'show reset' -- $cur)) + return + fi - if [[ $cword -eq $optind ]]; then - _tipc_link_opts - elif [[ $cword -ge $optind+2 ]]; then - _tipc_link $(($optind + 2)) "peers" - fi + case "${words[optind]}" in + show | reset) + _tipc_link $((optind + 1)) + ;; + esac + ;; + esac ;; - statistics) - (( optind++ )) + media) + ((optind++)) - if [[ $cword -eq $optind ]]; then - COMPREPLY=( $(compgen -W 'show reset' -- $cur) ) + if ((cword == optind)); then + COMPREPLY=($(compgen -W 'get set list' -- $cur)) return fi - case "${words[$optind]}" in - show|reset) - _tipc_link $(($optind + 1)) - ;; - esac - ;; - esac - ;; - media) - (( optind++ )) + case "${words[optind]}" in + get) + ((optind++)) - if [[ $cword -eq $optind ]]; then - COMPREPLY=( $(compgen -W 'get set list' -- $cur) ) - return - fi - - case "${words[$optind]}" in - get) - (( optind++ )) + if ((cword == optind)); then + _tipc_link_opts + elif ((cword >= optind + 1)); then + _tipc_media $((optind + 1)) + fi + ;; + set) + ((optind++)) - if [[ $cword -eq $optind ]]; then - _tipc_link_opts - elif [[ $cword -ge $optind+1 ]]; then - _tipc_media $(($optind + 1)) - fi + if ((cword == optind)); then + _tipc_link_opts + elif ((cword >= optind + 2)); then + _tipc_media $((optind + 2)) + fi + ;; + esac ;; - set) - (( optind++ )) + nametable) + ((optind++)) - if [[ $cword -eq $optind ]]; then - _tipc_link_opts - elif [[ $cword -ge $optind+2 ]]; then - _tipc_media $(($optind + 2)) + if ((cword == optind)); then + COMPREPLY=($(compgen -W 'show' -- $cur)) fi ;; - esac - ;; - nametable) - (( optind++ )) + node) + ((optind++)) - if [[ $cword -eq $optind ]]; then - COMPREPLY=( $(compgen -W 'show' -- $cur) ) - fi - ;; - node) - (( optind++ )) + if ((cword == optind)); then + COMPREPLY=($(compgen -W 'list get set' -- $cur)) + return + fi - if [[ $cword -eq $optind ]]; then - COMPREPLY=( $(compgen -W 'list get set' -- $cur) ) - return - fi + case "${words[optind]}" in + get | set) + ((optind++)) - case "${words[$optind]}" in - get|set) - (( optind++ )) + if ((cword == optind)); then + COMPREPLY=($(compgen -W 'address netid' -- $cur)) + fi + ;; + esac + ;; + socket) + ((optind++)) - if [[ $cword -eq $optind ]]; then - COMPREPLY=( $(compgen -W 'address netid' -- $cur) ) + if ((cword == optind)); then + COMPREPLY=($(compgen -W 'list' -- $cur)) fi - esac - ;; - socket) - (( optind++ )) - - if [[ $cword -eq $optind ]]; then - COMPREPLY=( $(compgen -W 'list' -- $cur) ) - fi - ;; + ;; esac } && -complete -F _tipc tipc + complete -F _tipc tipc # ex: filetype=sh diff --git a/completions/tox b/completions/tox index 7dcddc54..0ea656e9 100644 --- a/completions/tox +++ b/completions/tox @@ -12,35 +12,40 @@ _tox() fi case $prev in - --help|--version|--num|--index-url|--hashseed|--force-dep|-!(-*)[hni]) + --help | --version | --num | --index-url | --hashseed | --force-dep | -!(-*)[hni]) return ;; -!(-*)c) _filedir ini return ;; - --installpkg|--result-json|--workdir) + --installpkg | --result-json | --workdir) _filedir return ;; -!(-*)e) local envs=$( - { "$1" --listenvs-all || "$1" --listenvs; } 2>/dev/null ) + { + "$1" --listenvs-all || "$1" --listenvs + } 2>/dev/null + ) [[ $envs ]] || envs=$( - command sed -e 's/,/ /g' -ne 's/^envlist[[:space:]]*=//p' \ - tox.ini 2>/dev/null) - local prefix=""; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $(compgen -X '*[{}]*' -W "$envs ALL" -- "${cur##*,}") ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + command sed -e 's/,/ /g' -ne 's/^envlist[[:space:]]*=//p' \ + tox.ini 2>/dev/null + ) + local prefix="" + [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=($(compgen -X '*[{}]*' -W "$envs ALL" -- "${cur##*,}")) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") --' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1") --' -- "$cur")) return fi } && -complete -F _tox tox + complete -F _tox tox # ex: filetype=sh diff --git a/completions/tracepath b/completions/tracepath index 29dec3e8..176534f1 100644 --- a/completions/tracepath +++ b/completions/tracepath @@ -13,14 +13,14 @@ _tracepath() if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) return fi local ipvx [[ $1 == *6 ]] && ipvx=-6 - _known_hosts_real $ipvx -- "$cur" + _known_hosts_real ${ipvx-} -- "$cur" } && -complete -F _tracepath tracepath tracepath6 + complete -F _tracepath tracepath tracepath6 # ex: filetype=sh diff --git a/completions/tshark b/completions/tshark index 2f18d0a3..396fbcbd 100644 --- a/completions/tshark +++ b/completions/tshark @@ -23,13 +23,13 @@ _tshark() cur=${cur#*:} _filedir else - [ -n "$_tshark_prefs" ] || - _tshark_prefs="$("$1" -G defaultprefs 2>/dev/null | command\ - sed -ne 's/^#\{0,1\}\([a-z0-9_.-]\{1,\}:\).*/\1/p' | + [[ -v _tshark_prefs ]] || + _tshark_prefs="$("$1" -G defaultprefs 2>/dev/null | command sed -ne 's/^#\{0,1\}\([a-z0-9_.-]\{1,\}:\).*/\1/p' | tr '\n' ' ')" - COMPREPLY=( $(compgen -P "$prefix" -W "$_tshark_prefs" \ - -- "${cur:${#prefix}}") ) - [[ $COMPREPLY == *: ]] && compopt -o nospace + : ${prefix:=} + COMPREPLY=($(compgen -P "$prefix" -W "$_tshark_prefs" \ + -- "${cur:${#prefix}}")) + [[ ${COMPREPLY-} == *: ]] && compopt -o nospace fi return ;; @@ -37,73 +37,71 @@ _tshark() return ;; -*i) - COMPREPLY=( $(compgen -W \ - "$("$1" -D 2>/dev/null | awk '{print $2}')" -- "$cur") ) + COMPREPLY=($(compgen -W \ + "$("$1" -D 2>/dev/null | awk '{print $2}')" -- "$cur")) return ;; -*y) local opts i - for (( i=${#words[@]}-1; i > 0; i-- )); do + for ((i = ${#words[@]} - 1; i > 0; i--)); do if [[ ${words[i]} == -i ]]; then - opts+="-i ${words[i+1]}" + opts+="-i ${words[i + 1]}" break fi done - COMPREPLY=( $(compgen -W "$("$1" $opts -L 2>/dev/null | \ - awk '/^ / { print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$("$1" $opts -L 2>/dev/null | + awk '/^ / { print $1 }')" -- "$cur")) return ;; -*[ab]) - COMPREPLY=( $(compgen -W 'duration: filesize: files:' -- "$cur") ) - [[ $COMPREPLY == *: ]] && compopt -o nospace + COMPREPLY=($(compgen -W 'duration: filesize: files:' -- "$cur")) + [[ ${COMPREPLY-} == *: ]] && compopt -o nospace return ;; - -*r) - _filedir '@(pcap?(ng)|cap)?(.gz)' - return - ;; - -*H) + -*[rH]) + # -r accepts a lot of different file types _filedir return ;; -*w) _filedir - [[ $cur == @(|-) ]] && COMPREPLY+=( - ) + [[ $cur == @(|-) ]] && COMPREPLY+=(-) return ;; -*F) - COMPREPLY=( $(compgen -W "$("$1" -F 2>&1 | \ - awk '/^ / { print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$("$1" -F 2>&1 | + awk '/^ / { print $1 }')" -- "$cur")) return ;; -*O) - local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - [ -n "$_tshark_protocols" ] || + local prefix= + [[ $cur == *,* ]] && prefix="${cur%,*}," + [[ -v _tshark_protocols ]] || _tshark_protocols="$("$1" -G protocols 2>/dev/null | cut -f 3 | tr '\n' ' ')" - COMPREPLY=( $(compgen -W "$_tshark_protocols" -- "${cur##*,}") ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + COMPREPLY=($(compgen -W "$_tshark_protocols" -- "${cur##*,}")) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) return ;; -*T) # Parse from: tshark -T . 2>&1 | awk -F \" '/^\t*"/ { print $2 }' - COMPREPLY=( $(compgen -W \ - 'pdml ps psml json jsonraw ek tabs text fields' -- "$cur") ) + COMPREPLY=($(compgen -W \ + 'pdml ps psml json jsonraw ek tabs text fields' -- "$cur")) return ;; -*t) # Parse from: tshark -t . 2>&1 | awk -F \" '/^\t*"/ { print $2 }' - COMPREPLY=( $(compgen -W \ - 'a ad adoy d dd e r u ud udoy' -- "$cur") ) + COMPREPLY=($(compgen -W \ + 'a ad adoy d dd e r u ud udoy' -- "$cur")) return ;; -*u) # TODO: could be parsed from "-u ." output - COMPREPLY=( $(compgen -W 's hms' -- "$cur") ) + COMPREPLY=($(compgen -W 's hms' -- "$cur")) return ;; -*W) - COMPREPLY=( $(compgen -W 'n' -- "$cur") ) + COMPREPLY=($(compgen -W 'n' -- "$cur")) return ;; -*X) @@ -111,28 +109,28 @@ _tshark() cur=${cur#*:} _filedir lua else - COMPREPLY=( $(compgen -P "$prefix" -W 'lua_script:' -- \ - "${cur:${#prefix}}") ) - [[ $COMPREPLY == *: ]] && compopt -o nospace + COMPREPLY=($(compgen -P "$prefix" -W 'lua_script:' -- \ + "${cur:${#prefix}}")) + [[ ${COMPREPLY-} == *: ]] && compopt -o nospace fi return ;; -*G) - COMPREPLY=( $(compgen -W "$("$1" -G \? 2>/dev/null | \ + COMPREPLY=($(compgen -W "$("$1" -G \? 2>/dev/null | awk '/^[ \t]*-G / \ { sub("^[[]","",$2); sub("[]]$","",$2); print $2 }')" \ - -- "$cur") ) + -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h 2>/dev/null)' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h 2>/dev/null)' \ + -- "$cur")) return fi } && -complete -F _tshark tshark + complete -F _tshark tshark # ex: filetype=sh diff --git a/completions/tsig-keygen b/completions/tsig-keygen new file mode 100644 index 00000000..017e9d81 --- /dev/null +++ b/completions/tsig-keygen @@ -0,0 +1,28 @@ +# tsig-keygen(8) completion -*- shell-script -*- + +_tsig_keygen() +{ + local cur prev words cword + _init_completion || return + + case $prev in + -h) + return + ;; + -a) + COMPREPLY=($(compgen -W 'hmac-{md5,sha{1,224,256,384,512}}' -- "$cur")) + return + ;; + -r) + COMPREPLY=($(compgen -W keyboard -- "$cur")) + _filedir + return + ;; + esac + + [[ $cur != -* ]] || + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) +} && + complete -F _tsig_keygen tsig-keygen + +# ex: filetype=sh diff --git a/completions/tune2fs b/completions/tune2fs index ab79cd51..66d629c4 100644 --- a/completions/tune2fs +++ b/completions/tune2fs @@ -10,12 +10,12 @@ _tune2fs() return ;; -*e) - COMPREPLY=( $(compgen -W 'continue remount-ro panic' -- "$cur") ) + COMPREPLY=($(compgen -W 'continue remount-ro panic' -- "$cur")) return ;; -*g) _gids - COMPREPLY=( $(compgen -g -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY=($(compgen -g -W '${COMPREPLY[@]}' -- "$cur")) return ;; -*M) @@ -26,7 +26,7 @@ _tune2fs() local -a opts=(^debug ^bsdgroups ^user_xattr ^acl ^uid16 ^journal_data ^journal_data_ordered ^journal_data_writeback ^nobarrier ^block_validity ^discard ^nodelalloc) - COMPREPLY=( $(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur")) return ;; -*O) @@ -34,28 +34,28 @@ _tune2fs() ^filetype ^flex_bg ^has_journal ^huge_file ^large_file ^metadata_csum ^mmp ^project ^quota ^read-only ^resize_inode ^sparse_super ^uninit_bg) - COMPREPLY=( $(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur")) return ;; -*u) _uids - COMPREPLY=( $(compgen -u -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY=($(compgen -u -W '${COMPREPLY[@]}' -- "$cur")) return ;; -*U) - COMPREPLY=( $(compgen -W 'clear random time' -- "$cur") ) + COMPREPLY=($(compgen -W 'clear random time' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi cur=${cur:=/dev/} _filedir } && -complete -F _tune2fs tune2fs + complete -F _tune2fs tune2fs # ex: filetype=sh diff --git a/completions/ulimit b/completions/ulimit index 3887cdf5..e596bf72 100644 --- a/completions/ulimit +++ b/completions/ulimit @@ -10,33 +10,33 @@ _ulimit() local mode case $prev in -a) - COMPREPLY=( $(compgen -W "-S -H" -- "$cur") ) + COMPREPLY=($(compgen -W "-S -H" -- "$cur")) return ;; - -[SH]) - ;; + -[SH]) ;; + -*) mode=$prev ;; esac - if [[ -z "$mode" ]]; then + if [[ ! -v mode ]]; then local word for word in "${words[@]}"; do [[ $word == -*a* ]] && return done - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi fi local args _count_args - [[ $args -eq 1 ]] && \ - COMPREPLY=( $(compgen -W "soft hard unlimited" -- "$cur") ) + ((args == 1)) && + COMPREPLY=($(compgen -W "soft hard unlimited" -- "$cur")) } && -complete -F _ulimit ulimit + complete -F _ulimit ulimit # ex: filetype=sh diff --git a/completions/unace b/completions/unace index a58bd6f0..7d6bd424 100644 --- a/completions/unace +++ b/completions/unace @@ -6,15 +6,15 @@ _unace() _init_completion || return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur") ) + COMPREPLY=($(compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur")) else - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'e l t v x' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'e l t v x' -- "$cur")) else _filedir ace fi fi } && -complete -F _unace unace + complete -F _unace unace # ex: filetype=sh diff --git a/completions/unpack200 b/completions/unpack200 index 393df04d..8814259b 100644 --- a/completions/unpack200 +++ b/completions/unpack200 @@ -6,15 +6,15 @@ _unpack200() _init_completion -s || return case $prev in - --help|--version|-!(-*)[?hVJ]) + --help | --version | -!(-*)[?hVJ]) return ;; - --deflate-hint|-!(-*)H) - COMPREPLY=( $(compgen -W 'true false keep' -- "$cur") ) + --deflate-hint | -!(-*)H) + COMPREPLY=($(compgen -W 'true false keep' -- "$cur")) return ;; - --log-file|-!(-*)l) - COMPREPLY=( $(compgen -W '-' -- "$cur") ) + --log-file | -!(-*)l) + COMPREPLY=($(compgen -W '-' -- "$cur")) _filedir log return ;; @@ -23,26 +23,26 @@ _unpack200() $split && return # Check if a pack or a jar was already given. - local i pack=false jar=false - for (( i=0; i < ${#words[@]}-1; i++ )) ; do - case ${words[i]} in - *.pack|*.pack.gz) pack=true ;; + local word pack=false jar=false + for word in "${words[@]:1}"; do + case $word in + *.pack | *.pack.gz) pack=true ;; *.jar) jar=true ;; esac done - if ! $pack ; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--deflate-hint= --remove-pack-file - --verbose --quiet --log-file= --help --version' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if ! $pack; then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--deflate-hint= --remove-pack-file + --verbose --quiet --log-file= --help --version' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir 'pack?(.gz)' fi - elif ! $jar ; then + elif ! $jar; then _filedir jar fi } && -complete -F _unpack200 unpack200 + complete -F _unpack200 unpack200 # ex: filetype=sh diff --git a/completions/unrar b/completions/unrar index 959a5c9c..4cbac8fe 100644 --- a/completions/unrar +++ b/completions/unrar @@ -6,18 +6,18 @@ _unrar() _init_completion || return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-ad -ap -av- -c- -cfg- -cl -cu -dh -ep -f + COMPREPLY=($(compgen -W '-ad -ap -av- -c- -cfg- -cl -cu -dh -ep -f -idp -ierr -inul -kb -o+ -o- -ow -p -p- -r -ta -tb -tn -to -u -v - -ver -vp -x -x@ -y' -- "$cur") ) + -ver -vp -x -x@ -y' -- "$cur")) else - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'e l lb lt p t v vb vt x' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'e l lb lt p t v vb vt x' -- "$cur")) else _filedir '@(rar|exe)' fi fi } && -complete -F _unrar unrar + complete -F _unrar unrar # ex: filetype=sh diff --git a/completions/unshunt b/completions/unshunt index 214fa423..95a16015 100644 --- a/completions/unshunt +++ b/completions/unshunt @@ -5,13 +5,13 @@ _unshunt() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else _filedir -d fi } && -complete -F _unshunt unshunt + complete -F _unshunt unshunt # ex: filetype=sh diff --git a/completions/update-alternatives b/completions/update-alternatives index 17b687a7..25d2ce6b 100644 --- a/completions/update-alternatives +++ b/completions/update-alternatives @@ -7,13 +7,13 @@ _installed_alternatives() for i in alternatives dpkg/alternatives rpm/alternatives; do [[ -d /var/lib/$i ]] && admindir=/var/lib/$i && break done - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == --admindir ]]; then - admindir=${words[i+1]} + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == --admindir ]]; then + admindir=${words[i + 1]} break fi done - COMPREPLY=( $(compgen -W '$(command ls $admindir)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(command ls $admindir)' -- "$cur")) } _update_alternatives() @@ -22,11 +22,11 @@ _update_alternatives() _init_completion || return case $prev in - --altdir|--admindir) + --altdir | --admindir) _filedir -d return ;; - --help|--usage|--version) + --help | --usage | --version) return ;; esac @@ -34,18 +34,18 @@ _update_alternatives() local mode args i # find which mode to use and how many real args used so far - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == --@(install|remove|auto|display|config|remove-all|set) ]]; then + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == --@(install|remove|auto|display|config|remove-all|set) ]]; then mode=${words[i]} - args=$(($cword - i)) + args=$((cword - i)) break fi done - case $mode in + case ${mode-} in --install) case $args in - 1|3) + 1 | 3) _filedir ;; 2) @@ -56,19 +56,20 @@ _update_alternatives() ;; *) case $((args % 4)) in - 0|2) + 0 | 2) _filedir ;; 1) - COMPREPLY=( $(compgen -W '--slave' -- "$cur") ) + COMPREPLY=($(compgen -W '--slave' -- "$cur")) ;; 3) _installed_alternatives ;; esac + ;; esac ;; - --remove|--set) + --remove | --set) case $args in 1) _installed_alternatives @@ -78,13 +79,14 @@ _update_alternatives() ;; esac ;; - --auto|--remove-all|--display|--config) + --auto | --remove-all | --display | --config) _installed_alternatives ;; *) - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + ;; esac } && -complete -F _update_alternatives update-alternatives alternatives + complete -F _update_alternatives update-alternatives alternatives # ex: filetype=sh diff --git a/completions/update-rc.d b/completions/update-rc.d index 31cd820b..9b281d5f 100644 --- a/completions/update-rc.d +++ b/completions/update-rc.d @@ -9,50 +9,50 @@ _update_rc_d() local sysvdir services options - [[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d \ - || sysvdir=/etc/init.d + [[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d || + sysvdir=/etc/init.d - services=( $(printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob)) ) - services=( ${services[@]#$sysvdir/} ) - options=( -f -n ) + services=($(printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob))) + services=(${services[@]#$sysvdir/}) + options=(-f -n) - if [[ $cword -eq 1 || "$prev" == -* ]]; then - COMPREPLY=( $(compgen -W '${options[@]} ${services[@]}' \ - -X '$(tr " " "|" <<<${words[@]})' -- "$cur") ) - elif [[ "$prev" == ?($(tr " " "|" <<<"${services[*]}")) ]]; then - COMPREPLY=( $(compgen -W 'remove defaults start stop' -- "$cur") ) - elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then - COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 ) - elif [[ "$prev" == defaults && "$cur" == [sk]?([0-9]) ]]; then - COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 ) - elif [[ "$prev" == defaults && -z "$cur" ]]; then - COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 s k ) - elif [[ "$prev" == ?(start|stop) ]]; then - if [[ "$cur" == [0-9] || -z "$cur" ]]; then - COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 ) - elif [[ "$cur" == [0-9][0-9] ]]; then - COMPREPLY=( $cur ) + if [[ $cword -eq 1 || $prev == -* ]]; then + COMPREPLY=($(compgen -W '${options[@]} ${services[@]}' \ + -X '$(tr " " "|" <<<${words[@]})' -- "$cur")) + elif [[ $prev == ?($(tr " " "|" <<<"${services[*]}")) ]]; then + COMPREPLY=($(compgen -W 'remove defaults start stop' -- "$cur")) + elif [[ $prev == defaults && $cur == [0-9] ]]; then + COMPREPLY=(0 1 2 3 4 5 6 7 8 9) + elif [[ $prev == defaults && $cur == [sk]?([0-9]) ]]; then + COMPREPLY=(0 1 2 3 4 5 6 7 8 9) + elif [[ $prev == defaults && -z $cur ]]; then + COMPREPLY=(0 1 2 3 4 5 6 7 8 9 s k) + elif [[ $prev == ?(start|stop) ]]; then + if [[ $cur == [0-9] || -z $cur ]]; then + COMPREPLY=(0 1 2 3 4 5 6 7 8 9) + elif [[ $cur == [0-9][0-9] ]]; then + COMPREPLY=($cur) else COMPREPLY=() fi - elif [[ "$prev" == ?([0-9][0-9]|[0-6S]) ]]; then - if [[ -z "$cur" ]]; then + elif [[ $prev == ?([0-9][0-9]|[0-6S]) ]]; then + if [[ -z $cur ]]; then if [[ $prev == [0-9][0-9] ]]; then - COMPREPLY=( 0 1 2 3 4 5 6 S ) + COMPREPLY=(0 1 2 3 4 5 6 S) else - COMPREPLY=( 0 1 2 3 4 5 6 S . ) + COMPREPLY=(0 1 2 3 4 5 6 S .) fi - elif [[ "$cur" == [0-6S.] ]]; then - COMPREPLY=( $cur ) + elif [[ $cur == [0-6S.] ]]; then + COMPREPLY=($cur) else COMPREPLY=() fi - elif [[ "$prev" == "." ]]; then - COMPREPLY=( $(compgen -W "start stop" -- "$cur") ) + elif [[ $prev == "." ]]; then + COMPREPLY=($(compgen -W "start stop" -- "$cur")) else COMPREPLY=() fi } && -complete -F _update_rc_d update-rc.d + complete -F _update_rc_d update-rc.d # ex: filetype=sh diff --git a/completions/upgradepkg b/completions/upgradepkg index 7b775769..d3ce6084 100644 --- a/completions/upgradepkg +++ b/completions/upgradepkg @@ -5,26 +5,26 @@ _upgradepkg() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--dry-run --install-new --reinstall - --verbose' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--dry-run --install-new --reinstall + --verbose' -- "$cur")) return fi - if [[ "$cur" == ?*%* ]]; then + if [[ $cur == ?*%* ]]; then prev="${cur%%?(\\)%*}" cur="${cur#*%}" local nofiles IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -P "$prev%" -f -X "!*.@(t[bgxl]z)" -- "$cur") ) - [[ $COMPREPLY ]] || nofiles=1 - COMPREPLY+=( $(compgen -P "$prev%" -S '/' -d -- "$cur") ) - [[ $nofiles ]] && compopt -o nospace + COMPREPLY=($(compgen -P "$prev%" -f -X "!*.@(t[bgxl]z)" -- "$cur")) + [[ ${COMPREPLY-} ]] || nofiles=1 + COMPREPLY+=($(compgen -P "$prev%" -S '/' -d -- "$cur")) + [[ -v nofiles ]] && compopt -o nospace return fi _filedir 't[bglx]z' } && -complete -F _upgradepkg upgradepkg + complete -F _upgradepkg upgradepkg # ex: filetype=sh diff --git a/completions/urlsnarf b/completions/urlsnarf index d3581c5f..e3270762 100644 --- a/completions/urlsnarf +++ b/completions/urlsnarf @@ -16,11 +16,11 @@ _urlsnarf() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) fi } && -complete -F _urlsnarf urlsnarf + complete -F _urlsnarf urlsnarf # ex: filetype=sh diff --git a/completions/uscan b/completions/uscan index de0e7174..441bae3f 100644 --- a/completions/uscan +++ b/completions/uscan @@ -7,7 +7,7 @@ _uscan() case $prev in --package) - COMPREPLY=( $(_xfunc apt-cache _apt_cache_src_packages)) + COMPREPLY=($(_xfunc apt-cache _apt_cache_src_packages)) return ;; --watchfile) @@ -18,16 +18,16 @@ _uscan() _filedir -d return ;; - --timeout|--upstream-version|--download-version|--check-dirname-level|--check-dirname-regex) - COMPREPLY=( ) + --timeout | --upstream-version | --download-version | --check-dirname-level | --check-dirname-regex) + COMPREPLY=() return ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _uscan uscan + complete -F _uscan uscan # ex: filetype=sh diff --git a/completions/useradd b/completions/useradd index 8e095441..ceeca914 100644 --- a/completions/useradd +++ b/completions/useradd @@ -9,27 +9,28 @@ _useradd() # with -u/--uid case $prev in - --comment|--help|--expiredate|--inactive|--key|--password|--uid|\ - --selinux-user|-!(-*)[chefKpuZ]) + --comment | --help | --expiredate | --inactive | --key | --password | --uid | \ + --selinux-user | -!(-*)[chefKpuZ]) return ;; - --base-dir|--home-dir|--skel|--root|-!(-*)[bdkR]) + --base-dir | --home-dir | --skel | --root | -!(-*)[bdkR]) _filedir -d return ;; - --gid|-!(-*)g) + --gid | -!(-*)g) _gids - COMPREPLY=( $(compgen -W '${COMPREPLY[@]} $(compgen -g)' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]} $(compgen -g)' \ + -- "$cur")) return ;; - --groups|-!(-*)G) - local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $(compgen -g -- "${cur##*,}") ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + --groups | -!(-*)G) + local prefix= + [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=($(compgen -g -- "${cur##*,}")) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) return ;; - --shell|-!(-*)s) + --shell | -!(-*)s) _shells return ;; @@ -37,9 +38,9 @@ _useradd() $split && return - [[ "$cur" == -* ]] && \ - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $cur == -* ]] && + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _useradd useradd + complete -F _useradd useradd # ex: filetype=sh diff --git a/completions/userdel b/completions/userdel index 7d637d2e..ed98447b 100644 --- a/completions/userdel +++ b/completions/userdel @@ -6,22 +6,22 @@ _userdel() _init_completion || return case $prev in - --help|-!(-*)h) + --help | -!(-*)h) return ;; - --root|-!(-*)R) + --root | -!(-*)R) _filedir -d return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) } && -complete -F _userdel userdel + complete -F _userdel userdel # ex: filetype=sh diff --git a/completions/usermod b/completions/usermod index 3d0efdbd..77ab33c8 100644 --- a/completions/usermod +++ b/completions/usermod @@ -9,27 +9,28 @@ _usermod() # with -u/--uid case $prev in - --comment|--home|--expiredate|--inactive|--help|--login|--password|\ - --uid|--selinux-user|-!(-*)[cdefhlpuZ]) + --comment | --home | --expiredate | --inactive | --help | --login | --password | \ + --uid | --selinux-user | -!(-*)[cdefhlpuZ]) return ;; - --gid|-!(-*)g) + --gid | -!(-*)g) _gids - COMPREPLY=( $(compgen -W '${COMPREPLY[@]} $(compgen -g)' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]} $(compgen -g)' \ + -- "$cur")) return ;; - --groups|-!(-*)G) - local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $(compgen -g -- "${cur##*,}") ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + --groups | -!(-*)G) + local prefix= + [[ $cur == *,* ]] && prefix="${cur%,*}," + COMPREPLY=($(compgen -g -- "${cur##*,}")) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) return ;; - --root|-!(-*)R) + --root | -!(-*)R) _filedir -d return ;; - --shell|-!(-*)s) + --shell | -!(-*)s) _shells return ;; @@ -37,14 +38,14 @@ _usermod() $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # TODO: -U/--unlock, -p/--password, -L/--lock mutually exclusive - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) } && -complete -F _usermod usermod + complete -F _usermod usermod # ex: filetype=sh diff --git a/completions/valgrind b/completions/valgrind index 01ca62c5..f5411615 100644 --- a/completions/valgrind +++ b/completions/valgrind @@ -9,47 +9,47 @@ _valgrind() # Note: intentionally using COMP_WORDS and COMP_CWORD instead of # words and cword here due to splitting on = causing index differences # (_command_offset assumes the former). - for (( i=1; i <= COMP_CWORD; i++ )); do - if [[ ${COMP_WORDS[i]} != @([-=])* && ${COMP_WORDS[i-1]} != = ]]; then + for ((i = 1; i <= COMP_CWORD; i++)); do + if [[ ${COMP_WORDS[i]} != @([-=])* && ${COMP_WORDS[i - 1]} != = ]]; then _command_offset $i return fi done - local tool - for (( i=1; i < ${#words[@]}; i++ )); do - if [[ ${words[i]} == --tool=?* ]]; then - tool=${words[i]} + local word tool + for word in "${words[@]:1}"; do + if [[ $word == --tool=?* ]]; then + tool=$word break fi done case $prev in - -h|--help|--help-debug|--version) + -h | --help | --help-debug | --version) return ;; --tool) # Tools seem to be named e.g. like memcheck-amd64-linux from which # we want to grab memcheck. - COMPREPLY=( $(compgen -W '$( + COMPREPLY=($(compgen -W '$( for f in /usr{,/local}/lib{,64,exec}{/*-linux-gnu,}/valgrind/* do [[ $f != *.so && -x $f && $f =~ ^.*/(.*)-[^-]+-[^-]+ ]] && printf "%s\n" "${BASH_REMATCH[1]}" - done)' -- "$cur") ) + done)' -- "$cur")) return ;; --sim-hints) - COMPREPLY=( $(compgen -W 'lax-ioctls enable-outer' -- "$cur") ) + COMPREPLY=($(compgen -W 'lax-ioctls enable-outer' -- "$cur")) return ;; --soname-synonyms) - COMPREPLY=( $(compgen -W 'somalloc' -S = -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W 'somalloc' -S = -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return ;; --kernel-variant) - COMPREPLY=( $(compgen -W 'bproc' -- "$cur") ) + COMPREPLY=($(compgen -W 'bproc' -- "$cur")) return ;; # callgrind: @@ -59,18 +59,18 @@ _valgrind() ;; # exp-dhat: --sort-by) - COMPREPLY=( $(compgen -W 'max-bytes-live tot-bytes-allocd - max-blocks-live' -- "$cur") ) + COMPREPLY=($(compgen -W 'max-bytes-live tot-bytes-allocd + max-blocks-live' -- "$cur")) return ;; # massif: --time-unit) - COMPREPLY=( $(compgen -W 'i ms B' -- "$cur") ) + COMPREPLY=($(compgen -W 'i ms B' -- "$cur")) return ;; - # generic cases parsed from --help output + # generic cases parsed from --help output --+([-A-Za-z0-9_])) - local value=$($1 --help-debug $tool 2>/dev/null | \ + local value=$($1 --help-debug ${tool-} 2>/dev/null | command sed -ne "s|^[[:blank:]]*$prev=\([^[:blank:]]\{1,\}\).*|\1|p") case $value in \<file*\>) @@ -79,18 +79,18 @@ _valgrind() ;; \<command\>) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; \<+([0-9])..+([0-9])\>) - COMPREPLY=( $(compgen -W "{${value:1:((${#value}-2))}}" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "{${value:1:${#value}-2}}" \ + -- "$cur")) return ;; # "yes", "yes|no", etc (but not "string", "STR", # "hint1,hint2,...") - yes|+([-a-z0-9])\|+([-a-z0-9\|])) - COMPREPLY=( $(IFS='|' compgen -W '$value' -- "$cur") ) + yes | +([-a-z0-9])\|+([-a-z0-9\|])) + COMPREPLY=($(IFS='|' compgen -W '$value' -- "$cur")) return ;; esac @@ -100,12 +100,12 @@ _valgrind() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" "--help $tool")' \ - -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" "--help ${tool-}")' \ + -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi } && -complete -F _valgrind valgrind + complete -F _valgrind valgrind # ex: filetype=sh diff --git a/completions/vipw b/completions/vipw index 46771a0a..b3a74156 100644 --- a/completions/vipw +++ b/completions/vipw @@ -6,17 +6,17 @@ _vipw() _init_completion || return case $prev in - --help|-!(-*)h) + --help | -!(-*)h) return ;; - --root|-!(-*)R) + --root | -!(-*)R) _filedir -d return ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _vipw vipw vigr + complete -F _vipw vipw vigr # ex: filetype=sh diff --git a/completions/vmstat b/completions/vmstat index f15d4089..e36934a5 100644 --- a/completions/vmstat +++ b/completions/vmstat @@ -6,22 +6,22 @@ _vmstat() _init_completion || return case $prev in - --help|--version|--partition|-!(-*)[hVcMNnwp]) + --help | --version | --partition | -!(-*)[hVcMNnwp]) return ;; - --unit|-!(-*)S) - [[ $OSTYPE == *linux* ]] && \ - COMPREPLY=( $(compgen -W 'k K m M' -- "$cur") ) + --unit | -!(-*)S) + [[ $OSTYPE == *linux* ]] && + COMPREPLY=($(compgen -W 'k K m M' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY ]] || \ - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} ]] || + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) fi } && -complete -F _vmstat vmstat + complete -F _vmstat vmstat # ex: filetype=sh diff --git a/completions/vncviewer b/completions/vncviewer index 000ba1a8..ba552268 100644 --- a/completions/vncviewer +++ b/completions/vncviewer @@ -4,17 +4,17 @@ _vncviewer_bootstrap() { local fname case $(_realcommand vncviewer) in - *xvnc4viewer) fname=_xvnc4viewer ;; - *tightvncviewer) fname=_tightvncviewer ;; - *) fname=_known_hosts ;; + *xvnc4viewer) fname=_xvnc4viewer ;; + *tightvncviewer) fname=_tightvncviewer ;; + *) fname=_known_hosts ;; esac # Install real completion for subsequent completions complete -F $fname vncviewer - $fname # Generate completions once for now + $fname # Generate completions once for now unset -f _vncviewer_bootstrap } && -complete -F _vncviewer_bootstrap vncviewer + complete -F _vncviewer_bootstrap vncviewer _tightvncviewer() { @@ -27,8 +27,8 @@ _tightvncviewer() return ;; -encodings) - COMPREPLY=( $(compgen -W 'copyrect tight hextile zlib corre rre - raw' -- "$cur") ) + COMPREPLY=($(compgen -W 'copyrect tight hextile zlib corre rre + raw' -- "$cur")) return ;; -via) @@ -37,18 +37,16 @@ _tightvncviewer() ;; esac - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-help -listen -via -shared -noshared + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-help -listen -via -shared -noshared -viewonly -fullscreen -noraiseonbeep -passwd -encodings -bgr233 -owncmap -truecolour -truecolor -depth -compresslevel -quality - -nojpeg -nocursorshape -x11cursor' -- "$cur") ) + -nojpeg -nocursorshape -x11cursor' -- "$cur")) else _known_hosts_real -- "$cur" fi } && -complete -F _tightvncviewer tightvncviewer - + complete -F _tightvncviewer tightvncviewer # NOTE: - VNC Viewer options are case insensitive. # Preferred case is taken from -help. @@ -61,12 +59,12 @@ _xvnc4viewer() local opt=${prev/#--/-} case ${opt,,} in # -passwd, -PasswordFile - -passwd|-passwordfile) + -passwd | -passwordfile) _filedir return ;; -preferredencoding) - COMPREPLY=( $(compgen -W 'zrle hextile raw' -- "$cur") ) + COMPREPLY=($(compgen -W 'zrle hextile raw' -- "$cur")) return ;; -via) @@ -75,26 +73,27 @@ _xvnc4viewer() ;; esac - if [[ "$cur" == -* || "$cur" == --* ]]; then + if [[ $cur == -* || $cur == --* ]]; then # Default to vncviewer camelcase options, see `vncviewer -help' - local dash options=( AcceptClipboard AutoSelect DebugDelay display + local dash options=(AcceptClipboard AutoSelect DebugDelay display DotWhenNoCursor FullColor FullColour FullScreen geometry help listen Log LowColourLevel MenuKey name Parent passwd PasswordFile PointerEventInterval PreferredEncoding SendClipboard SendPrimary Shared UseLocalCursor via ViewOnly WMDecorationHeight - WMDecorationWidth ZlibLevel ) - [[ "$cur" == --* ]] && dash=-- || dash=- + WMDecorationWidth ZlibLevel) + [[ $cur == --* ]] && dash=-- || dash=- - local IFS=$' \t\n' 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) ) + COMPREPLY=($(for option in "${options[@]}"; do + [[ $dash$option == "$cur"* ]] && printf '%s\n' $dash$option + done)) $reset else _known_hosts_real -- "$cur" fi } && -complete -F _xvnc4viewer xvnc4viewer + complete -F _xvnc4viewer xvnc4viewer # ex: filetype=sh diff --git a/completions/vpnc b/completions/vpnc index 5eb5be71..bbdb8ee7 100644 --- a/completions/vpnc +++ b/completions/vpnc @@ -6,9 +6,9 @@ _vpnc() _init_completion || return case $prev in - --help|--long-help|--version|--id|--username|--domain|--ifname|\ - --application-version|--local-addr|--local-port|--udp-port|--dpd-idle|\ - --target-network|--ifmtu) + --help | --long-help | --version | --id | --username | --domain | --ifname | \ + --application-version | --local-addr | --local-port | --udp-port | --dpd-idle | \ + --target-network | --ifmtu) return ;; --gateway) @@ -16,36 +16,36 @@ _vpnc() return ;; --vendor) - COMPREPLY=( $(compgen -W 'cisco netscreen' -- "$cur") ) + COMPREPLY=($(compgen -W 'cisco netscreen' -- "$cur")) return ;; --natt-mode) - COMPREPLY=( $(compgen -W 'natt none force-natt cisco-udp' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'natt none force-natt cisco-udp' \ + -- "$cur")) return ;; - --script|--pid-file|--ca-file) + --script | --pid-file | --ca-file) _filedir return ;; --dh) - COMPREPLY=( $(compgen -W 'dh1 dh2 dh5' -- "$cur") ) + COMPREPLY=($(compgen -W 'dh1 dh2 dh5' -- "$cur")) return ;; --pfs) - COMPREPLY=( $(compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur") ) + COMPREPLY=($(compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur")) return ;; --ifmode) - COMPREPLY=( $(compgen -W 'tun tap' -- "$cur") ) + COMPREPLY=($(compgen -W 'tun tap' -- "$cur")) return ;; --debug) - COMPREPLY=( $(compgen -W '0 1 2 3 99' -- "$cur") ) + COMPREPLY=($(compgen -W '0 1 2 3 99' -- "$cur")) return ;; --auth-mode) - COMPREPLY=( $(compgen -W 'psk cert hybrid' -- "$cur") ) + COMPREPLY=($(compgen -W 'psk cert hybrid' -- "$cur")) return ;; --ca-dir) @@ -54,28 +54,29 @@ _vpnc() ;; --password-helper) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --long-help)' -- "$cur") ) - elif [[ "$cur" == */* ]]; then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --long-help)' -- "$cur")) + elif [[ $cur == */* ]]; then # explicit filename _filedir conf else # 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}" ) + 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") ) + COMPREPLY=($(compgen -W '${configs[@]}' -- "$cur")) fi } && -complete -F _vpnc vpnc + complete -F _vpnc vpnc # ex: filetype=sh diff --git a/completions/watch b/completions/watch index eb04df89..efc0a98f 100644 --- a/completions/watch +++ b/completions/watch @@ -8,13 +8,13 @@ _watch() _init_completion -s || return local offset=0 i - for (( i=1; i <= cword; i++ )); do + for ((i = 1; i <= cword; i++)); do case ${words[i]} in - --help|--version|-!(-*)h) + --help | --version | -!(-*)h) return ;; - --interval|-!(-*)n) - (( i++ )) + --interval | -!(-*)n) + ((i++)) continue ;; -*) @@ -25,18 +25,18 @@ _watch() break done - if [[ $offset -gt 0 ]]; then + if ((offset > 0)); then _command_offset $offset return fi case $prev in - --differences|-!(-*)d) - [[ $cur != -* ]] && \ - COMPREPLY=( $(compgen -W 'cumulative' -- "$cur") ) + --differences | -!(-*)d) + [[ $cur != -* ]] && + COMPREPLY=($(compgen -W 'cumulative' -- "$cur")) return ;; - --interval|-!(-*)n) + --interval | -!(-*)n) return ;; esac @@ -44,11 +44,11 @@ _watch() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi } && -complete -F _watch watch + complete -F _watch watch # ex: filetype=sh diff --git a/completions/webmitm b/completions/webmitm index d50bc3e3..549c5ef5 100644 --- a/completions/webmitm +++ b/completions/webmitm @@ -5,13 +5,13 @@ _webmitm() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) else _known_hosts_real -- "$cur" fi } && -complete -F _webmitm webmitm + complete -F _webmitm webmitm # ex: filetype=sh diff --git a/completions/wget b/completions/wget index b27d860d..d6a2fe93 100644 --- a/completions/wget +++ b/completions/wget @@ -6,84 +6,87 @@ _wget() _init_completion -s || return case $prev in - --version|--help|-!(-*)[hV]) + --version | --help | -!(-*)[hV]) return ;; --progress) - COMPREPLY=( $(compgen -W 'bar dot' -- "$cur") ) + COMPREPLY=($(compgen -W 'bar dot' -- "$cur")) return ;; --bind-address) _ip_addresses return ;; - --domains|--exclude-domains|-!(-*)D) + --domains | --exclude-domains | -!(-*)D) _known_hosts_real -- "$cur" return ;; --restrict-file-names) local excludes=() case $cur in - *unix*|*windows*) - excludes=( windows unix ) + *unix* | *windows*) + excludes=(windows unix) ;;& - *lowercase*|*uppercase*) - excludes+=( lowercase uppercase ) + *lowercase* | *uppercase*) + excludes+=(lowercase uppercase) ;;& *nocontrol*) - excludes+=( nocontrol ) + excludes+=(nocontrol) ;;& *ascii*) - excludes+=( ascii ) + excludes+=(ascii) ;; esac - local excludes_str=$(export IFS='|'; echo "${excludes[*]}";) + local excludes_str=$( + export IFS='|' + echo "${excludes[*]}" + ) # prevopt is the previous options string used as a prefix # to avoid COMPREPLY replacing them with the $lastopt completion - local lastopt=${cur/*,} prevopt= + local lastopt=${cur/*,/} prevopt= [[ $cur == *,* ]] && prevopt=${cur%,*}, - COMPREPLY=( $(compgen -P "$prevopt" -X "@($excludes_str)" \ + COMPREPLY=($(compgen -P "$prevopt" -X "@($excludes_str)" \ -W 'unix windows nocontrol ascii lowercase uppercase' \ - -- "$lastopt") ) + -- "$lastopt")) # +o nospace when no more valid option is possible (= append a space) - local opt_as_arr=( $(echo ${COMPREPLY[0]//,/ }) ) - [[ ${#opt_as_arr[@]} -lt 4 ]] && compopt -o nospace + local opt_as_arr=(${COMPREPLY[0]//,/ }) + ((${#opt_as_arr[@]} < 4)) && compopt -o nospace return ;; --prefer-family) - COMPREPLY=( $(compgen -W 'IPv4 IPv6 none' -- "$cur") ) + COMPREPLY=($(compgen -W 'IPv4 IPv6 none' -- "$cur")) return ;; - --directory-prefix|--ca-directory|--warc-tempdir|-!(-*)P) + --directory-prefix | --ca-directory | --warc-tempdir | -!(-*)P) _filedir -d return ;; - --output-file|--append-output|--config|--load-cookies|--save-cookies|\ - --post-file|--certificate|--ca-certificate|--private-key|\ - --random-file|--egd-file|--warc-file|--warc-dedup|-!(-*)[oa]) + --output-file | --append-output | --config | --load-cookies | --save-cookies | \ + --post-file | --certificate | --ca-certificate | --private-key | \ + --random-file | --egd-file | --warc-file | --warc-dedup | -!(-*)[oa]) _filedir return ;; - --output-document|--input-file|-!(-*)[Oi]) - _filedir && [[ $cur == - || -z $cur ]] && COMPREPLY+=( - ) + --output-document | --input-file | -!(-*)[Oi]) + _filedir && [[ $cur == - || -z $cur ]] && COMPREPLY+=(-) return ;; --secure-protocol) - COMPREPLY=( $(compgen -W 'auto SSLv2 SSLv3 TLSv1' -- "$cur") ) + COMPREPLY=($(compgen -W 'auto SSLv2 SSLv3 TLSv1' -- "$cur")) return ;; - --certificate-type|--private-key-type) - COMPREPLY=( $(compgen -W 'PEM DER' -- "$cur") ) + --certificate-type | --private-key-type) + COMPREPLY=($(compgen -W 'PEM DER' -- "$cur")) return ;; - --follow-tags|--ignore-tags) - local lastopt=${cur/*,} prevopt= + --follow-tags | --ignore-tags) + local lastopt=${cur/*,/} prevopt= [[ $cur == *,* ]] && prevopt=${cur%,*}, - COMPREPLY=( $(compgen -P "$prevopt" -W 'a abbr acronym address + COMPREPLY=($(compgen -P "$prevopt" -W 'a abbr acronym address applet area b base basefont bdo big blockquote body br button caption center cite code col colgroup dd del dir div dfn dl dt em fieldset font form frame frameset h6 head hr html i iframe @@ -91,37 +94,37 @@ _wget() noframes noscript object ol optgroup option p param pre q s samp script select small span strike strong style sub sup table tbody td textarea tfoot th thead title tr tt u ul var xmp' \ - -- "$lastopt") ) + -- "$lastopt")) return ;; - --tries|--timeout|--dns-timeout|--connect-timeout|--read-timeout|\ - --wait|--waitretry|--cut-dirs|--max-redirect|--level|-!(-*)[tTwl]) + --tries | --timeout | --dns-timeout | --connect-timeout | --read-timeout | \ + --wait | --waitretry | --cut-dirs | --max-redirect | --level | -!(-*)[tTwl]) # expect integer number - COMPREPLY+=( $(compgen -P "$cur" -W "{0..9}") ) + COMPREPLY+=($(compgen -P "$cur" -W "{0..9}")) compopt -o nospace return ;; - --quota|--limit-rate|--warc-max-size|-!(-*)Q) + --quota | --limit-rate | --warc-max-size | -!(-*)Q) # expect size if [[ $cur == *[km] ]]; then - COMPREPLY=( $(compgen -W "$cur") ) + COMPREPLY=($(compgen -W "$cur")) elif [[ $cur ]]; then - COMPREPLY=( $(compgen -P "$cur" -W "{0..9} k m") ) + COMPREPLY=($(compgen -P "$cur" -W "{0..9} k m")) compopt -o nospace else - COMPREPLY=( $(compgen -W "{0..9}") ) + COMPREPLY=($(compgen -W "{0..9}")) compopt -o nospace fi return ;; - --user|--http-user|--proxy-user|--ftp-user) - COMPREPLY=( $(compgen -W "$(command sed -n \ + --user | --http-user | --proxy-user | --ftp-user) + COMPREPLY=($(compgen -W "$(command sed -n \ '/^login/s/^[[:blank:]]*login[[:blank:]]//p' ~/.netrc \ - 2>/dev/null)" -- "$cur") ) + 2>/dev/null)" -- "$cur")) return ;; --header) - COMPREPLY=( $(compgen -W 'Accept Accept-Charset Accept-Encoding + COMPREPLY=($(compgen -W 'Accept Accept-Charset Accept-Encoding Accept-Language Accept-Ranges Age Allow Authorization Cache-Control Connection Content-Encoding Content-Language Content-Length Content-Location Content-MD5 Content-Range @@ -130,29 +133,29 @@ _wget() Last-Modified Location Max-Forwards Pragma Proxy-Authenticate Proxy-Authorization Range Referer Retry-After Server TE Trailer Transfer-Encoding Upgrade User-Agent Vary Via Warning - WWW-Authenticate' -- "$cur") ) + WWW-Authenticate' -- "$cur")) compopt -o nospace return ;; - --local-encoding|--remote-encoding) + --local-encoding | --remote-encoding) type -P xauth &>/dev/null && _xfunc iconv _iconv_charsets return ;; - --execute|-!(-*)e) + --execute | -!(-*)e) return # TODO base=STR ;; --report-speed) - COMPREPLY=( $(compgen -W 'bits' -- "$cur") ) + COMPREPLY=($(compgen -W 'bits' -- "$cur")) return ;; --regex-type) - COMPREPLY=( $(compgen -W 'posix' -- "$cur") ) + COMPREPLY=($(compgen -W 'posix' -- "$cur")) return ;; - --base|--password|--ftp-password|--http-password|--proxy-password|\ - --default-page|--referer|--user-agent|--post-data|--warc-header|\ - --accept|--reject|--accept-regex|--reject-regex|--include-directories|\ - --exclude-directories|-!(-*)[BUARIX]) + --base | --password | --ftp-password | --http-password | --proxy-password | \ + --default-page | --referer | --user-agent | --post-data | --warc-header | \ + --accept | --reject | --accept-regex | --reject-regex | --include-directories | \ + --exclude-directories | -!(-*)[BUARIX]) # argument required but no completions available return ;; @@ -161,11 +164,11 @@ _wget() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _wget wget + complete -F _wget wget # ex: filetype=sh diff --git a/completions/wine b/completions/wine index dab45ae4..429fede4 100644 --- a/completions/wine +++ b/completions/wine @@ -5,16 +5,16 @@ _wine() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) - [[ $COMPREPLY ]] && return + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --version' -- "$cur")) + [[ ${COMPREPLY-} ]] && return fi _filedir '@([eE][xX][eE]?(.[sS][oO])|[cC][oO][mM]|[sS][cC][rR]|[mM][sS][iI])' else _filedir fi } && -complete -F _wine wine wine-development wine-stable + complete -F _wine wine wine-development wine-stable # ex: filetype=sh diff --git a/completions/withlist b/completions/withlist index cd030a27..4142471e 100644 --- a/completions/withlist +++ b/completions/withlist @@ -5,14 +5,14 @@ _withlist() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--lock --interactive --run --all --quiet - --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--lock --interactive --run --all --quiet + --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _withlist withlist + complete -F _withlist withlist # ex: filetype=sh diff --git a/completions/wodim b/completions/wodim index ac1dc5a9..b308291d 100644 --- a/completions/wodim +++ b/completions/wodim @@ -5,19 +5,19 @@ _cdrecord() local cur prev words cword _init_completion -n = || return - local i generic_options track_options track_mode + local generic_options track_options track_mode # foo=bar style option - if [[ "$cur" == *=* ]]; then + if [[ $cur == *=* ]]; then prev=${cur%%=*} cur=${cur#*=} case $prev in - textfile|cuefile|msifile) + textfile | cuefile | msifile) _filedir ;; blank) - COMPREPLY=( $(compgen -W 'help all fast track unreserve trtail - unclose session' -- "$cur") ) + COMPREPLY=($(compgen -W 'help all fast track unreserve trtail + unclose session' -- "$cur")) ;; driveropts) if [[ $cur == *=* ]]; then @@ -25,53 +25,55 @@ _cdrecord() cur=${cur#*=} case $prev in varirec) - COMPREPLY=( $(compgen -W "-2 -1 0 1 2" -- "$cur") ) + COMPREPLY=($(compgen -W "-2 -1 0 1 2" -- "$cur")) ;; gigarec) - COMPREPLY=( $(compgen -W "0.6 0.7 0.8 1.0 1.2 1.3 - 1.4" -- "$cur") ) + COMPREPLY=($(compgen -W "0.6 0.7 0.8 1.0 1.2 1.3 + 1.4" -- "$cur")) ;; tattoofile) _filedir ;; esac else - COMPREPLY=( $(compgen -W 'burnfree noburnfree varirec= + COMPREPLY=($(compgen -W 'burnfree noburnfree varirec= gigarec= audiomaster forcespeed noforcespeed speedread nospeedread singlesession nosinglesession hidecdr - nohidecdr tattooinfo tattoofile=' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + nohidecdr tattooinfo tattoofile=' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi ;; driver) - COMPREPLY=( $(compgen -W "$($1 driver=help 2>&1 | \ - awk 'NR > 1 { print $1 }') help" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 driver=help 2>&1 | + awk 'NR > 1 { print $1 }') help" -- "$cur")) ;; minbuf) - COMPREPLY=( $(compgen -W '{25..95}' -- "$cur") ) + COMPREPLY=($(compgen -W '{25..95}' -- "$cur")) ;; esac return fi - generic_options=( -version -v -V -d -silent -force -immed -dummy -clone \ - -dao -sao -tao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc -atip \ - -fix -nofix -waiti -load -lock -eject -format -setdropts -checkdrive \ - -prcap -inq -scanbus --devices -reset -abort -overburn -ignsize \ - -useinfo -packet -noclose -text debug= kdebug= minbuf= msifile= \ - speed= blank= fs= ts= dev= gracetime= timeout= driver= driveropts= \ - defpregap= pktsize= mcn= textfile= cuefile= ) - track_options=( -audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi \ - -isosize -pad -nopad -shorttrack -noshorttrack -preemp -nopreemp \ - -copy -nocopy -scms isrc= index= padsize= pregap= tsize= ) + generic_options=(-version -v -V -d -silent -force -immed -dummy -clone + -dao -sao -tao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc -atip + -fix -nofix -waiti -load -lock -eject -format -setdropts -checkdrive + -prcap -inq -scanbus --devices -reset -abort -overburn -ignsize + -useinfo -packet -noclose -text "debug=" "kdebug=" "minbuf=" + "msifile=" "speed=" "blank=" "fs=" "ts=" "dev=" "gracetime=" + "timeout=" "driver=" "driveropts=" "defpregap=" "pktsize=" "mcn=" + "textfile=" "cuefile=") + track_options=(-audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi + -isosize -pad -nopad -shorttrack -noshorttrack -preemp -nopreemp + -copy -nocopy -scms "isrc=" "index=" "padsize=" "pregap=" "tsize=") # look if previous was either a file or a track option track_mode=0 - if [[ $cword -gt 1 ]]; then + if ((cword > 1)); then if [[ -f $prev ]]; then track_mode=1 else - for (( i=0; i < ${#track_options[@]}; i++ )); do - if [[ "${track_options[i]}" == "$prev" ]]; then + local opt + for opt in "${track_options[@]}"; do + if [[ $opt == "$prev" ]]; then track_mode=1 break fi @@ -82,13 +84,13 @@ _cdrecord() # files are always eligible completion _filedir # track options are always available - COMPREPLY+=( $(compgen -W '${track_options[@]}' -- "$cur") ) + COMPREPLY+=($(compgen -W '${track_options[@]}' -- "$cur")) # general options are no more available after file or track option - if [[ $track_mode -eq 0 ]]; then - COMPREPLY+=( $(compgen -W '${generic_options[@]}' -- "$cur") ) + if ((track_mode == 0)); then + COMPREPLY+=($(compgen -W '${generic_options[@]}' -- "$cur")) fi - [[ $COMPREPLY == *= ]] && compopt -o nospace + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _cdrecord cdrecord wodim + complete -F _cdrecord cdrecord wodim # ex: filetype=sh diff --git a/completions/wol b/completions/wol index 0222b24d..eada070b 100644 --- a/completions/wol +++ b/completions/wol @@ -6,20 +6,22 @@ _wol() _init_completion -s -n : || return case $prev in - --version|--help|--port|--passwd|--wait|-!(-*)[Vpw]) + --version | --help | --port | --passwd | --wait | -!(-*)[Vpw]) return ;; - --host|--ipaddr|-!(-*)[hi]) + --host | --ipaddr | -!(-*)[hi]) # Broadcast addresses local PATH=$PATH:/sbin - COMPREPLY=( $({ ip addr show || ifconfig -a; } 2>/dev/null | \ + COMPREPLY=($({ + ip addr show || ifconfig -a + } 2>/dev/null | 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') ) + 's/.*inet.*[[:space:]]brd[[:space:]]\([^[:space:]]*\).*/\1/p' -ne \ + 's/.*[[:space:]]broadcast[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p')) _known_hosts_real -- "$cur" return ;; - --file|-!(-*)f) + --file | -!(-*)f) _filedir return ;; @@ -27,14 +29,14 @@ _wol() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _mac_addresses } && -complete -F _wol wol + complete -F _wol wol # ex: filetype=sh diff --git a/completions/wsimport b/completions/wsimport index 406a47d7..d5bec9fe 100644 --- a/completions/wsimport +++ b/completions/wsimport @@ -6,7 +6,7 @@ _wsimport() _init_completion -n : || return case $prev in - -help|-version|-B|-p|-wsdllocation) + -help | -version | -B | -p | -wsdllocation) return ;; -b) @@ -17,12 +17,12 @@ _wsimport() _filedir '@(xml|soc|catalog)' return ;; - -d|–s) + -d | –s) _filedir -d return ;; -target) - COMPREPLY=( $(compgen -W '2.0 2.1 2.2' -- "$cur") ) + COMPREPLY=($(compgen -W '2.0 2.1 2.2' -- "$cur")) return ;; -clientjar) @@ -35,14 +35,14 @@ _wsimport() _known_hosts_real -- "${cur#-httpproxy:}" return elif [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - [[ $COMPREPLY == *: ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + [[ ${COMPREPLY-} == *: ]] && compopt -o nospace __ltrim_colon_completions "$cur" return fi _filedir wsdl } && -complete -F _wsimport wsimport + complete -F _wsimport wsimport # ex: filetype=sh diff --git a/completions/wtf b/completions/wtf index 6a596a3b..27fc10a7 100644 --- a/completions/wtf +++ b/completions/wtf @@ -7,34 +7,36 @@ _wtf() _init_completion || return [[ $prev == -f ]] && _filedir && return - [[ "${words[*]}" == *\ -f* ]] && addf= || addf=-f + [[ ${words[*]} == *\ -f* ]] && addf= || addf=-f if [[ $cur == -* ]]; then - COMPREPLY=( $addf ) + COMPREPLY=($addf) return fi local db set -- "${words[@]}" - while [[ $# -gt 0 ]]; do + while (($# > 0)); do if [[ $1 == -f ]]; then - shift ; db=$1 ; break + shift + db=$1 + break fi shift done - if [[ -z "$db" ]]; then + if [[ ! -v db ]]; then local f - for f in "$ACRONYMDB" /usr/share/misc/acronyms \ + for f in "${ACRONYMDB-}" /usr/share/misc/acronyms \ /usr/share/games/bsdgames/acronyms; do - [[ -f "$f" ]] && db="$f" && break + [[ -f $f ]] && db="$f" && break done - [[ -z "$db" ]] && return + [[ -v db ]] || return fi - COMPREPLY=( $(compgen -W "$(cut -f 1 -s $db* 2>/dev/null) $addf" \ - -- "${cur^^}") ) + COMPREPLY=($(compgen -W "$(cut -f 1 -s $db* 2>/dev/null) $addf" \ + -- "${cur^^}")) } && -complete -F _wtf wtf + complete -F _wtf wtf # ex: filetype=sh diff --git a/completions/wvdial b/completions/wvdial index e0316617..86674002 100644 --- a/completions/wvdial +++ b/completions/wvdial @@ -18,29 +18,29 @@ _wvdial() case $cur in -*) - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace ;; *) # start with global and personal config files config="/etc/wvdial.conf"$'\n'"$HOME/.wvdialrc" # replace with command line config file if present - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == "--config" ]]; then - config=${words[i+1]} + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == "--config" ]]; then + config=${words[i + 1]} break fi done # parse config files for sections and # remove default section - COMPREPLY=( $(command sed -ne "s|^\[Dialer \($cur.*\)\]$|\1|p" $config \ + COMPREPLY=($(command sed -ne "s|^\[Dialer \($cur.*\)\]$|\1|p" $config \ 2>/dev/null | command grep -v '^Defaults$')) # escape spaces - COMPREPLY=${COMPREPLY// /\\ } + COMPREPLY=(${COMPREPLY[@]// /\\ }) ;; esac } && -complete -F _wvdial wvdial + complete -F _wvdial wvdial # ex: filetype=sh diff --git a/completions/xdg-mime b/completions/xdg-mime index 72e92c66..74c26c43 100644 --- a/completions/xdg-mime +++ b/completions/xdg-mime @@ -2,9 +2,9 @@ _xdg_mime_mimetype() { - COMPREPLY+=( $(compgen -S / -W 'application audio font image message model - multipart text video' -- "$cur") ) - [[ $COMPREPLY == */ ]] && compopt -o nospace + COMPREPLY+=($(compgen -S / -W 'application audio font image message model + multipart text video' -- "$cur")) + [[ ${COMPREPLY-} == */ ]] && compopt -o nospace } _xdg_mime() @@ -15,59 +15,60 @@ _xdg_mime() local args _count_args - if [[ $args -eq 1 ]]; then + if ((args == 1)); then if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '--help --manual --version' -- "$cur") ) + COMPREPLY=($(compgen -W '--help --manual --version' -- "$cur")) return fi - COMPREPLY=( $(compgen -W \ - 'query default install uninstall' -- "$cur") ) + 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") ) + if ((args == 2)); then + COMPREPLY=($(compgen -W 'filetype default' -- "$cur")) return fi - case ${words[2]} in # TODO and $args -eq 3 (takes only one arg!) + case ${words[2]} in # TODO and args == 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[@]##*/}" ) + if ((args == 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") ) + COMPREPLY=($(compgen -W '${desktops[@]}' -- "$cur")) else _xdg_mime_mimetype fi ;; install) if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '--mode --novendor' -- "$cur") ) + COMPREPLY=($(compgen -W '--mode --novendor' -- "$cur")) elif [[ $prev == --mode ]]; then - COMPREPLY=( $(compgen -W 'user system' -- "$cur") ) + COMPREPLY=($(compgen -W 'user system' -- "$cur")) else _filedir xml fi ;; uninstall) if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '--mode' -- "$cur") ) + COMPREPLY=($(compgen -W '--mode' -- "$cur")) elif [[ $prev == --mode ]]; then - COMPREPLY=( $(compgen -W 'user system' -- "$cur") ) + COMPREPLY=($(compgen -W 'user system' -- "$cur")) else _filedir xml fi ;; esac } && -complete -F _xdg_mime xdg-mime + complete -F _xdg_mime xdg-mime # ex: filetype=sh diff --git a/completions/xdg-settings b/completions/xdg-settings index c14d37ba..abd92464 100644 --- a/completions/xdg-settings +++ b/completions/xdg-settings @@ -6,26 +6,26 @@ _xdg_settings() _init_completion || return case $prev in - --help|--list|--manual|--version) + --help | --list | --manual | --version) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$("$1" --help | - tr "{|" "\n" | _parse_help -)' -- "$cur") ) + COMPREPLY=($(compgen -W '$("$1" --help | + tr "{|" "\n" | _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") ) + if ((args == 1)); then + COMPREPLY=($(compgen -W "get check set" -- "$cur")) + elif ((args == 2)); then + COMPREPLY=($(compgen -W \ + '$("$1" --list | awk "!/^Known/ { print \$1 }")' -- "$cur")) fi } && -complete -F _xdg_settings xdg-settings + complete -F _xdg_settings xdg-settings # ex: filetype=sh diff --git a/completions/xfreerdp b/completions/xfreerdp index f025cfce..f17414f2 100644 --- a/completions/xfreerdp +++ b/completions/xfreerdp @@ -5,63 +5,63 @@ _xfreerdp() local cur prev words cword _init_completion -n : || return - case $prev in # old/dash syntax + case $prev in # old/dash syntax -k) - COMPREPLY=( $(compgen -W '$("$1" --kbd-list | - awk "/^0x/ { print \$1 }")' -- "$cur") ) + COMPREPLY=($(compgen -W '$("$1" --kbd-list | + awk "/^0x/ { print \$1 }")' -- "$cur")) return ;; -a) - COMPREPLY=( $(compgen -W '8 15 16 24 32' -- "$cur") ) + COMPREPLY=($(compgen -W '8 15 16 24 32' -- "$cur")) return ;; -x) - COMPREPLY=( $(compgen -W 'broadband modem lan' -- "$cur") ) + COMPREPLY=($(compgen -W 'broadband modem lan' -- "$cur")) return ;; --plugin) - COMPREPLY=( $(compgen -W 'cliprdr rdpsnd rdpdr' -- "$cur") ) + COMPREPLY=($(compgen -W 'cliprdr rdpsnd rdpdr' -- "$cur")) return ;; esac - case $cur in # new/slash syntax + case $cur in # new/slash syntax /kbd:*) - COMPREPLY=( $(compgen -W '$("$1" /kbd-list | - awk "/^0x/ { print \$1 }")' -- "${cur#/kbd:}") ) + COMPREPLY=($(compgen -W '$("$1" /kbd-list | + awk "/^0x/ { print \$1 }")' -- "${cur#/kbd:}")) return ;; /bpp:*) - COMPREPLY=( $(compgen -W '8 15 16 24 32' -- "${cur#/bpp:}") ) + COMPREPLY=($(compgen -W '8 15 16 24 32' -- "${cur#/bpp:}")) return ;; - /*:*|/help|/version|-h|--help|--version) + /*:* | /help | /version | -h | --help | --version) return ;; esac - if [[ "$cur" == /* ]]; then - COMPREPLY=( $(compgen -W '$("$1" --help | + if [[ $cur == /* ]]; then + COMPREPLY=($(compgen -W '$("$1" --help | awk "\$1 ~ /^\\// && \$1 !~ /^.(flag\$|option:)/ { sub(\":.*\",\":\",\$1); print \$1 }")' \ - -- "$cur") ) - [[ $COMPREPLY == *: ]] && compopt -o nospace - elif [[ "$cur" == [+-]* ]]; then + -- "$cur")) + [[ ${COMPREPLY-} == *: ]] && compopt -o nospace + elif [[ $cur == [+-]* ]]; then local char=${cur:0:1} local help="$($1 --help)" - if [[ "$help" == */help* ]]; then # new/slash syntax - COMPREPLY=( $(compgen -W '$(awk " + if [[ $help == */help* ]]; then # new/slash syntax + COMPREPLY=($(compgen -W '$(awk " \$1 ~ /^[+-]/ && \$1 !~ /^.toggle\$/ { sub(\"^.\",\"$char\",\$1); print \$1 } - " <<<"$help")' -- "$cur") ) - else # old/dash syntax - COMPREPLY=( $(_parse_help - <<<"$help") ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]%:}' -- "$cur") ) + " <<<"$help")' -- "$cur")) + else # old/dash syntax + COMPREPLY=($(_parse_help - <<<"$help")) + COMPREPLY=($(compgen -W '${COMPREPLY[@]%:}' -- "$cur")) fi else - COMPREPLY=( $(compgen -W "$(awk '{print $1}' ~/.freerdp/known_hosts \ - 2>/dev/null)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(awk '{print $1}' ~/.freerdp/known_hosts \ + 2>/dev/null)" -- "$cur")) fi } && -complete -F _xfreerdp xfreerdp + complete -F _xfreerdp xfreerdp # ex: filetype=sh diff --git a/completions/xgamma b/completions/xgamma index 005928d2..8d77ba3b 100644 --- a/completions/xgamma +++ b/completions/xgamma @@ -9,37 +9,37 @@ _xgamma() -screen) local screens=$(xrandr --query 2>/dev/null | command sed -n \ '/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null) - COMPREPLY=( $(compgen -W "$screens" -- "$cur") ) + COMPREPLY=($(compgen -W "$screens" -- "$cur")) return ;; - -gamma|-rgamma|-ggamma|-bgamma) + -gamma | -rgamma | -ggamma | -bgamma) # expect f.f - if [[ $cur && "$cur" != *.* ]]; then - COMPREPLY=( . ) + if [[ $cur && $cur != *.* ]]; then + COMPREPLY=(.) fi - COMPREPLY+=( $(compgen -W "{0..9}") ) + COMPREPLY+=($(compgen -W "{0..9}")) compopt -o nospace return ;; -display) # expect hostname:displaynumber.screennumber - if [[ "$cur" == :* && "$cur" != :*.* ]]; then + if [[ $cur == :* && $cur != :*.* ]]; then # FIXME: where to get local display numbers? local display=${cur#:} - COMPREPLY=( $(compgen -W "${display:-0}.") ) + COMPREPLY=($(compgen -W "${display:-0}.")) compopt -o nospace - elif [[ "$cur" == :*.* ]]; then + elif [[ $cur == :*.* ]]; then # local screen numbers local t screens=$(xrandr --query 2>/dev/null | command sed -ne \ '/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null) t="${cur#:}" - COMPREPLY=( $(compgen -P "${t%.*}." -W "$screens" -- \ - "${cur##*.}") ) - elif [[ "$cur" != *:* ]]; then + COMPREPLY=($(compgen -P "${t%.*}." -W "$screens" -- \ + "${cur##*.}")) + elif [[ $cur != *:* ]]; then # complete hostnames _known_hosts_real -c -- "$cur" if [[ ! $cur ]]; then - COMPREPLY+=( : ) + COMPREPLY+=(:) fi compopt -o nospace fi @@ -48,12 +48,14 @@ _xgamma() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - [[ $COMPREPLY ]] && return + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + if [[ ${COMPREPLY-} ]]; then + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi fi } && -complete -F _xgamma xgamma + complete -F _xgamma xgamma # ex: filetype=sh diff --git a/completions/xhost b/completions/xhost index 53b3695b..648ae4f1 100644 --- a/completions/xhost +++ b/completions/xhost @@ -1,6 +1,6 @@ # xhost(1) completion -*- shell-script -*- -_xhost () +_xhost() { local cur prev words cword _init_completion || return @@ -8,9 +8,9 @@ _xhost () case $cur in +*) _known_hosts_real -p+ -- "${cur:1}" ;; -*) _known_hosts_real -p- -- "${cur:1}" ;; - *) _known_hosts_real -- "$cur" ;; + *) _known_hosts_real -- "$cur" ;; esac } && -complete -F _xhost xhost + complete -F _xhost xhost # ex: filetype=sh diff --git a/completions/xmllint b/completions/xmllint index f5865b39..a6ef38f4 100644 --- a/completions/xmllint +++ b/completions/xmllint @@ -6,11 +6,11 @@ _xmllint() _init_completion || return case $prev in - -o|--output) + -o | --output) _filedir return ;; - --path|--dtdvalidfpi|--maxmem|--pattern|--xpath) + --path | --dtdvalidfpi | --maxmem | --pattern | --xpath) # argument required but no completions available return ;; @@ -35,19 +35,19 @@ _xmllint() return ;; --pretty) - COMPREPLY=( $(compgen -W '{0..2}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..2}' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - COMPREPLY=( "${COMPREPLY[@]%:}" ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + COMPREPLY=("${COMPREPLY[@]%:}") return fi _filedir '@(*ml|htm|svg?(z)|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)?(.gz)' } && -complete -F _xmllint xmllint + complete -F _xmllint xmllint # ex: filetype=sh diff --git a/completions/xmlwf b/completions/xmlwf index 9cd0e195..b397af94 100644 --- a/completions/xmlwf +++ b/completions/xmlwf @@ -11,8 +11,8 @@ _xmlwf() return ;; -*e) - COMPREPLY=( $(compgen -W 'US-ASCII UTF-8 UTF-16 ISO-8859-1' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'US-ASCII UTF-8 UTF-16 ISO-8859-1' \ + -- "$cur")) return ;; -*v) @@ -20,13 +20,13 @@ _xmlwf() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi _filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)' } && -complete -F _xmlwf xmlwf + complete -F _xmlwf xmlwf # ex: filetype=sh diff --git a/completions/xmms b/completions/xmms index 9f084c38..af4aefe9 100644 --- a/completions/xmms +++ b/completions/xmms @@ -6,24 +6,24 @@ _xmms() _init_completion -s || return case $prev in - --help|--version|-!(-*)[hv]) + --help | --version | -!(-*)[hv]) return ;; - --toggle-shuffle|--toggle-repeat|--toggle-advance|-!(-*)[SRA]) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + --toggle-shuffle | --toggle-repeat | --toggle-advance | -!(-*)[SRA]) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else _filedir '@(mp[23]|ogg|wav|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)' fi } && -complete -F _xmms xmms + complete -F _xmms xmms # ex: filetype=sh diff --git a/completions/xmodmap b/completions/xmodmap index 38bc6391..7cfa230b 100644 --- a/completions/xmodmap +++ b/completions/xmodmap @@ -6,18 +6,18 @@ _xmodmap() _init_completion || return case $prev in - -display|-e) + -display | -e) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) return fi _filedir } && -complete -F _xmodmap xmodmap + complete -F _xmodmap xmodmap # ex: filetype=sh diff --git a/completions/xrandr b/completions/xrandr index 9b5b6a59..16704e31 100644 --- a/completions/xrandr +++ b/completions/xrandr @@ -6,58 +6,58 @@ _xrandr() _init_completion || return case "$prev" in - -display|-d|-help|-s|--size|-r|--rate|--refresh|--screen|--fb|--fbmm|\ - --dpi|--pos|--set|--scale|--transform|--crtc|--panning|--gamma|\ - --newmode|--rmmode|--addmode|--delmode) + -display | -d | -help | -s | --size | -r | --rate | --refresh | --screen | --fb | --fbmm | \ + --dpi | --pos | --set | --scale | --transform | --crtc | --panning | --gamma | \ + --newmode | --rmmode | --addmode | --delmode) return ;; - --output|--left-of|--right-of|--above|--below|--same-as) + --output | --left-of | --right-of | --above | --below | --same-as) local outputs=$("$1" | awk '/connected/ {print $1}') - COMPREPLY=( $(compgen -W "$outputs" -- "$cur") ) + COMPREPLY=($(compgen -W "$outputs" -- "$cur")) return ;; --mode) local i output - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == --output ]]; then - output=${words[i+1]} + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == --output ]]; then + output=${words[i + 1]} break fi done - if [[ $output ]]; then + if [[ -v output ]]; then local modes=$("$1" | command sed -e "1,/^$output / d" \ -e "/connected/,$ d" \ -e "s/\([^[:space:]]\)[[:space:]].*/\1/") - COMPREPLY=( $(compgen -W "$modes" -- "$cur") ) + COMPREPLY=($(compgen -W "$modes" -- "$cur")) fi return ;; - -o|--orientation) - COMPREPLY=( $(compgen -W 'normal inverted left right 0 1 2 3' -- \ - "$cur") ) + -o | --orientation) + COMPREPLY=($(compgen -W 'normal inverted left right 0 1 2 3' -- \ + "$cur")) return ;; --reflect) - COMPREPLY=( $(compgen -W 'normal x y xy' -- "$cur") ) + COMPREPLY=($(compgen -W 'normal x y xy' -- "$cur")) return ;; --rotate) - COMPREPLY=( $(compgen -W 'normal inverted left right' -- "$cur") ) + COMPREPLY=($(compgen -W 'normal inverted left right' -- "$cur")) return ;; - --setprovideroutputsource|--setprovideroffloadsink) + --setprovideroutputsource | --setprovideroffloadsink) local providers=$("$1" --listproviders 2>/dev/null | command sed -ne 's/.* name:\([^ ]*\).*/\1/p') - COMPREPLY=( $(compgen -W "$providers" -- "$cur") ) + COMPREPLY=($(compgen -W "$providers" -- "$cur")) # TODO 2nd arg needed, is that a provider as well? return ;; esac - COMPREPLY=( $(compgen -W '$("$1" -help 2>&1 | + COMPREPLY=($(compgen -W '$("$1" -help 2>&1 | command sed -e "s/ or / /g" -e "s/<[^>]*>]//g" | _parse_help -)' \ - -- "$cur") ) + -- "$cur")) } && -complete -F _xrandr xrandr + complete -F _xrandr xrandr # ex: filetype=sh diff --git a/completions/xrdb b/completions/xrdb index d9f11439..f46f90b9 100644 --- a/completions/xrdb +++ b/completions/xrdb @@ -6,22 +6,22 @@ _xrdb() _init_completion || return case $prev in - -backup|-display|-help) + -backup | -display | -help) return ;; - -cpp|-edit) + -cpp | -edit) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir } && -complete -F _xrdb xrdb + complete -F _xrdb xrdb # ex: filetype=sh diff --git a/completions/xsltproc b/completions/xsltproc index dbe68c45..4cb70719 100644 --- a/completions/xsltproc +++ b/completions/xsltproc @@ -6,7 +6,7 @@ _xsltproc() _init_completion || return case $prev in - --output|-o) + --output | -o) _filedir return ;; @@ -16,11 +16,11 @@ _xsltproc() ;; --encoding) # some aliases removed - COMPREPLY=( $(compgen -X '@(UTF[1378]|8859|ISO[0-9_])*' \ - -W "$(iconv -l | command sed -e 's/\/.*//')" -- "$cur") ) + COMPREPLY=($(compgen -X '@(UTF[1378]|8859|ISO[0-9_])*' \ + -W "$(iconv -l | command sed -e 's/\/.*//')" -- "$cur")) return ;; - --param|--stringparam) + --param | --stringparam) return ;; # not really like --writesubtree @@ -34,16 +34,16 @@ _xsltproc() ;; esac - [[ $cword -gt 2 && `_get_cword '' 2` == --?(string)param ]] && return + [[ $cword -gt 2 && $(_get_cword '' 2) == --?(string)param ]] && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - COMPREPLY=( "${COMPREPLY[@]%:}" ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + COMPREPLY=("${COMPREPLY[@]%:}") else # TODO: 1st file xsl|xslt, 2nd XML _filedir '@(xsl|xslt|xml|dbk|docbook|page)' fi } && -complete -F _xsltproc xsltproc + complete -F _xsltproc xsltproc # ex: filetype=sh diff --git a/completions/xvfb-run b/completions/xvfb-run index 162c66ed..ed2788a9 100644 --- a/completions/xvfb-run +++ b/completions/xvfb-run @@ -6,7 +6,7 @@ _xvfb_run() _init_completion -s || return local i - for (( i=1; i <= COMP_CWORD; i++ )); do + for ((i = 1; i <= COMP_CWORD; i++)); do if [[ ${COMP_WORDS[i]} != -* ]]; then _command_offset $i return @@ -15,10 +15,10 @@ _xvfb_run() done case $prev in - --help|--server-num|--xauth-protocol|--server-args|-!(-*)[hnps]) + --help | --server-num | --xauth-protocol | --server-args | -!(-*)[hnps]) return ;; - --error-file|--auth-file|-!(-*)[ef]) + --error-file | --auth-file | -!(-*)[ef]) _filedir return ;; @@ -26,11 +26,11 @@ _xvfb_run() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _xvfb_run xvfb-run + complete -F _xvfb_run xvfb-run # ex: filetype=sh diff --git a/completions/xxd b/completions/xxd index f6bcb4a2..a470bb0d 100644 --- a/completions/xxd +++ b/completions/xxd @@ -6,18 +6,18 @@ _xxd() _init_completion || return case $prev in - -h|-help|-c|-cols|-g|-groupsize|-l|-len|-s|-seek|-v|-version) + -h | -help | -c | -cols | -g | -groupsize | -l | -len | -s | -seek | -v | -version) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) return fi _filedir } && -complete -F _xxd xxd + complete -F _xxd xxd # ex: filetype=sh diff --git a/completions/xz b/completions/xz index b64921f1..73958c50 100644 --- a/completions/xz +++ b/completions/xz @@ -8,40 +8,40 @@ _xz() local xspec="*.@(xz|lzma|txz|tlz)" case $prev in - --decompress|--list|--test|-!(-*)[dlt]*) + --decompress | --list | --test | -!(-*)[dlt]*) xspec="!"$xspec ;; - --files|--files0) + --files | --files0) _filedir return ;; - --check|-!(-*)C) - COMPREPLY=( $(compgen -W 'crc32 crc64 sha256 none' -- "$cur") ) + --check | -!(-*)C) + COMPREPLY=($(compgen -W 'crc32 crc64 sha256 none' -- "$cur")) return ;; - --format|-!(-*)F) - COMPREPLY=( $(compgen -W 'auto xz lzma raw' -- "$cur") ) + --format | -!(-*)F) + COMPREPLY=($(compgen -W 'auto xz lzma raw' -- "$cur")) return ;; - --threads|-!(-*)T) - COMPREPLY=( $(compgen -W "{0..$(_ncpus)}" -- "$cur") ) + --threads | -!(-*)T) + COMPREPLY=($(compgen -W "{0..$(_ncpus)}" -- "$cur")) return ;; - --memlimit|--memlimit-compress|--memlimit-decompress|--memory|\ - --suffix|--delta|--lzma1|--lzma2|-!(-*)[MS]) + --memlimit | --memlimit-compress | --memlimit-decompress | --memory | \ + --suffix | --delta | --lzma1 | --lzma2 | -!(-*)[MS]) return ;; - --help|--long-help|--version|--info-memory|-!(-*)[hHV]) + --help | --long-help | --version | --info-memory | -!(-*)[hHV]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --long-help) {-1..-9}' \ - -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --long-help) {-1..-9}' \ + -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -49,8 +49,8 @@ _xz() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _xz xz pxz + complete -F _xz xz pxz # ex: filetype=sh diff --git a/completions/xzdec b/completions/xzdec index 6b402eb3..993bd2b2 100644 --- a/completions/xzdec +++ b/completions/xzdec @@ -6,24 +6,24 @@ _xzdec() _init_completion -s || return case $prev in - --memory|-!(-*)M) + --memory | -!(-*)M) return ;; - --help|--version|-!(-*)[hV]) + --help | --version | -!(-*)[hV]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir xz # no lzma support here as of xz 4.999.9beta } && -complete -F _xzdec xzdec + complete -F _xzdec xzdec # ex: filetype=sh diff --git a/completions/ypmatch b/completions/ypmatch index 655390f2..13249f06 100644 --- a/completions/ypmatch +++ b/completions/ypmatch @@ -12,15 +12,15 @@ _ypmatch() if [[ $cmd == ypmatch && $cword -eq 1 && ${#words[@]} -eq 3 ]]; then map=${words[2]} - COMPREPLY=( $(compgen -W '$(ypcat $map 2>/dev/null | \ - cut -d':' -f 1)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(ypcat $map 2>/dev/null | \ + cut -d':' -f 1)' -- "$cur")) else [[ $cmd == ypmatch && $cword -ne 2 ]] && return - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ '$(printf "%s\n" $(ypcat -x 2>/dev/null | \ - cut -d"\"" -f 2))' -- "$cur") ) + cut -d"\"" -f 2))' -- "$cur")) fi } && -complete -F _ypmatch ypmatch ypcat + complete -F _ypmatch ypmatch ypcat # ex: filetype=sh diff --git a/completions/yum-arch b/completions/yum-arch index f2b902a3..883c77e1 100644 --- a/completions/yum-arch +++ b/completions/yum-arch @@ -5,12 +5,12 @@ _yum_arch() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-d -v -vv -n -c -z -s -l -q' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-d -v -vv -n -c -z -s -l -q' -- "$cur")) else _filedir -d fi } && -complete -F _yum_arch yum-arch + complete -F _yum_arch yum-arch # ex: filetype=sh diff --git a/completions/zopfli b/completions/zopfli index 3c7ea403..8c02885e 100644 --- a/completions/zopfli +++ b/completions/zopfli @@ -11,10 +11,10 @@ _zopfli() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W \ - '$(_parse_help "$1" -h | command sed -e "s/#$//")' -- "$cur") ) - [[ $COMPREPLY == --i ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W \ + '$(_parse_help "$1" -h | command sed -e "s/#$//")' -- "$cur")) + [[ ${COMPREPLY-} == --i ]] && compopt -o nospace return fi @@ -22,8 +22,8 @@ _zopfli() local IFS=$'\n' xspec="*.@(gz|t[ag]z)" compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _zopfli zopfli + complete -F _zopfli zopfli # ex: filetype=sh diff --git a/completions/zopflipng b/completions/zopflipng index 3d815404..4526cd92 100644 --- a/completions/zopflipng +++ b/completions/zopflipng @@ -6,34 +6,34 @@ _zopflipng() _init_completion -s || return case $prev in - -h|--help) + -h | --help) return ;; --splitting) - COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..3}' -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(_parse_help "$1" -h) ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]%:}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(_parse_help "$1" -h)) + COMPREPLY=($(compgen -W '${COMPREPLY[@]%:}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - if [[ "${words[*]}" != *\ --prefix=* ]]; then + if [[ ${words[*]} != *\ --prefix=* ]]; then # 2 png args only if --prefix not given local args _count_args - [[ $args -lt 3 ]] && _filedir png + ((args < 3)) && _filedir png else # otherwise arbitrary number of png args _filedir png fi } && -complete -F _zopflipng zopflipng + complete -F _zopflipng zopflipng # ex: filetype=sh |