diff --git a/bash_completion b/bash_completion index 1be07cc2d31..4bfe022ccb0 100644 --- a/bash_completion +++ b/bash_completion @@ -1190,10 +1190,52 @@ _comp_initialize() return 0 } -# Helper function for _parse_help and _parse_usage. +# Helper function for _comp_compgen_help and _comp_compgen_usage. +# Obtain the help output based on the arguments. +# @param $@ args Arguments specified to the caller. +# @var[out] _lines +# @return 2 if the usage is wrong, 1 if no output is obtained, or otherwise 0. +_comp_compgen_help__get_help_lines() +{ + local -a help_cmd + case ${1-} in + -) + if (($# > 1)); then + printf 'bash_completion: %s -: extra arguments for -\n' "${FUNCNAME[1]}" >&2 + printf 'usage: %s -\n' "${FUNCNAME[1]}" >&2 + printf 'usage: %s -c cmd args...\n' "${FUNCNAME[1]}" >&2 + printf 'usage: %s [-- args...]\n' "${FUNCNAME[1]}" >&2 + return 2 + fi + help_cmd=(exec cat) + ;; + -c) + if (($# < 2)); then + printf 'bash_completion: %s -c: no command is specified\n' "${FUNCNAME[1]}" >&2 + printf 'usage: %s -\n' "${FUNCNAME[1]}" >&2 + printf 'usage: %s -c cmd args...\n' "${FUNCNAME[1]}" >&2 + printf 'usage: %s [-- args...]\n' "${FUNCNAME[1]}" >&2 + return 2 + fi + help_cmd=("${@:2}") + ;; + --) shift 1 ;& + *) + local ret + _comp_dequote "${comp_args[0]-}" || ret=${comp_args[0]-} + help_cmd=("${ret:-false}" "$@") + ;; + esac + + local ret + _comp_split -l ret "$(LC_ALL=C "${help_cmd[@]}" 2>&1)" && + _lines=("${ret[@]}") +} + +# Helper function for _comp_compgen_help and _comp_compgen_usage. +# @var[in,out] _options Add options # @return True (0) if an option was found, False (> 0) otherwise -# TODO: rename per API conventions, rework to use vars rather than outputting -__parse_options() +_comp_compgen_help__parse() { local option option2 i @@ -1219,7 +1261,7 @@ __parse_options() if [[ $option =~ (\[((no|dont)-?)\]). ]]; then option2=${option/"${BASH_REMATCH[1]}"/} option2=${option2%%[<{().[]*} - printf '%s\n' "${option2/=*/=}" + _options+=("${option2/=*/=}") option=${option/"${BASH_REMATCH[1]}"/"${BASH_REMATCH[2]}"} fi @@ -1227,100 +1269,81 @@ __parse_options() option=${option/=*/=} [[ $option ]] || return 1 - printf '%s\n' "$option" + _options+=("$option") } -# Parse GNU style help output of the given command. -# @param $1 command; if "-", read from stdin and ignore rest of args -# @param $2 command options (default: --help) +# Parse GNU style help output of the given command and generate and store +# completions in an array. The help output is produced in the way depending on +# the usage: +# usage: _comp_compgen_help - # read from stdin +# usage: _comp_compgen_help -c cmd args... # run "cmd args..." +# usage: _comp_compgen_help [[--] args...] # run "${comp_args[0]} args..." +# When no arguments are specified, `--help` is assumed. # -# TODO: rename per API conventions, rework to use vars rather than outputting -_parse_help() +# @var[in] comp_args[0] +_comp_compgen_help() { - local IFS=$' \t\n' - local reset_monitor=$(shopt -po monitor) reset_lastpipe=$(shopt -p lastpipe) reset_noglob=$(shopt -po noglob) - set +o monitor - shopt -s lastpipe - set -o noglob + (($#)) || set -- -- --help - local cmd=$1 - local line rc=1 - ( - case $cmd in - -) exec cat ;; - *) - # shellcheck disable=SC2086 - _comp_dequote "$cmd" && LC_ALL=C "$ret" ${2:---help} 2>&1 - ;; - esac - ) | - while read -r line; do - - [[ $line == *([[:blank:]])-* ]] || continue - # transform "-f FOO, --foo=FOO" to "-f , --foo=FOO" etc - while [[ $line =~ ((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+([,_-]+[A-Z0-9]+)?(\.\.+)?\]? ]]; do - line=${line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"} - done - __parse_options "${line// or /, }" && rc=0 + local -a _lines + _comp_compgen_help__get_help_lines "$@" || return "$?" + local -a _options=() + local _line + for _line in "${_lines[@]}"; do + [[ $_line == *([[:blank:]])-* ]] || continue + # transform "-f FOO, --foo=FOO" to "-f , --foo=FOO" etc + while [[ $_line =~ ((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+([,_-]+[A-Z0-9]+)?(\.\.+)?\]? ]]; do + _line=${_line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"} done + _comp_compgen_help__parse "${_line// or /, }" + done + ((${#_options[@]})) || return 1 - $reset_monitor - $reset_lastpipe - $reset_noglob - return $rc + _comp_compgen -- -W '"${_options[@]}"' + return 0 } -# Parse BSD style usage output (options in brackets) of the given command. -# @param $1 command; if "-", read from stdin and ignore rest of args -# @param $2 command options (default: --usage) -# -# TODO: rename per API conventions, rework to use vars rather than outputting -_parse_usage() -{ - local IFS=$' \t\n' - local reset_monitor=$(shopt -po monitor) reset_lastpipe=$(shopt -p lastpipe) reset_noglob=$(shopt -po noglob) - set +o monitor - shopt -s lastpipe - set -o noglob - - local cmd=$1 - local line match option i char rc=1 - ( - case $cmd in - -) exec cat ;; - *) - # shellcheck disable=SC2086 - _comp_dequote "$cmd" && LC_ALL=C "$ret" ${2:---usage} 2>&1 - ;; - esac - ) | - while read -r line; do - - while [[ $line =~ \[[[:space:]]*(-[^]]+)[[:space:]]*\] ]]; do - match=${BASH_REMATCH[0]} - option=${BASH_REMATCH[1]} - case $option in - -?(\[)+([a-zA-Z0-9?])) - # Treat as bundled short options - for ((i = 1; i < ${#option}; i++)); do - char=${option:i:1} - [[ $char != '[' ]] && printf '%s\n' -"$char" && rc=0 - done - ;; - *) - __parse_options "$option" && rc=0 - ;; - esac - line=${line#*"$match"} - done - +# Parse BSD style usage output (options in brackets) of the given command. The +# help output is produced in the way depending on the usage: +# usage: _comp_compgen_usage - # read from stdin +# usage: _comp_compgen_usage -c cmd args... # run "cmd args..." +# usage: _comp_compgen_usage [[--] args...] # run "${comp_args[0]} args..." +# When no arguments are specified, `--usage` is assumed. +# +# @var[in] comp_args[0] +_comp_compgen_usage() +{ + (($#)) || set -- -- --usage + + local -a _lines + _comp_compgen_help__get_help_lines "$@" || return "$?" + + local -a _options=() + local _line _match _option _i _char + for _line in "${_lines[@]}"; do + while [[ $_line =~ \[[[:space:]]*(-[^]]+)[[:space:]]*\] ]]; do + _match=${BASH_REMATCH[0]} + _option=${BASH_REMATCH[1]} + case $_option in + -?(\[)+([a-zA-Z0-9?])) + # Treat as bundled short options + for ((_i = 1; _i < ${#_option}; _i++)); do + _char=${_option:_i:1} + [[ $_char != '[' ]] && _options+=("-$_char") + done + ;; + *) + _comp_compgen_help__parse "$_option" + ;; + esac + _line=${_line#*"$_match"} done + done + ((${#_options[@]})) || return 1 - $reset_monitor - $reset_lastpipe - $reset_noglob - return $rc + _comp_compgen -- -W '"${_options[@]}"' + return 0 } # This function completes on signal names (minus the SIG prefix) diff --git a/bash_completion.d/000_bash_completion_compat.bash b/bash_completion.d/000_bash_completion_compat.bash index 45f6d80497e..47e5f9318d6 100644 --- a/bash_completion.d/000_bash_completion_compat.bash +++ b/bash_completion.d/000_bash_completion_compat.bash @@ -276,4 +276,62 @@ _tilde() ! _comp_compgen -c "$1" tilde } +# Helper function for _parse_help and _parse_usage. +# @return True (0) if an option was found, False (> 0) otherwise +# @deprecated Use _comp_compgen_help__parse +__parse_options() +{ + local -a _options=() + _comp_compgen_help__parse "$1" + printf '%s\n' "${_options[@]}" +} + +# Parse GNU style help output of the given command. +# @param $1 command; if "-", read from stdin and ignore rest of args +# @param $2 command options (default: --help) +# @deprecated Use `_comp_compgen_help`. `COMPREPLY=($(compgen -W +# '$(_parse_help "$1" ...)' -- "$cur"))` can be replaced with +# `_comp_compgen_help [-- ...]`. Also, `var=($(_parse_help "$1" ...))` can +# be replaced with `_comp_compgen -Rv var help [-- ...]`. +_parse_help() +{ + local -a args + if [[ $1 == - ]]; then + args=(-) + else + local ret opt IFS=$' \t\n' + _comp_dequote "$1" + _comp_split opt "${2:---help}" + args=(-c "$ret" ${opt[@]+"${opt[@]}"}) + fi + local -a ret=() + _comp_compgen -Rv ret help "${args[@]}" || return 1 + ((${#ret[@]})) && printf '%s\n' "${ret[@]}" + return 0 +} + +# Parse BSD style usage output (options in brackets) of the given command. +# @param $1 command; if "-", read from stdin and ignore rest of args +# @param $2 command options (default: --usage) +# @deprecated Use `_comp_compgen_usage`. `COMPREPLY=($(compgen -W +# '$(_parse_usage "$1" ...)' -- "$cur"))` can be replaced with +# `_comp_compgen_usage [-- ...]`. `var=($(_parse_usage "$1" ...))` can be +# replaced with `_comp_compgen -Rv var usage [-- ...]`. +_parse_usage() +{ + local -a args + if [[ $1 == - ]]; then + args=(-) + else + local ret opt IFS=$' \t\n' + _comp_dequote "$1" + _comp_split opt "${2:---usage}" + args=(-c "$ret" ${opt[@]+"${opt[@]}"}) + fi + local -a ret=() + _comp_compgen -Rv ret usage "${args[@]}" || return 1 + ((${#ret[@]})) && printf '%s\n' "${ret[@]}" + return 0 +} + # ex: filetype=sh diff --git a/completions/2to3 b/completions/2to3 index 7d3a06091f8..c22d12dc88e 100644 --- a/completions/2to3 +++ b/completions/2to3 @@ -27,7 +27,7 @@ _comp_cmd_2to3() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/_adb b/completions/_adb index 6b0d66705b6..2858cad3457 100644 --- a/completions/_adb +++ b/completions/_adb @@ -37,7 +37,7 @@ _comp_cmd_adb() if [[ ! $has_cmd ]]; then local tmp=() if [[ ! $cur || $cur == -* ]]; then - tmp+=($(compgen -W '$(_parse_help "$1" help)' -- "$cur")) + _comp_compgen -av tmp help -- help fi if [[ ! $cur || $cur != -* ]]; then tmp+=($("$1" help 2>&1 | awk '$1 == "adb" { print $2 }')) diff --git a/completions/_cal b/completions/_cal index 15e48f6d4b9..3dbdba3b3f3 100644 --- a/completions/_cal +++ b/completions/_cal @@ -24,9 +24,7 @@ _comp_cmd_cal() esac if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage return fi diff --git a/completions/_chsh b/completions/_chsh index 53945391d6d..082a3b5a65f 100644 --- a/completions/_chsh +++ b/completions/_chsh @@ -32,9 +32,7 @@ _comp_cmd_chsh() esac if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage else _allowed_users fi diff --git a/completions/_dmesg b/completions/_dmesg index 348aac1c127..3b72fad72fa 100644 --- a/completions/_dmesg +++ b/completions/_dmesg @@ -25,9 +25,7 @@ _comp_cmd_dmesg() ;; esac - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage } && complete -F _comp_cmd_dmesg dmesg diff --git a/completions/_eject b/completions/_eject index 7c3413dce2d..1daec085428 100644 --- a/completions/_eject +++ b/completions/_eject @@ -19,7 +19,7 @@ _comp_cmd_eject() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return elif [[ $prev == @(-d|--default) ]]; then return diff --git a/completions/_hexdump b/completions/_hexdump index 473d9ea7b0e..939cfa6656d 100644 --- a/completions/_hexdump +++ b/completions/_hexdump @@ -19,9 +19,7 @@ _comp_cmd_hexdump() esac if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage return fi diff --git a/completions/_ionice b/completions/_ionice index 66c2b3e8d80..77621eaaa16 100644 --- a/completions/_ionice +++ b/completions/_ionice @@ -51,7 +51,7 @@ _comp_cmd_ionice() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h return fi } && diff --git a/completions/_mock b/completions/_mock index 6fe05e6254c..77c6681ed64 100644 --- a/completions/_mock +++ b/completions/_mock @@ -58,7 +58,7 @@ _comp_cmd_mock() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _comp_compgen_filedir '@(?(no)src.r|s)pm' diff --git a/completions/_repomanage b/completions/_repomanage index 465b845ab01..3a7c5ad15f1 100644 --- a/completions/_repomanage +++ b/completions/_repomanage @@ -13,7 +13,7 @@ _comp_cmd_repomanage() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _comp_compgen_filedir -d diff --git a/completions/_reptyr b/completions/_reptyr index 78d22b2e13c..6a42da42f36 100644 --- a/completions/_reptyr +++ b/completions/_reptyr @@ -15,7 +15,7 @@ _comp_cmd_reptyr() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/_rtcwake b/completions/_rtcwake index cd977b9da5e..9945d149224 100644 --- a/completions/_rtcwake +++ b/completions/_rtcwake @@ -26,7 +26,7 @@ _comp_cmd_rtcwake() [[ $was_split ]] && return - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help } && complete -F _comp_cmd_rtcwake rtcwake diff --git a/completions/_su b/completions/_su index 53838ec5f51..60bc959ab1e 100644 --- a/completions/_su +++ b/completions/_su @@ -29,7 +29,7 @@ _comp_cmd_su() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/_udevadm b/completions/_udevadm index da98c3bf32f..057e72c0493 100644 --- a/completions/_udevadm +++ b/completions/_udevadm @@ -67,8 +67,7 @@ _comp_cmd_udevadm() fi if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W \ - '$(_parse_help "$1" "${udevcmd-} --help")' -- "$cur")) + _comp_compgen_help -- ${has_udevcmd:+"$udevcmd"} --help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && diff --git a/completions/_yum b/completions/_yum index 31cbddf5b64..b142bc4864a 100644 --- a/completions/_yum +++ b/completions/_yum @@ -141,7 +141,7 @@ _comp_cmd_yum() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && diff --git a/completions/a2x b/completions/a2x index df3ca0d6700..63c410ee690 100644 --- a/completions/a2x +++ b/completions/a2x @@ -29,7 +29,7 @@ _comp_cmd_a2x() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/aclocal b/completions/aclocal index c8fcb178750..2669efe4aa6 100644 --- a/completions/aclocal +++ b/completions/aclocal @@ -27,7 +27,7 @@ _comp_cmd_aclocal() [[ $was_split ]] && return - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && complete -F _comp_cmd_aclocal aclocal aclocal-1.1{0..6} diff --git a/completions/acpi b/completions/acpi index bb21058bf6b..207a043ff7d 100644 --- a/completions/acpi +++ b/completions/acpi @@ -17,7 +17,7 @@ _comp_cmd_acpi() ;; esac - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help } && complete -F _comp_cmd_acpi acpi diff --git a/completions/alias b/completions/alias index 163c6e58aa1..35b0d8e5370 100644 --- a/completions/alias +++ b/completions/alias @@ -19,7 +19,7 @@ _comp_cmd_alias() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage help "-s $1")' -- "$cur")) + _comp_compgen_usage -c help -s "$1" ((${#COMPREPLY[*]} != 1)) || compopt +o nospace fi } && diff --git a/completions/ant b/completions/ant index 0caabc2b901..85e2e5e0558 100644 --- a/completions/ant +++ b/completions/ant @@ -64,8 +64,7 @@ _comp_cmd_ant() elif [[ $cur == -* ]]; then # The /dev/null)' -- "$cur")) diff --git a/completions/mussh b/completions/mussh index b777d62cc0b..cd329dd66e6 100644 --- a/completions/mussh +++ b/completions/mussh @@ -45,7 +45,7 @@ _comp_cmd_mussh() esac [[ $cur != -* ]] || - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help } && complete -F _comp_cmd_mussh mussh diff --git a/completions/mypy b/completions/mypy index 4e0fa12fa09..6f18a98230a 100644 --- a/completions/mypy +++ b/completions/mypy @@ -49,7 +49,7 @@ _comp_cmd_mypy() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/mysqladmin b/completions/mysqladmin index b4f7ea73ee8..35c34788ade 100644 --- a/completions/mysqladmin +++ b/completions/mysqladmin @@ -51,7 +51,7 @@ _comp_cmd_mysqladmin() [[ $was_split ]] && return - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help COMPREPLY+=($(compgen -W 'create debug drop extended-status flush-hosts flush-logs flush-status flush-tables flush-threads flush-privileges diff --git a/completions/nc b/completions/nc index 90ae9544db6..8a099934f27 100644 --- a/completions/nc +++ b/completions/nc @@ -35,7 +35,7 @@ _comp_cmd_nc() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h return fi diff --git a/completions/ncftp b/completions/ncftp index 635ed999088..89e8c72d92e 100644 --- a/completions/ncftp +++ b/completions/ncftp @@ -12,7 +12,7 @@ _comp_cmd_ncftp() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h return fi diff --git a/completions/nethogs b/completions/nethogs index b74d5a3ba37..20af9584d0f 100644 --- a/completions/nethogs +++ b/completions/nethogs @@ -15,7 +15,7 @@ _comp_cmd_nethogs() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h)' -- "$cur")) + _comp_compgen_usage -- -h return fi diff --git a/completions/newlist b/completions/newlist index c24aa9795c2..fa73855acf5 100644 --- a/completions/newlist +++ b/completions/newlist @@ -14,7 +14,7 @@ _comp_cmd_newlist() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _comp_xfunc list_lists mailman_lists diff --git a/completions/newusers b/completions/newusers index a2169888770..a7b89bef694 100644 --- a/completions/newusers +++ b/completions/newusers @@ -18,7 +18,7 @@ _comp_cmd_newusers() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/ngrep b/completions/ngrep index d9a8ee6aadc..ee65be30784 100644 --- a/completions/ngrep +++ b/completions/ngrep @@ -29,7 +29,7 @@ _comp_cmd_ngrep() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h return fi } && diff --git a/completions/nproc b/completions/nproc index 34fc94e47f8..dc38944e6e1 100644 --- a/completions/nproc +++ b/completions/nproc @@ -14,7 +14,7 @@ _comp_cmd_nproc() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && diff --git a/completions/nslookup b/completions/nslookup index 8b7b59e7488..b2b9af362bd 100644 --- a/completions/nslookup +++ b/completions/nslookup @@ -85,7 +85,7 @@ _comp_cmd_host() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage return fi diff --git a/completions/nsupdate b/completions/nsupdate index 4ef9c4b3f9e..b23cfea8faf 100644 --- a/completions/nsupdate +++ b/completions/nsupdate @@ -28,7 +28,7 @@ _comp_cmd_nsupdate() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage return fi diff --git a/completions/ntpdate b/completions/ntpdate index 0ac1ed389d7..d06f473a85c 100644 --- a/completions/ntpdate +++ b/completions/ntpdate @@ -25,9 +25,7 @@ _comp_cmd_ntpdate() esac if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" -h || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help -- -h || _comp_compgen_usage else _known_hosts_real -- "$cur" fi diff --git a/completions/oggdec b/completions/oggdec index 19ef8c10d64..4b72bed26eb 100644 --- a/completions/oggdec +++ b/completions/oggdec @@ -28,7 +28,7 @@ _comp_cmd_oggdec() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/opera b/completions/opera index 50697b48e80..f7655a62148 100644 --- a/completions/opera +++ b/completions/opera @@ -35,7 +35,7 @@ _comp_cmd_opera() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + _comp_compgen_help -- -help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/optipng b/completions/optipng index dae68e16164..86e66aa2898 100644 --- a/completions/optipng +++ b/completions/optipng @@ -41,7 +41,7 @@ _comp_cmd_optipng() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/passwd b/completions/passwd index ed3eed254d4..ca7040b3907 100644 --- a/completions/passwd +++ b/completions/passwd @@ -15,9 +15,7 @@ _comp_cmd_passwd() esac if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage return fi diff --git a/completions/patch b/completions/patch index 995906238a6..474d982f969 100644 --- a/completions/patch +++ b/completions/patch @@ -51,7 +51,7 @@ _comp_cmd_patch() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/pdftoppm b/completions/pdftoppm index 13e72ad5dca..0934e37a03d 100644 --- a/completions/pdftoppm +++ b/completions/pdftoppm @@ -24,7 +24,7 @@ _comp_cmd_pdftoppm() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/pdftotext b/completions/pdftotext index a79e12c1e3b..8d0cd61db0f 100644 --- a/completions/pdftotext +++ b/completions/pdftotext @@ -22,7 +22,7 @@ _comp_cmd_pdftotext() esac if [[ $cur == -* && ${prev,,} != *.pdf ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/perl b/completions/perl index e0e9ad95fde..5b6167ae520 100644 --- a/completions/perl +++ b/completions/perl @@ -126,7 +126,7 @@ _comp_cmd_perldoc() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h else # return available modules (unless it is clearly a file) if [[ $cur != @(*/|[.~])* ]]; then diff --git a/completions/perlcritic b/completions/perlcritic index 42385c83377..8ff9ebf127b 100644 --- a/completions/perlcritic +++ b/completions/perlcritic @@ -40,7 +40,7 @@ _comp_cmd_perlcritic() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage return fi diff --git a/completions/perltidy b/completions/perltidy index 4c5e7c2f39f..4603db48c39 100644 --- a/completions/perltidy +++ b/completions/perltidy @@ -52,7 +52,7 @@ _comp_cmd_perltidy() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _comp_compgen_filedir 'p[lm]|t' diff --git a/completions/pidof b/completions/pidof index 5fcff64e663..e6cfb73147e 100644 --- a/completions/pidof +++ b/completions/pidof @@ -18,7 +18,7 @@ _comp_cmd_pidof() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/pine b/completions/pine index 7f8edf3cf12..5ceddda0ccb 100644 --- a/completions/pine +++ b/completions/pine @@ -22,7 +22,7 @@ _comp_cmd_pine() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h else COMPREPLY=($(compgen -W '$(awk "{print \$1}" ~/.addressbook \ 2>/dev/null)' -- "$cur")) diff --git a/completions/ping b/completions/ping index 9e01a34f32e..58e608108ea 100644 --- a/completions/ping +++ b/completions/ping @@ -58,9 +58,7 @@ _comp_cmd_ping() esac if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage return fi diff --git a/completions/pkg-config b/completions/pkg-config index b5ea16a3f50..0535ee5975b 100644 --- a/completions/pkg-config +++ b/completions/pkg-config @@ -32,7 +32,7 @@ _comp_cmd_pkg_config() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else COMPREPLY=($(compgen -W "$("$1" --list-all \ diff --git a/completions/pngfix b/completions/pngfix index ff7943c29ff..d638ccef0d5 100644 --- a/completions/pngfix +++ b/completions/pngfix @@ -24,7 +24,7 @@ _comp_cmd_pngfix() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/postcat b/completions/postcat index 34dfea9c91c..aeadb842163 100644 --- a/completions/postcat +++ b/completions/postcat @@ -13,7 +13,7 @@ _comp_cmd_postcat() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage return fi diff --git a/completions/postconf b/completions/postconf index dcdf56ba966..ac1b21b39b1 100644 --- a/completions/postconf +++ b/completions/postconf @@ -23,7 +23,7 @@ _comp_cmd_postconf() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage return fi diff --git a/completions/postfix b/completions/postfix index cb7b606fff3..3391a654274 100644 --- a/completions/postfix +++ b/completions/postfix @@ -17,8 +17,7 @@ _comp_cmd_postfix() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W \ - '$(_parse_usage _bashcomp_try_faketty "$1 --help")' -- "$cur")) + _comp_compgen_usage -c _bashcomp_try_faketty "$1" --help return fi diff --git a/completions/postmap b/completions/postmap index aa6b8d7c8f0..aa0a661fb00 100644 --- a/completions/postmap +++ b/completions/postmap @@ -16,7 +16,7 @@ _comp_cmd_postmap() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage return fi diff --git a/completions/postsuper b/completions/postsuper index 6420c23048a..1f4055021cb 100644 --- a/completions/postsuper +++ b/completions/postsuper @@ -46,7 +46,7 @@ _comp_cmd_postsuper() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/prelink b/completions/prelink index c140e9e2e1e..51b1cd9c2c8 100644 --- a/completions/prelink +++ b/completions/prelink @@ -30,7 +30,7 @@ _comp_cmd_prelink() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/printenv b/completions/printenv index 526f1a0cab0..41bd3faa8d9 100644 --- a/completions/printenv +++ b/completions/printenv @@ -12,7 +12,7 @@ _comp_cmd_printenv() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/protoc b/completions/protoc index d275c73bfb8..a4581c1f1d5 100644 --- a/completions/protoc +++ b/completions/protoc @@ -44,7 +44,7 @@ _comp_cmd_protoc() return ;; -*) - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help local i for i in "${!COMPREPLY[@]}"; do [[ ${COMPREPLY[i]} == -oFILE ]] && unset -v 'COMPREPLY[i]' diff --git a/completions/psql b/completions/psql index 01d59b9c36c..0f689f7a7cd 100644 --- a/completions/psql +++ b/completions/psql @@ -43,7 +43,7 @@ _comp_cmd_createdb() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _comp_cmd_psql__databases @@ -77,7 +77,7 @@ _comp_cmd_createuser() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && @@ -109,7 +109,7 @@ _comp_cmd_dropdb() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _comp_cmd_psql__databases @@ -143,7 +143,7 @@ _comp_cmd_dropuser() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _comp_cmd_psql__users @@ -188,7 +188,7 @@ _comp_cmd_psql() if [[ $cur == -* ]]; then # return list of available options - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else # return list of available databases diff --git a/completions/puppet b/completions/puppet index 0e5bb0d17db..6d4dd49fde5 100644 --- a/completions/puppet +++ b/completions/puppet @@ -56,8 +56,7 @@ _comp_cmd_puppet__subcmd_opts() { # puppet cmd help is somewhat slow, avoid if possible [[ ! $cur || $cur == -* ]] && - COMPREPLY+=($(compgen -W \ - '$(_parse_usage "$1" "help $2")' -- "$cur")) + _comp_compgen -a usage -- help ${2:+"$2"} } _comp_cmd_puppet() @@ -65,7 +64,7 @@ _comp_cmd_puppet() local cur prev words cword comp_args _comp_initialize -- "$@" || return - local subcommand action + local subcommand="" action case $prev in -h | --help | -V | --version) @@ -338,7 +337,7 @@ _comp_cmd_puppet() esac ;; resource | *) - _comp_cmd_puppet__subcmd_opts "$1" "$subcommand" + _comp_cmd_puppet__subcmd_opts "$1" ${subcommand:+"$subcommand"} return ;; esac diff --git a/completions/pv b/completions/pv index e8e45aab928..ef79fd24350 100644 --- a/completions/pv +++ b/completions/pv @@ -24,7 +24,7 @@ _comp_cmd_pv() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help else _comp_compgen_filedir fi diff --git a/completions/pwck b/completions/pwck index ef636144a62..3e74ea5e3b9 100644 --- a/completions/pwck +++ b/completions/pwck @@ -6,9 +6,7 @@ _comp_cmd_pwck() _comp_initialize -- "$@" || return if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage return fi diff --git a/completions/pwd b/completions/pwd index f3bba5e122a..159dacc92e2 100644 --- a/completions/pwd +++ b/completions/pwd @@ -11,7 +11,7 @@ _comp_cmd_pwd() ;; esac - COMPREPLY=($(compgen -W '$(_parse_usage help "-s $1")' -- "$cur")) + _comp_compgen_usage -c help -s "$1" } && complete -F _comp_cmd_pwd pwd diff --git a/completions/pwgen b/completions/pwgen index b2730466b64..515ef1cf348 100644 --- a/completions/pwgen +++ b/completions/pwgen @@ -20,7 +20,7 @@ _comp_cmd_pwgen() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/pycodestyle b/completions/pycodestyle index 3034611c475..a3455d2ae6b 100644 --- a/completions/pycodestyle +++ b/completions/pycodestyle @@ -22,7 +22,7 @@ _comp_cmd_pycodestyle() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/pydocstyle b/completions/pydocstyle index 58791edceaf..52ceaf92441 100644 --- a/completions/pydocstyle +++ b/completions/pydocstyle @@ -23,7 +23,7 @@ _comp_cmd_pydocstyle() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/pyflakes b/completions/pyflakes index 18139bce545..a53904ea402 100644 --- a/completions/pyflakes +++ b/completions/pyflakes @@ -12,7 +12,7 @@ _comp_cmd_pyflakes() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/pylint b/completions/pylint index 5698b8f12ad..2ec431603e5 100644 --- a/completions/pylint +++ b/completions/pylint @@ -103,8 +103,7 @@ _comp_cmd_pylint() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W \ - '$(_parse_help "$1" --long-help)' -- "$cur")) + _comp_compgen_help -- --long-help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/pytest b/completions/pytest index 62e41ea09ff..2aa405e47ba 100644 --- a/completions/pytest +++ b/completions/pytest @@ -96,7 +96,7 @@ _comp_cmd_pytest() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/querybts b/completions/querybts index 95358d4647e..62116d4194a 100644 --- a/completions/querybts +++ b/completions/querybts @@ -27,7 +27,7 @@ _comp_cmd_querybts() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else COMPREPLY=($(compgen -W 'wnpp boot-floppies kernel bugs.debian.org diff --git a/completions/quota b/completions/quota index 99303b826f2..6af43256087 100644 --- a/completions/quota +++ b/completions/quota @@ -18,9 +18,7 @@ _comp_cmd_quota__user_or_group() _comp_cmd_quota__parse_help() { - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } diff --git a/completions/radvdump b/completions/radvdump index 99c83b451d7..e2fd1751f68 100644 --- a/completions/radvdump +++ b/completions/radvdump @@ -15,7 +15,7 @@ _comp_cmd_radvdump() ;; esac - COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) + _comp_compgen_usage -- --help } && complete -F _comp_cmd_radvdump radvdump diff --git a/completions/reportbug b/completions/reportbug index b06c1e54abb..9917fb50dcb 100644 --- a/completions/reportbug +++ b/completions/reportbug @@ -60,7 +60,7 @@ _comp_cmd_reportbug() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == -*= ]] && compopt -o nospace return fi diff --git a/completions/ri b/completions/ri index 6142f00dbb5..3062d0585c9 100644 --- a/completions/ri +++ b/completions/ri @@ -61,7 +61,7 @@ _comp_cmd_ri() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/rmmod b/completions/rmmod index 7a41e061f68..461fb067811 100644 --- a/completions/rmmod +++ b/completions/rmmod @@ -13,7 +13,7 @@ _comp_cmd_rmmod() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/rpm b/completions/rpm index 851558b1ece..73697068480 100644 --- a/completions/rpm +++ b/completions/rpm @@ -281,7 +281,7 @@ _comp_cmd_rpmbuild() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/sbopkg b/completions/sbopkg index 7699002103a..36a8da9dd01 100644 --- a/completions/sbopkg +++ b/completions/sbopkg @@ -6,7 +6,7 @@ _comp_cmd_sbopkg() _comp_initialize -- "$@" || return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h [[ ${COMPREPLY-} ]] && return fi diff --git a/completions/screen b/completions/screen index 63e174f4732..aac7df25838 100644 --- a/completions/screen +++ b/completions/screen @@ -113,7 +113,7 @@ _comp_cmd_screen__sessions() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help fi } && complete -F _comp_cmd_screen screen diff --git a/completions/scrub b/completions/scrub index 58190e99c7e..1622bad89cf 100644 --- a/completions/scrub +++ b/completions/scrub @@ -27,7 +27,7 @@ _comp_cmd_scrub() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/shellcheck b/completions/shellcheck index 0c7d0250cf2..b3d3c87e6de 100644 --- a/completions/shellcheck +++ b/completions/shellcheck @@ -53,7 +53,7 @@ _comp_cmd_shellcheck() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/sitecopy b/completions/sitecopy index 328965a2aec..75099edf2c5 100644 --- a/completions/sitecopy +++ b/completions/sitecopy @@ -29,7 +29,7 @@ _comp_cmd_sitecopy() case $cur in --*) - COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return ;; diff --git a/completions/slapt-get b/completions/slapt-get index 5f9b23d1ccc..5a1c2f03235 100644 --- a/completions/slapt-get +++ b/completions/slapt-get @@ -17,7 +17,7 @@ _comp_cmd_slapt_get() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + _comp_compgen_help if [[ ${COMPREPLY-} ]]; then [[ $COMPREPLY == *= ]] && compopt -o nospace return diff --git a/completions/slapt-src b/completions/slapt-src index 972b42cea1e..5a1bb6e94e5 100644 --- a/completions/slapt-src +++ b/completions/slapt-src @@ -19,7 +19,7 @@ _comp_cmd_slapt_src() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + _comp_compgen_help if [[ ${COMPREPLY-} ]]; then [[ $COMPREPLY == *= ]] && compopt -o nospace return diff --git a/completions/smartctl b/completions/smartctl index db5b756b73b..7b5a97a358e 100644 --- a/completions/smartctl +++ b/completions/smartctl @@ -121,7 +121,7 @@ _comp_cmd_smartctl() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _comp_compgen -c "${cur:-/dev/}" filedir diff --git a/completions/smbclient b/completions/smbclient index 8938964f3e8..848db4cf810 100644 --- a/completions/smbclient +++ b/completions/smbclient @@ -101,7 +101,7 @@ _comp_cmd_smbclient() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && @@ -135,7 +135,7 @@ _comp_cmd_smbget() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && @@ -182,7 +182,7 @@ _comp_cmd_smbcacls() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && @@ -220,7 +220,7 @@ _comp_cmd_smbcquotas() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && @@ -254,7 +254,7 @@ _comp_cmd_smbpasswd() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h fi } && complete -F _comp_cmd_smbpasswd smbpasswd @@ -287,7 +287,7 @@ _comp_cmd_smbtar() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help fi } && complete -F _comp_cmd_smbtar smbtar @@ -324,7 +324,7 @@ _comp_cmd_smbtree() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && diff --git a/completions/snownews b/completions/snownews index a2cffc29438..a767a6c8b01 100644 --- a/completions/snownews +++ b/completions/snownews @@ -7,7 +7,7 @@ _comp_cmd_snownews() if [[ $cur == -* ]]; then # return list of available options - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help fi } && complete -F _comp_cmd_snownews snownews diff --git a/completions/sqlite3 b/completions/sqlite3 index f6e69d9609f..0bf0e5ed4ef 100644 --- a/completions/sqlite3 +++ b/completions/sqlite3 @@ -27,7 +27,7 @@ _comp_cmd_sqlite3() return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + _comp_compgen_help -- -help return fi diff --git a/completions/ss b/completions/ss index 5aefde45792..4a8ac4770c0 100644 --- a/completions/ss +++ b/completions/ss @@ -30,7 +30,7 @@ _comp_cmd_ss() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace elif [[ $prev == state ]]; then COMPREPLY=($(compgen -W 'all connected synchronized bucket big diff --git a/completions/ssh b/completions/ssh index 78e632de21e..cefab8988df 100644 --- a/completions/ssh +++ b/completions/ssh @@ -345,7 +345,7 @@ _comp_cmd_ssh() # Prefix completions with '-F' COMPREPLY=("${COMPREPLY[@]/#/-F}") elif [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage else local args # Keep glob sort in sync with cases above @@ -418,7 +418,7 @@ _comp_cmd_sftp() # Prefix completions with '-F' COMPREPLY=("${COMPREPLY[@]/#/-F}") elif [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage else _known_hosts_real ${ipvx:+"$ipvx"} -a ${configfile:+-F "$configfile"} -- "$cur" fi @@ -575,8 +575,7 @@ _comp_cmd_scp() else case $cur in -*) - COMPREPLY=($(compgen -W '$(_parse_usage "${words[0]}")' \ - -- "$cur")) + _comp_compgen_usage COMPREPLY=("${COMPREPLY[@]/%/ }") return ;; diff --git a/completions/ssh-add b/completions/ssh-add index b027b6692a8..79989720133 100644 --- a/completions/ssh-add +++ b/completions/ssh-add @@ -24,7 +24,7 @@ _comp_cmd_ssh_add() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" "-\?")' -- "$cur")) + _comp_compgen_help -- '-?' return fi diff --git a/completions/ssh-copy-id b/completions/ssh-copy-id index 3b440801b40..6ecc922012a 100644 --- a/completions/ssh-copy-id +++ b/completions/ssh-copy-id @@ -22,7 +22,7 @@ _comp_cmd_ssh_copy_id() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) + _comp_compgen_usage -- --help else _known_hosts_real -a -- "$cur" fi diff --git a/completions/ssh-keyscan b/completions/ssh-keyscan index efb34f70177..f88c13a7dbf 100644 --- a/completions/ssh-keyscan +++ b/completions/ssh-keyscan @@ -28,7 +28,7 @@ _comp_cmd_ssh_keyscan() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage return fi diff --git a/completions/sshmitm b/completions/sshmitm index 2d6758c0e0a..4b14301f574 100644 --- a/completions/sshmitm +++ b/completions/sshmitm @@ -6,7 +6,7 @@ _comp_cmd_sshmitm() _comp_initialize -- "$@" || return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage else _known_hosts_real -- "$cur" fi diff --git a/completions/sshow b/completions/sshow index b3deddfe4a1..202162f1a7d 100644 --- a/completions/sshow +++ b/completions/sshow @@ -17,7 +17,7 @@ _comp_cmd_sshow() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage fi } && diff --git a/completions/strace b/completions/strace index 3323e394d2d..239ccf825c2 100644 --- a/completions/strace +++ b/completions/strace @@ -88,7 +88,7 @@ _comp_cmd_strace() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h else COMPREPLY=($(compgen -c -- "$cur")) fi diff --git a/completions/sudo b/completions/sudo index 542770a8834..fc21bdb2c50 100644 --- a/completions/sudo +++ b/completions/sudo @@ -45,9 +45,7 @@ _comp_cmd_sudo() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/synclient b/completions/synclient index 1c68b4f8484..1452d345ca6 100644 --- a/completions/synclient +++ b/completions/synclient @@ -12,7 +12,7 @@ _comp_cmd_synclient() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage elif [[ $cur != *=?* ]]; then COMPREPLY=($(compgen -S = -W '$("$1" -l 2>/dev/null | \ awk "/^[ \t]/ { print \$1 }")' -- "$cur")) diff --git a/completions/sysctl b/completions/sysctl index 22788a14f41..e0024e26b86 100644 --- a/completions/sysctl +++ b/completions/sysctl @@ -18,9 +18,7 @@ _comp_cmd_sysctl() esac if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage else local suffix= [[ $prev == -w ]] && suffix="=" diff --git a/completions/tcpdump b/completions/tcpdump index 04c2f7ab2c6..1122ec2705b 100644 --- a/completions/tcpdump +++ b/completions/tcpdump @@ -56,7 +56,7 @@ _comp_cmd_tcpdump() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi diff --git a/completions/tcpnice b/completions/tcpnice index a882036d8eb..d35c753cc45 100644 --- a/completions/tcpnice +++ b/completions/tcpnice @@ -13,7 +13,7 @@ _comp_cmd_tcpnice() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage fi } && diff --git a/completions/timeout b/completions/timeout index 1f6348b445f..e62058d4f3c 100644 --- a/completions/timeout +++ b/completions/timeout @@ -32,9 +32,7 @@ _comp_cmd_timeout() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && diff --git a/completions/tracepath b/completions/tracepath index 4ee85a1c29d..f6a57db289d 100644 --- a/completions/tracepath +++ b/completions/tracepath @@ -12,9 +12,7 @@ _comp_cmd_tracepath() esac if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage return fi diff --git a/completions/tree b/completions/tree index 4b7a6ddc914..de195d36652 100644 --- a/completions/tree +++ b/completions/tree @@ -28,7 +28,7 @@ _comp_cmd_tree() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/truncate b/completions/truncate index 57544a234bb..94534a285bc 100644 --- a/completions/truncate +++ b/completions/truncate @@ -20,7 +20,7 @@ _comp_cmd_truncate() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/tshark b/completions/tshark index 3191bb214fc..69aeeb22a5f 100644 --- a/completions/tshark +++ b/completions/tshark @@ -124,8 +124,7 @@ _comp_cmd_tshark() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h 2>/dev/null)' \ - -- "$cur")) + _comp_compgen_help -- -h return fi } && diff --git a/completions/tsig-keygen b/completions/tsig-keygen index fb9887e249f..3a64ff2ea64 100644 --- a/completions/tsig-keygen +++ b/completions/tsig-keygen @@ -23,7 +23,7 @@ _comp_cmd_tsig_keygen() esac [[ $cur != -* ]] || - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help } && complete -F _comp_cmd_tsig_keygen tsig-keygen diff --git a/completions/tune2fs b/completions/tune2fs index 902d5b3b228..4daf3dd611f 100644 --- a/completions/tune2fs +++ b/completions/tune2fs @@ -51,7 +51,7 @@ _comp_cmd_tune2fs() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage return fi diff --git a/completions/ulimit b/completions/ulimit index 107c9554eb5..3d4331fbf97 100644 --- a/completions/ulimit +++ b/completions/ulimit @@ -27,7 +27,7 @@ _comp_cmd_ulimit() done if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage help "-s $1")' -- "$cur")) + _comp_compgen_usage -c help -s "$1" return fi fi diff --git a/completions/unshunt b/completions/unshunt index 3a7078f2c34..0486d1fca47 100644 --- a/completions/unshunt +++ b/completions/unshunt @@ -6,7 +6,7 @@ _comp_cmd_unshunt() _comp_initialize -- "$@" || return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help else _comp_compgen_filedir -d fi diff --git a/completions/update-alternatives b/completions/update-alternatives index 06352b8aeaa..963602bdc7a 100644 --- a/completions/update-alternatives +++ b/completions/update-alternatives @@ -83,7 +83,7 @@ _comp_cmd_update_alternatives() _comp_cmd_update_alternatives__installed ;; *) - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help ;; esac } && diff --git a/completions/urlsnarf b/completions/urlsnarf index 7cc0bbc6a55..90be5d92248 100644 --- a/completions/urlsnarf +++ b/completions/urlsnarf @@ -17,7 +17,7 @@ _comp_cmd_urlsnarf() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage fi } && diff --git a/completions/uscan b/completions/uscan index 90a3203d0ff..227ac3f3462 100644 --- a/completions/uscan +++ b/completions/uscan @@ -27,7 +27,7 @@ _comp_cmd_uscan() [[ $was_split ]] && return - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help } && complete -F _comp_cmd_uscan uscan diff --git a/completions/useradd b/completions/useradd index a88019c2591..edcde420a3f 100644 --- a/completions/useradd +++ b/completions/useradd @@ -52,7 +52,7 @@ _comp_cmd_useradd() [[ $was_split ]] && return [[ $cur == -* ]] && - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help } && complete -F _comp_cmd_useradd useradd diff --git a/completions/userdel b/completions/userdel index cc08bce8b81..e0e7904a1cc 100644 --- a/completions/userdel +++ b/completions/userdel @@ -18,7 +18,7 @@ _comp_cmd_userdel() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/usermod b/completions/usermod index e1a4238b70d..b903850ee5a 100644 --- a/completions/usermod +++ b/completions/usermod @@ -53,7 +53,7 @@ _comp_cmd_usermod() if [[ $cur == -* ]]; then # TODO: -U/--unlock, -p/--password, -L/--lock mutually exclusive - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/valgrind b/completions/valgrind index 5c5c224ffcd..eb4bf5c6b16 100644 --- a/completions/valgrind +++ b/completions/valgrind @@ -13,7 +13,7 @@ _comp_cmd_valgrind() fi done - local word tool + local word tool="" for word in "${words[@]:1}"; do if [[ $word == --tool=?* ]]; then tool=$word @@ -70,7 +70,7 @@ _comp_cmd_valgrind() # generic cases parsed from --help output --+([-A-Za-z0-9_])) # shellcheck disable=SC2086 - 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 @@ -101,8 +101,7 @@ _comp_cmd_valgrind() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" "--help ${tool-}")' \ - -- "$cur")) + _comp_compgen_help -- --help ${tool:+"$tool"} [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/vipw b/completions/vipw index 91361ca2100..bfaa48af7b9 100644 --- a/completions/vipw +++ b/completions/vipw @@ -17,9 +17,7 @@ _comp_cmd_vipw() ;; esac - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage } && complete -F _comp_cmd_vipw vipw vigr diff --git a/completions/vmstat b/completions/vmstat index 77e424017f2..e6af4e111b6 100644 --- a/completions/vmstat +++ b/completions/vmstat @@ -19,9 +19,9 @@ _comp_cmd_vmstat() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} ]] || - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage fi } && complete -F _comp_cmd_vmstat vmstat diff --git a/completions/vpnc b/completions/vpnc index d615bbc7d6b..98e501c8a47 100644 --- a/completions/vpnc +++ b/completions/vpnc @@ -61,7 +61,7 @@ _vpnc() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" --long-help)' -- "$cur")) + _comp_compgen_help -- --long-help elif _comp_looks_like_path "$cur"; then # explicit filename _comp_compgen_filedir conf diff --git a/completions/watch b/completions/watch index f46fa093bb3..38b019603e8 100644 --- a/completions/watch +++ b/completions/watch @@ -47,7 +47,7 @@ _comp_cmd_watch() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/webmitm b/completions/webmitm index 805d2454df9..c56208eeb69 100644 --- a/completions/webmitm +++ b/completions/webmitm @@ -6,7 +6,7 @@ _comp_cmd_webmitm() _comp_initialize -- "$@" || return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage else _known_hosts_real -- "$cur" fi diff --git a/completions/wget b/completions/wget index a6688ee13f6..5f162273a23 100644 --- a/completions/wget +++ b/completions/wget @@ -169,7 +169,7 @@ _comp_cmd_wget() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi diff --git a/completions/wol b/completions/wol index 0b93bf8deb3..049912666f8 100644 --- a/completions/wol +++ b/completions/wol @@ -33,7 +33,7 @@ _comp_cmd_wol() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi diff --git a/completions/wsimport b/completions/wsimport index 22050d84d6b..edf6fed5aae 100644 --- a/completions/wsimport +++ b/completions/wsimport @@ -35,7 +35,7 @@ _comp_cmd_wsimport() _known_hosts_real -- "${cur#-httpproxy:}" return elif [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + _comp_compgen_help -- -help [[ ${COMPREPLY-} == *: ]] && compopt -o nospace _comp_ltrim_colon_completions "$cur" return diff --git a/completions/wvdial b/completions/wvdial index 64434e21818..7a29f764fe7 100644 --- a/completions/wvdial +++ b/completions/wvdial @@ -18,7 +18,7 @@ _comp_cmd_wvdial() case $cur in -*) - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace ;; *) diff --git a/completions/xev b/completions/xev index 9e6848f48fd..a5fbf8a2723 100644 --- a/completions/xev +++ b/completions/xev @@ -25,7 +25,7 @@ _comp_cmd_xev() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi } && diff --git a/completions/xgamma b/completions/xgamma index a506043bdb1..73bc697fa96 100644 --- a/completions/xgamma +++ b/completions/xgamma @@ -49,7 +49,7 @@ _comp_cmd_xgamma() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + _comp_compgen_help -- -help if [[ ${COMPREPLY-} ]]; then [[ $COMPREPLY == *= ]] && compopt -o nospace return diff --git a/completions/xmllint b/completions/xmllint index c3e079473ec..c929dba3d8f 100644 --- a/completions/xmllint +++ b/completions/xmllint @@ -41,7 +41,7 @@ _comp_cmd_xmllint() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help COMPREPLY=("${COMPREPLY[@]%:}") return fi diff --git a/completions/xmlwf b/completions/xmlwf index d36c813e41c..ae9a539625c 100644 --- a/completions/xmlwf +++ b/completions/xmlwf @@ -21,9 +21,7 @@ _comp_cmd_xmlwf() esac if [[ $cur == -* ]]; then - COMPREPLY=($( - compgen -W '$(_parse_help "$1" || _parse_usage "$1")' -- "$cur" - )) + _comp_compgen_help || _comp_compgen_usage return fi diff --git a/completions/xmms b/completions/xmms index 35ef954a575..533010535c3 100644 --- a/completions/xmms +++ b/completions/xmms @@ -20,7 +20,7 @@ _comp_cmd_xmms() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help else _comp_compgen_filedir '@(mp[23]|ogg|wav|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)' fi diff --git a/completions/xmodmap b/completions/xmodmap index 68492753cce..f8d295744cf 100644 --- a/completions/xmodmap +++ b/completions/xmodmap @@ -12,7 +12,7 @@ _comp_cmd_xmodmap() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + _comp_compgen_help -- -help return fi diff --git a/completions/xrdb b/completions/xrdb index 4577cf6d7e6..0bd2598c445 100644 --- a/completions/xrdb +++ b/completions/xrdb @@ -16,7 +16,7 @@ _comp_cmd_xrdb() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help return fi diff --git a/completions/xsltproc b/completions/xsltproc index 21622d25bd2..3f06c8e26c5 100644 --- a/completions/xsltproc +++ b/completions/xsltproc @@ -37,7 +37,7 @@ _comp_cmd_xsltproc() [[ $cword -gt 2 && ${words[cword - 2]} == --?(string)param ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help COMPREPLY=("${COMPREPLY[@]%:}") else # TODO: 1st file xsl|xslt, 2nd XML diff --git a/completions/xvfb-run b/completions/xvfb-run index d4f85768f42..9ae1fc85ce1 100644 --- a/completions/xvfb-run +++ b/completions/xvfb-run @@ -30,7 +30,7 @@ _comp_cmd_xvfb_run() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && diff --git a/completions/xxd b/completions/xxd index e824dd0b564..b9facde1817 100644 --- a/completions/xxd +++ b/completions/xxd @@ -13,7 +13,7 @@ _comp_cmd_xxd() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h return fi diff --git a/completions/xzdec b/completions/xzdec index a4fad321115..21ee6ec9eaf 100644 --- a/completions/xzdec +++ b/completions/xzdec @@ -19,7 +19,7 @@ _comp_cmd_xzdec() [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi