From 774454d0e0b9e59c4f0b4a1dbf90e88715fa8668 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Mon, 22 May 2023 22:03:27 +0900 Subject: [PATCH] docs(api-and-naming): use REPLY for return variable instead of ret https://github.com/scop/bash-completion/discussions/537#discussioncomment-5961630 --- bash_completion | 146 +++++++++--------- .../000_bash_completion_compat.bash | 58 +++---- completions/2to3 | 4 +- completions/7z | 4 +- completions/Makefile.am | 6 +- completions/_cal | 4 +- completions/_umount.linux | 8 +- completions/_xm | 20 +-- completions/ant | 6 +- completions/arp | 4 +- completions/avctrl | 4 +- completions/bzip2 | 4 +- completions/chmod | 4 +- completions/chown | 4 +- completions/cppcheck | 4 +- completions/cryptsetup | 6 +- completions/export | 4 +- completions/fio | 22 +-- completions/flake8 | 4 +- completions/gcc | 4 +- completions/gpgv | 4 +- completions/gzip | 4 +- completions/hcitool | 50 +++--- completions/ifup | 4 +- completions/isort | 4 +- completions/java | 26 ++-- completions/jq | 4 +- completions/jsonschema | 4 +- completions/lrzip | 4 +- completions/lvm | 32 ++-- completions/lz4 | 4 +- completions/lzip | 4 +- completions/make | 16 +- completions/mkinitrd | 4 +- completions/mutt | 36 ++--- completions/nc | 4 +- completions/nslookup | 12 +- completions/patch | 4 +- completions/pkg-get | 12 +- completions/pkgadd | 4 +- completions/pkgutil | 12 +- completions/pylint | 4 +- completions/pytest | 4 +- completions/quota | 4 +- completions/sbopkg | 4 +- completions/sh | 4 +- completions/slapt-get | 4 +- completions/slapt-src | 4 +- completions/ssh | 10 +- completions/vncviewer | 4 +- completions/xdg-mime | 4 +- completions/xdg-settings | 6 +- completions/xz | 4 +- completions/zopflipng | 4 +- doc/api-and-naming.md | 2 +- test/t/test_mutt.py | 2 +- test/t/unit/test_unit_abspath.py | 6 +- test/t/unit/test_unit_command_offset.py | 6 +- test/t/unit/test_unit_count_args.py | 4 +- test/t/unit/test_unit_dequote.py | 2 +- test/t/unit/test_unit_expand_tilde.py | 4 +- test/t/unit/test_unit_get_first_arg.py | 2 +- test/t/unit/test_unit_quote.py | 2 +- test/t/unit/test_unit_quote_compgen.py | 6 +- test/t/unit/test_unit_realcommand.py | 6 +- 65 files changed, 335 insertions(+), 335 deletions(-) diff --git a/bash_completion b/bash_completion index 7089f241af2..147e02e9e1b 100644 --- a/bash_completion +++ b/bash_completion @@ -139,11 +139,11 @@ _comp_readline_variable_on() # This function shell-quotes the argument # @param $1 String to be quoted -# @var[out] ret Resulting string +# @var[out] REPLY Resulting string # @since 2.12 _comp_quote() { - ret=\'${1//\'/\'\\\'\'}\' + REPLY=\'${1//\'/\'\\\'\'}\' } # shellcheck disable=SC1003 @@ -175,8 +175,8 @@ _comp_dequote__initialize # - Quotes \?, '...', "...", $'...', and $"...". In the double # quotations, parameter expansions are allowed. # -# @var[out] ret Array that contains the expanded results. Multiple words or no -# words may be generated through pathname expansions. +# @var[out] REPLY Array that contains the expanded results. Multiple words or +# no words may be generated through pathname expansions. # # Note: This function allows parameter expansions as safe strings, which might # cause unexpected results: @@ -203,9 +203,9 @@ _comp_dequote__initialize # @since 2.12 _comp_dequote() { - ret=() # fallback value for unsafe word and failglob + REPLY=() # fallback value for unsafe word and failglob [[ $1 =~ $_comp_dequote__regex_safe_word ]] || return 1 - eval "ret=($1)" 2>/dev/null # may produce failglob + eval "REPLY=($1)" 2>/dev/null # may produce failglob } # Unset the given variables across a scope boundary. Useful for unshadowing @@ -1032,25 +1032,25 @@ _comp_ltrim_colon_completions() # - https://lists.gnu.org/archive/html/bug-bash/2009-03/msg00155.html # - https://www.mail-archive.com/bash-completion-devel@lists.alioth.debian.org/msg01944.html # @param $1 Argument to quote -# @var[out] ret Quoted result is stored in this variable +# @var[out] REPLY Quoted result is stored in this variable # @since 2.12 -# shellcheck disable=SC2178 # The assignment is not intended for the global "ret" +# shellcheck disable=SC2178 # The assignment is not intended for the global "REPLY" _comp_quote_compgen() { if [[ $1 == \'* ]]; then # Leave out first character - ret=${1:1} + REPLY=${1:1} else - printf -v ret %q "$1" + printf -v REPLY %q "$1" # If result becomes quoted like this: $'string', re-evaluate in order # to drop the additional quoting. See also: # https://www.mail-archive.com/bash-completion-devel@lists.alioth.debian.org/msg01942.html - if [[ $ret == \$\'*\' ]]; then - local value=${ret:2:-1} # Strip beginning $' and ending '. - value=${value//'%'/%%} # Escape % for printf format. + if [[ $REPLY == \$\'*\' ]]; then + local value=${REPLY:2:-1} # Strip beginning $' and ending '. + value=${value//'%'/%%} # Escape % for printf format. # shellcheck disable=SC2059 - printf -v ret "$value" # Decode escape sequences of \.... + printf -v REPLY "$value" # Decode escape sequences of \.... fi fi } @@ -1073,10 +1073,10 @@ _comp_compgen_filedir() if [[ $_arg == -d ]]; then _comp_compgen -v toks -- -d else - local ret + local REPLY _comp_quote_compgen "${cur-}" - local _quoted=$ret - _comp_unlocal ret + local _quoted=$REPLY + _comp_unlocal REPLY # work around bash-4.2 where compgen -f "''" produces nothing. [[ $_quoted == "''" ]] && _quoted="" @@ -1441,15 +1441,15 @@ _comp_compgen_help__get_help_lines() ;; --) shift 1 ;& *) - local ret - _comp_dequote "${comp_args[0]-}" || ret=${comp_args[0]-} - help_cmd=("${ret:-false}" "$@") + local REPLY + _comp_dequote "${comp_args[0]-}" || REPLY=${comp_args[0]-} + help_cmd=("${REPLY:-false}" "$@") ;; esac - local ret - _comp_split -l ret "$(LC_ALL=C "${help_cmd[@]}" 2>&1)" && - _lines=("${ret[@]}") + local REPLY + _comp_split -l REPLY "$(LC_ALL=C "${help_cmd[@]}" 2>&1)" && + _lines=("${REPLY[@]}") } # Helper function for _comp_compgen_help and _comp_compgen_usage. @@ -1709,17 +1709,17 @@ _comp_compgen_available_interfaces() } # Echo number of CPUs, falling back to 1 on failure. -# @var[out] ret +# @var[out] REPLY # @return 0 if it successfully obtained the number of CPUs, or otherwise 1 # @since 2.12 _comp_get_ncpus() { local var=NPROCESSORS_ONLN [[ $OSTYPE == *@(linux|msys|cygwin)* ]] && var=_$var - if ret=$(getconf $var 2>/dev/null) && ((ret >= 1)); then + if REPLY=$(getconf $var 2>/dev/null) && ((REPLY >= 1)); then return 0 else - ret=1 + REPLY=1 return 1 fi } @@ -1752,11 +1752,11 @@ _comp_compgen_tilde() # a dollar sign variable ($) or asterisk (*) is not expanded. # Example usage: # -# $ _comp_expand_tilde "~"; echo "$ret" +# $ _comp_expand_tilde "~"; echo "$REPLY" # # Example output: # -# $1 ret +# $1 REPLY # -------- ---------------- # ~ /home/user # ~foo/bar /home/foo/bar @@ -1765,14 +1765,14 @@ _comp_compgen_tilde() # ~foo/* /home/foo/* # # @param $1 Value to expand -# @var[out] ret Expanded result +# @var[out] REPLY Expanded result # @since 2.12 _comp_expand_tilde() { - ret=$1 + REPLY=$1 if [[ $1 == \~* ]]; then - printf -v ret '~%q' "${1#\~}" - eval "ret=$ret" + printf -v REPLY '~%q' "${1#\~}" + eval "REPLY=$REPLY" fi } @@ -1787,9 +1787,9 @@ _comp_expand() case ${cur-} in ~*/*) - local ret + local REPLY _comp_expand_tilde "$cur" - cur=$ret + cur=$REPLY ;; ~*) _comp_compgen -v COMPREPLY tilde && @@ -2143,40 +2143,40 @@ _comp_compgen_fstypes() # No symlink resolution or existence checks are done; # see `_comp_realcommand` for those. # @param $1 The file -# @var[out] ret The path +# @var[out] REPLY The path # @since 2.12 _comp_abspath() { - ret=$1 - case $ret in + REPLY=$1 + case $REPLY in /*) ;; - ../*) ret=$PWD/${ret:3} ;; - *) ret=$PWD/$ret ;; + ../*) REPLY=$PWD/${REPLY:3} ;; + *) REPLY=$PWD/$REPLY ;; esac - while [[ $ret == */./* ]]; do - ret=${ret//\/.\//\/} + while [[ $REPLY == */./* ]]; do + REPLY=${REPLY//\/.\//\/} done - ret=${ret//+(\/)/\/} + REPLY=${REPLY//+(\/)/\/} } # Get real command. # Command is the filename of command in PATH with possible symlinks resolved # (if resolve tooling available), empty string if command not found. # @param $1 Command -# @var[out] ret Resulting string +# @var[out] REPLY Resulting string # @return True (0) if command found, False (> 0) if not. # @since 2.12 _comp_realcommand() { - ret="" + REPLY="" local file file=$(type -P "$1") || return $? if type -p realpath >/dev/null; then - ret=$(realpath "$file") + REPLY=$(realpath "$file") elif type -p greadlink >/dev/null; then - ret=$(greadlink -f "$file") + REPLY=$(greadlink -f "$file") elif type -p readlink >/dev/null; then - ret=$(readlink -f "$file") + REPLY=$(readlink -f "$file") else _comp_abspath "$file" fi @@ -2187,7 +2187,7 @@ _comp_realcommand() # Options: # -a GLOB Pattern of options that take an option argument # -# @var[out] ret Position of the first argument before the current one being +# @var[out] REPLY Position of the first argument before the current one being # completed if any, or otherwise an empty string # @return True (0) if any argument is found, False (> 0) otherwise. # @since 2.12 @@ -2207,16 +2207,16 @@ _comp_locate_first_arg() shift "$((OPTIND - 1))" local i - ret= + REPLY= for ((i = 1; i < cword; i++)); do # shellcheck disable=SC2053 if [[ $has_optarg && ${words[i]} == $has_optarg ]]; then ((i++)) elif [[ ${words[i]} != -?* ]]; then - ret=$i + REPLY=$i return 0 elif [[ ${words[i]} == -- ]]; then - ((i + 1 < cword)) && ret=$((i + 1)) && return 0 + ((i + 1 < cword)) && REPLY=$((i + 1)) && return 0 break fi done @@ -2228,13 +2228,13 @@ _comp_locate_first_arg() # Options: # -a GLOB Pattern of options that take an option argument # -# @var[out] ret First argument before the current one being completed if any, +# @var[out] REPLY First argument before the current one being completed if any, # or otherwise an empty string # @return True (0) if any argument is found, False (> 0) otherwise. # @since 2.12 _comp_get_first_arg() { - _comp_locate_first_arg "$@" && ret=${words[ret]} + _comp_locate_first_arg "$@" && REPLY=${words[REPLY]} } # This function counts the number of args, excluding options @@ -2246,7 +2246,7 @@ _comp_get_first_arg() # -a GLOB Options whose following argument should not be counted # -i GLOB Options that should be counted as args # -# @var[out] ret Return the number of arguments +# @var[out] REPLY Return the number of arguments # @since 2.12 _comp_count_args() { @@ -2271,15 +2271,15 @@ _comp_count_args() fi local i - ret=1 + REPLY=1 for ((i = 1; i < cword; i++)); do # shellcheck disable=SC2053 if [[ $has_optarg && ${words[i]} == $has_optarg ]]; then ((i++)) elif [[ ${words[i]} != -?* || $glob_include && ${words[i]} == $glob_include ]]; then - ((ret++)) + ((REPLY++)) elif [[ ${words[i]} == -- ]]; then - ((ret += cword - i - 1)) + ((REPLY += cword - i - 1)) break fi done @@ -2394,7 +2394,7 @@ _comp__included_ssh_config_files() { (($# < 1)) && echo "bash_completion: $FUNCNAME: missing mandatory argument CONFIG" >&2 - local configfile i files f ret + local configfile i files f REPLY configfile=$1 # From man ssh_config: @@ -2427,7 +2427,7 @@ _comp__included_ssh_config_files() i="${relative_include_base}/${i}" fi _comp_expand_tilde "$i" - _comp_expand_glob files '$ret' + _comp_expand_glob files '$REPLY' # In case the expanded variable contains multiple paths if ((${#files[@]})); then for f in "${files[@]}"; do @@ -2535,19 +2535,19 @@ _comp_compgen_known_hosts__impl() # spaces in their name work (watch out for ~ expansion # breakage! Alioth#311595) if _comp_split -l tmpkh "$(_comp_awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t=]+", "") { print $0 }' "${config[@]}" | sort -u)"; then - local tmpkh2 j ret + local tmpkh2 j REPLY for i in "${tmpkh[@]}"; do # First deal with quoted entries... while [[ $i =~ ^([^\"]*)\"([^\"]*)\"(.*)$ ]]; do i=${BASH_REMATCH[1]}${BASH_REMATCH[3]} _comp_expand_tilde "${BASH_REMATCH[2]}" # Eval/expand possible `~' or `~user' - [[ -r $ret ]] && kh+=("$ret") + [[ -r $REPLY ]] && kh+=("$REPLY") done # ...and then the rest. _comp_split tmpkh2 "$i" || continue for j in "${tmpkh2[@]}"; do _comp_expand_tilde "$j" # Eval/expand possible `~' or `~user' - [[ -r $ret ]] && kh+=("$ret") + [[ -r $REPLY ]] && kh+=("$REPLY") done done fi @@ -2676,7 +2676,7 @@ complete -F _comp_complete_known_hosts traceroute traceroute6 \ # _comp__find_original_word() { - ret=$1 + REPLY=$1 # If CWORD or WORDS are undefined, we return the first argument without any # processing. @@ -2689,7 +2689,7 @@ _comp__find_original_word() word=${word#*"${COMP_WORDS[i++]}"} done done - ret=$i + REPLY=$i } # A meta-command completion function for commands like sudo(8), which need to # first complete on a command, then complete according to that command's own @@ -2702,9 +2702,9 @@ _comp_command_offset() # actual command completion # obtain the word index in COMP_WORDS - local ret + local REPLY _comp__find_original_word "$1" - local word_offset=$ret + local word_offset=$REPLY # make changes to COMP_* local. Note that bash-4.3..5.0 have a # bug that `local -a arr=("${arr[@]}")` fails. We instead first @@ -2733,8 +2733,8 @@ _comp_command_offset() if ((COMP_CWORD == 0)); then _comp_compgen_commands else - _comp_dequote "${COMP_WORDS[0]}" || ret=${COMP_WORDS[0]} - local cmd=$ret compcmd=$ret + _comp_dequote "${COMP_WORDS[0]}" || REPLY=${COMP_WORDS[0]} + local cmd=$REPLY compcmd=$REPLY local cspec=$(complete -p "$cmd" 2>/dev/null) # If we have no completion for $cmd yet, see if we have for basename @@ -2940,9 +2940,9 @@ _comp_compgen_filedir_xspec() { _comp_compgen_tilde && return - local ret + local REPLY _comp_quote_compgen "$cur" - local quoted=$ret + local quoted=$REPLY local xspec=${_comp_xspecs[${1##*/}]-${_xspecs[${1##*/}]-}} local -a toks @@ -3080,10 +3080,10 @@ _comp_load() fi # Resolve absolute path to $cmd - local ret pathcmd origcmd=$cmd + local REPLY pathcmd origcmd=$cmd if pathcmd=$(type -P "$cmd"); then _comp_abspath "$pathcmd" - cmd=$ret + cmd=$REPLY fi local -a dirs=() @@ -3113,7 +3113,7 @@ _comp_load() # the real path to the command, and $PATH paths=() [[ $cmd == /* ]] && paths+=("${cmd%/*}") - _comp_realcommand "$cmd" && paths+=("${ret%/*}") + _comp_realcommand "$cmd" && paths+=("${REPLY%/*}") _comp_split -aF : paths "$PATH" for dir in "${paths[@]%/}"; do [[ $dir == ?*/@(bin|sbin) ]] && diff --git a/bash_completion.d/000_bash_completion_compat.bash b/bash_completion.d/000_bash_completion_compat.bash index 1ff608e1485..6971fa9651e 100644 --- a/bash_completion.d/000_bash_completion_compat.bash +++ b/bash_completion.d/000_bash_completion_compat.bash @@ -58,7 +58,7 @@ have() # This function shell-quotes the argument # @deprecated 2.12 Use `_comp_quote` instead. Note that `_comp_quote` stores -# the results in the variable `ret` instead of writing them to stdout. +# the results in the variable `REPLY` instead of writing them to stdout. quote() { local quoted=${1//\'/\'\\\'\'} @@ -68,9 +68,9 @@ quote() # @deprecated 2.12 Use `_comp_quote_compgen` quote_readline() { - local ret + local REPLY _comp_quote_compgen "$1" - printf %s "$ret" + printf %s "$REPLY" } # This function is the same as `_comp_quote_compgen`, but receives the second @@ -78,23 +78,23 @@ quote_readline() # @param $1 Argument to quote # @param $2 Name of variable to return result to # @deprecated 2.12 Use `_comp_quote_compgen "$1"` instead. Note that -# `_comp_quote_compgen` stores the result in a fixed variable `ret`. +# `_comp_quote_compgen` stores the result in a fixed variable `REPLY`. _quote_readline_by_ref() { - [[ $2 == ret ]] || local ret + [[ $2 == REPLY ]] || local REPLY _comp_quote_compgen "$1" - [[ $2 == ret ]] || printf -v "$2" %s "$ret" + [[ $2 == REPLY ]] || printf -v "$2" %s "$REPLY" } # This function shell-dequotes the argument # @deprecated 2.12 Use `_comp_dequote' instead. Note that `_comp_dequote` -# stores the results in the array `ret` instead of writing them to stdout. +# stores the results in the array `REPLY` instead of writing them to stdout. dequote() { - local ret + local REPLY _comp_dequote "$1" local rc=$? - printf %s "$ret" + printf %s "$REPLY" return $rc } @@ -198,14 +198,14 @@ _get_pword() # Get real command. # @deprecated 2.12 Use `_comp_realcommand` instead. -# Note that `_comp_realcommand` stores the result in the variable `ret` +# Note that `_comp_realcommand` stores the result in the variable `REPLY` # instead of writing it to stdout. _realcommand() { - local ret + local REPLY _comp_realcommand "$1" local rc=$? - printf "%s\n" "$ret" + printf "%s\n" "$REPLY" return $rc } @@ -328,14 +328,14 @@ _parse_help() if [[ $1 == - ]]; then args=(-) else - local ret opt IFS=$' \t\n' + local REPLY opt IFS=$' \t\n' _comp_dequote "$1" _comp_split opt "${2:---help}" - args=(-c "$ret" ${opt[@]+"${opt[@]}"}) + args=(-c "$REPLY" ${opt[@]+"${opt[@]}"}) fi - local -a ret=() - _comp_compgen -Rv ret help "${args[@]}" || return 1 - ((${#ret[@]})) && printf '%s\n' "${ret[@]}" + local -a REPLY=() + _comp_compgen -Rv REPLY help "${args[@]}" || return 1 + ((${#REPLY[@]})) && printf '%s\n' "${REPLY[@]}" return 0 } @@ -352,23 +352,23 @@ _parse_usage() if [[ $1 == - ]]; then args=(-) else - local ret opt IFS=$' \t\n' + local REPLY opt IFS=$' \t\n' _comp_dequote "$1" _comp_split opt "${2:---usage}" - args=(-c "$ret" ${opt[@]+"${opt[@]}"}) + args=(-c "$REPLY" ${opt[@]+"${opt[@]}"}) fi - local -a ret=() - _comp_compgen -Rv ret usage "${args[@]}" || return 1 - ((${#ret[@]})) && printf '%s\n' "${ret[@]}" + local -a REPLY=() + _comp_compgen -Rv REPLY usage "${args[@]}" || return 1 + ((${#REPLY[@]})) && printf '%s\n' "${REPLY[@]}" return 0 } # @deprecated 2.12 Use `_comp_get_ncpus`. _ncpus() { - local ret + local REPLY _comp_get_ncpus - printf %s "$ret" + printf %s "$REPLY" } # Expand variable starting with tilde (~). @@ -381,14 +381,14 @@ _ncpus() # # @deprecated 2.12 Use `_comp_expand_tilde`. The new function receives the # value instead of a variable name as $1 and always returns the result to the -# variable `ret`. +# variable `REPLY`. __expand_tilde_by_ref() { [[ ${1+set} ]] || return 0 - [[ $1 == ret ]] || local ret + [[ $1 == REPLY ]] || local REPLY _comp_expand_tilde "${!1-}" # shellcheck disable=SC2059 - [[ $1 == ret ]] || printf -v "$1" "$ret" + [[ $1 == REPLY ]] || printf -v "$1" "$REPLY" } # @deprecated 2.12 Use `_comp_compgen -a cd_devices` @@ -449,7 +449,7 @@ _fstypes() # @deprecated 2.12 Use `_comp_get_first_arg`. Note that the new function # `_comp_get_first_arg` operates on `words` and `cword` instead of `COMP_WORDS` # and `COMP_CWORD`. The new function considers a command-line argument after -# `--` as an argument. The new function returns the result in variable `ret` +# `--` as an argument. The new function returns the result in variable `REPLY` # instead of `arg`. _get_first_arg() { @@ -471,7 +471,7 @@ _get_first_arg() # @param $3 glob Options that should be counted as args # @var[out] args Return the number of arguments # @deprecated 2.12 Use `_comp_count_args`. Note that the new function -# `_comp_count_args` returns the result in variable `ret` instead of `args`. +# `_comp_count_args` returns the result in variable `REPLY` instead of `args`. # In the new function, `-` is also counted as an argument. The new function # counts all the arguments after `--`. # shellcheck disable=SC2178 # assignments are not intended for global "args" diff --git a/completions/2to3 b/completions/2to3 index 98ec9f40529..0a60e1f2551 100644 --- a/completions/2to3 +++ b/completions/2to3 @@ -16,9 +16,9 @@ _comp_cmd_2to3() return ;; -j | --processes) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "{1..$ret}" + _comp_compgen -- -W "{1..$REPLY}" return ;; -o | --output-dir) diff --git a/completions/7z b/completions/7z index e4c4455d954..027f84be652 100644 --- a/completions/7z +++ b/completions/7z @@ -84,9 +84,9 @@ _comp_cmd_7z() return fi - local ret + local REPLY _comp_count_args - if ((ret == 2)); then + if ((REPLY == 2)); then _comp_compgen_filedir_xspec unzip # TODO: parsing 7z i output? # - how to figure out if the format is input or output? diff --git a/completions/Makefile.am b/completions/Makefile.am index 5d6b5abbb06..aff1dd105f3 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -1222,9 +1222,9 @@ install-data-hook: ss = $(SETUP_SYMLINKS) $(DESTDIR)$(bashcompdir) install-data-hook: symlinks check-local: - ret=0; \ + REPLY=0; \ for file in $(bashcomp_DATA); do \ $${bashcomp_bash:-$${BASH:-bash}} \ - -O extglob -n $(srcdir)/$$file || ret=$$?; \ + -O extglob -n $(srcdir)/$$file || REPLY=$$?; \ done; \ - exit $$ret + exit $$REPLY diff --git a/completions/_cal b/completions/_cal index 6ca6520784d..3f8b3ca8028 100644 --- a/completions/_cal +++ b/completions/_cal @@ -28,9 +28,9 @@ _comp_cmd_cal() return fi - local ret + local REPLY _comp_count_args - ((ret == 1)) && _comp_compgen -- -W '{1..12}' + ((REPLY == 1)) && _comp_compgen -- -W '{1..12}' } && complete -F _comp_cmd_cal cal ncal diff --git a/completions/_umount.linux b/completions/_umount.linux index 3a881e424b2..b0359a90539 100644 --- a/completions/_umount.linux +++ b/completions/_umount.linux @@ -15,10 +15,10 @@ _comp_cmd_umount__reply_compgen_array() # argument. local i wlist for i in ${!COMPREPLY[*]}; do - local ret - printf -v ret %q "${COMPREPLY[i]}" - _comp_quote "$ret" - wlist+=$ret$'\n' + local REPLY + printf -v REPLY %q "${COMPREPLY[i]}" + _comp_quote "$REPLY" + wlist+=$REPLY$'\n' done # We also have to add another round of escaping to $cur. diff --git a/completions/_xm b/completions/_xm index 16cdc41cd91..7577efd22d2 100644 --- a/completions/_xm +++ b/completions/_xm @@ -17,7 +17,7 @@ _comp_cmd_xm() # TODO: split longopt - local ret command commands options + local REPLY command commands options commands='console vncviewer create new delete destroy domid domname dump-core list mem-max mem-set migrate pause reboot rename reset @@ -80,7 +80,7 @@ _comp_cmd_xm() vcpu-list | vcpu-pin | vcpu-set | block-list | \ network-list | vtpm-list) _comp_count_args - case $ret in + case $REPLY in 2) _comp_cmd_xm__domain_names ;; @@ -88,7 +88,7 @@ _comp_cmd_xm() ;; migrate) _comp_count_args - case $ret in + case $REPLY in 2) _comp_cmd_xm__domain_names ;; @@ -102,7 +102,7 @@ _comp_cmd_xm() ;; save) _comp_count_args - case $ret in + case $REPLY in 2) _comp_cmd_xm__domain_names ;; @@ -113,7 +113,7 @@ _comp_cmd_xm() ;; sysrq) _comp_count_args - case $ret in + case $REPLY in 2) _comp_cmd_xm__domain_names ;; @@ -124,7 +124,7 @@ _comp_cmd_xm() ;; block-attach) _comp_count_args - case $ret in + case $REPLY in 2) _comp_cmd_xm__domain_names ;; @@ -141,7 +141,7 @@ _comp_cmd_xm() ;; block-detach) _comp_count_args - case $ret in + case $REPLY in 2) _comp_cmd_xm__domain_names ;; @@ -153,7 +153,7 @@ _comp_cmd_xm() ;; network-attach) _comp_count_args - case $ret in + case $REPLY in 2) _comp_cmd_xm__domain_names ;; @@ -165,7 +165,7 @@ _comp_cmd_xm() ;; network-detach) _comp_count_args - case $ret in + case $REPLY in 2) _comp_cmd_xm__domain_names ;; @@ -202,7 +202,7 @@ _comp_cmd_xm() esac _comp_count_args - case $ret in + case $REPLY in 2) _comp_cmd_xm__domain_names ;; diff --git a/completions/ant b/completions/ant index 97414b4ed27..e4f9f298714 100644 --- a/completions/ant +++ b/completions/ant @@ -9,7 +9,7 @@ _comp_cmd_ant__targets() # parse buildfile for targets while read -rd '>' line; do if [[ $line =~ \<(target|extension-point)[[:space:]].*name=[\"\']([^\"\']+) ]]; then - ret+=("${BASH_REMATCH[2]}") + REPLY+=("${BASH_REMATCH[2]}") fi done <"$1" @@ -87,12 +87,12 @@ _comp_cmd_ant() fi [[ ! -f $buildfile ]] && return - local ret=() + local REPLY=() # fill targets _comp_cmd_ant__targets "$buildfile" - _comp_compgen -- -W '"${ret[@]}"' + _comp_compgen -- -W '"${REPLY[@]}"' fi } && complete -F _comp_cmd_ant ant phing diff --git a/completions/arp b/completions/arp index d569eba2014..3d1669ad3bb 100644 --- a/completions/arp +++ b/completions/arp @@ -33,9 +33,9 @@ _comp_cmd_arp() return fi - local ret + local REPLY _comp_count_args -a "@(--device|--protocol|--file|--hw-type|-${noargopts}[iApfHt])" - case $ret in + case $REPLY in 1) local ips=$("$1" -an | command sed -ne \ 's/.*(\([0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}\)).*/\1/p') diff --git a/completions/avctrl b/completions/avctrl index 139bf5961f6..2bb27557b9a 100644 --- a/completions/avctrl +++ b/completions/avctrl @@ -8,9 +8,9 @@ _comp_cmd_avctrl() if [[ $cur == -* ]]; then _comp_compgen -- -W '--help --quiet' else - local ret + local REPLY _comp_count_args - if ((ret == 1)); then + if ((REPLY == 1)); then _comp_compgen -- -W 'discover switch' fi fi diff --git a/completions/bzip2 b/completions/bzip2 index 91a622efab1..0e5d98f1ca3 100644 --- a/completions/bzip2 +++ b/completions/bzip2 @@ -12,9 +12,9 @@ _comp_cmd_bzip2() return ;; -${noargopts}n) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "{1..$ret}" + _comp_compgen -- -W "{1..$REPLY}" return ;; esac diff --git a/completions/chmod b/completions/chmod index 9e66ac0465c..3dbc16f2707 100644 --- a/completions/chmod +++ b/completions/chmod @@ -27,10 +27,10 @@ _comp_cmd_chmod() return fi - local ret + local REPLY _comp_count_args -i "$modearg" - case $ret in + case $REPLY in 1) ;; # mode *) _comp_compgen_filedir ;; esac diff --git a/completions/chown b/completions/chown index a1416d785c0..25d0d67eba1 100644 --- a/completions/chown +++ b/completions/chown @@ -29,12 +29,12 @@ _comp_cmd_chown() --no-dereference --from --silent --quiet --reference --recursive --verbose --help --version $opts' else - local ret + local REPLY # The first argument is a usergroup; the rest are filedir. _comp_count_args - if ((ret == 1)); then + if ((REPLY == 1)); then _comp_compgen_usergroups -u else _comp_compgen_filedir diff --git a/completions/cppcheck b/completions/cppcheck index eda632d5b64..f865fb95d33 100644 --- a/completions/cppcheck +++ b/completions/cppcheck @@ -42,9 +42,9 @@ _comp_cmd_cppcheck() return ;; -j) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "{1..$ret}" + _comp_compgen -- -W "{1..$REPLY}" return ;; --language | -x) diff --git a/completions/cryptsetup b/completions/cryptsetup index e6b2c5abe4f..9d23bfa6381 100644 --- a/completions/cryptsetup +++ b/completions/cryptsetup @@ -34,11 +34,11 @@ _comp_cmd_cryptsetup() [[ $was_split ]] && return - local ret + local REPLY if _comp_get_first_arg; then - local arg=$ret + local arg=$REPLY _comp_count_args -a "-${noargopts}[chslSbopitTdM]" - local args=$ret + local args=$REPLY case $arg in open | create | luksOpen | loopaesOpen | tcryptOpen) case $args in diff --git a/completions/export b/completions/export index d01a3d76167..0f692c9861c 100644 --- a/completions/export +++ b/completions/export @@ -31,9 +31,9 @@ _comp_cmd_export() case $cur in *=) local pname=${cur%=} - local ret + local REPLY _comp_quote "${!pname-}" - local pval=$ret + local pval=$REPLY # Complete previous value if it's not empty. if [[ $pval != \'\' ]]; then COMPREPLY=("$pval") diff --git a/completions/fio b/completions/fio index 82084a24740..d7644a9cae1 100644 --- a/completions/fio +++ b/completions/fio @@ -3,8 +3,8 @@ _comp_cmd_fio__engines() { local IFS=$'\n' - ret=($("$1" --enghelp 2>/dev/null | command sed -ne '/^[[:space:]]/p')) - return $((!${#ret[*]})) + REPLY=($("$1" --enghelp 2>/dev/null | command sed -ne '/^[[:space:]]/p')) + return $((!${#REPLY[*]})) } _comp_cmd_fio() @@ -12,7 +12,7 @@ _comp_cmd_fio() local cur prev words cword was_split comp_args _comp_initialize -s -- "$@" || return - local ret + local REPLY case $prev in --help | --version) return @@ -36,13 +36,13 @@ _comp_cmd_fio() return ;; --cmdhelp) - ret=($("$1" --cmdhelp=all 2>/dev/null | _comp_awk '{print $1}') all) - _comp_compgen -- -W '"${ret[@]}"' + REPLY=($("$1" --cmdhelp=all 2>/dev/null | _comp_awk '{print $1}') all) + _comp_compgen -- -W '"${REPLY[@]}"' return ;; --enghelp) _comp_cmd_fio__engines "$1" && - _comp_compgen -- -W '"${ret[@]}"' + _comp_compgen -- -W '"${REPLY[@]}"' return ;; --eta) @@ -83,7 +83,7 @@ _comp_cmd_fio() ;; --ioengine) _comp_cmd_fio__engines "$1" && - _comp_compgen -- -W '"${ret[@]}"' + _comp_compgen -- -W '"${REPLY[@]}"' return ;; --exec_postrun | --exec_prerun) @@ -115,20 +115,20 @@ _comp_cmd_fio() # valid values: 1024 [...] # : 1000 [...] local line="" in_values="" - ret=() + REPLY=() for line in "${cmdhelp[@]}"; do if [[ $in_values ]]; then if [[ $line =~ ^[[:space:]]*:[[:space:]]*([^[:space:]]+) ]]; then - ret+=("${BASH_REMATCH[1]}") + REPLY+=("${BASH_REMATCH[1]}") else break fi elif [[ $line =~ ^[[:space:]]*valid\ values:[[:space:]]*([^[:space:]]+) ]]; then in_values=set - ret+=("${BASH_REMATCH[1]}") + REPLY+=("${BASH_REMATCH[1]}") fi done - _comp_compgen -- -W '"${ret[@]}"' + _comp_compgen -- -W '"${REPLY[@]}"' return ;; esac diff --git a/completions/flake8 b/completions/flake8 index e85809b35b6..6889e86a832 100644 --- a/completions/flake8 +++ b/completions/flake8 @@ -16,9 +16,9 @@ _comp_cmd_flake8() return ;; --jobs | -${noargopts}j) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "auto {1..$ret}" + _comp_compgen -- -W "auto {1..$REPLY}" return ;; --output-file | --append-config | --config) diff --git a/completions/gcc b/completions/gcc index 4a67ee3a43d..ed5bc9b3297 100644 --- a/completions/gcc +++ b/completions/gcc @@ -59,9 +59,9 @@ _comp_cmd_gcc() gccgo{,-5,-6,-7,-8} gcj gfortran{,-5,-6,-7,-8} gpc && _comp_cmd_gcc__setup_cmd() { - local ret + local REPLY _comp_realcommand "$1" - if [[ $ret == *$2* ]] || + if [[ $REPLY == *$2* ]] || "$1" --version 2>/dev/null | command grep -q GCC; then complete -F _comp_cmd_gcc "$1" else diff --git a/completions/gpgv b/completions/gpgv index 78a8b9d842b..7609a33c776 100644 --- a/completions/gpgv +++ b/completions/gpgv @@ -19,9 +19,9 @@ _comp_cmd_gpgv() ;; esac - local ret + local REPLY _comp_count_args -a "--@(weak-digest|*-fd|keyring|homedir)" - local args=$ret + local args=$REPLY if [[ $cur == -* && $args -eq 1 ]]; then _comp_compgen_help diff --git a/completions/gzip b/completions/gzip index 1a393da688e..9a41eecabe5 100644 --- a/completions/gzip +++ b/completions/gzip @@ -13,9 +13,9 @@ _comp_cmd_gzip() return ;; --processes | -${noargopts}p) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "{1..$ret}" + _comp_compgen -- -W "{1..$REPLY}" return ;; esac diff --git a/completions/hcitool b/completions/hcitool index 02b204df1a7..99b5367cf9a 100644 --- a/completions/hcitool +++ b/completions/hcitool @@ -45,12 +45,12 @@ _comp_cmd_hcitool() [[ $was_split ]] && return - local ret + local REPLY if _comp_get_first_arg; then - case $ret in + case $REPLY in name | info | dc | rssi | lq | afh | auth | key | clkoff | lst) _comp_count_args - if ((ret == 2)); then + if ((REPLY == 2)); then _comp_cmd_hcitool__bluetooth_addresses fi ;; @@ -59,14 +59,14 @@ _comp_cmd_hcitool() _comp_compgen -- -W '--role --pkt-type' else _comp_count_args - if ((ret == 2)); then + if ((REPLY == 2)); then _comp_cmd_hcitool__bluetooth_addresses fi fi ;; sr) _comp_count_args - if ((ret == 2)); then + if ((REPLY == 2)); then _comp_cmd_hcitool__bluetooth_addresses else _comp_compgen -- -W 'master slave' @@ -74,7 +74,7 @@ _comp_cmd_hcitool() ;; cpt) _comp_count_args - if ((ret == 2)); then + if ((REPLY == 2)); then _comp_cmd_hcitool__bluetooth_addresses else _comp_cmd_hcitool__bluetooth_packet_types @@ -82,7 +82,7 @@ _comp_cmd_hcitool() ;; tpl | enc | clock) _comp_count_args - if ((ret == 2)); then + if ((REPLY == 2)); then _comp_cmd_hcitool__bluetooth_addresses else _comp_compgen -- -W '0 1' @@ -114,9 +114,9 @@ _comp_cmd_sdptool() [[ $was_split ]] && return - local ret + local REPLY if _comp_get_first_arg; then - case $ret in + case $REPLY in search) if [[ $cur == -* ]]; then _comp_compgen -- -W '--bdaddr --tree --raw --xml' @@ -195,11 +195,11 @@ _comp_cmd_rfcomm() ;; esac - local ret + local REPLY if _comp_get_first_arg; then - local arg=$ret + local arg=$REPLY _comp_count_args - local args=$ret + local args=$REPLY if ((args == 2)); then _comp_cmd_hcitool__bluetooth_devices else @@ -234,13 +234,13 @@ _comp_cmd_ciptool() ;; esac - local ret + local REPLY if _comp_get_first_arg; then - case $ret in + case $REPLY in connect | release | loopback) - local ret + local REPLY _comp_count_args - if ((ret == 2)); then + if ((REPLY == 2)); then _comp_cmd_hcitool__bluetooth_addresses fi ;; @@ -270,9 +270,9 @@ _comp_cmd_dfutool() if [[ $cur == -* ]]; then _comp_compgen_help else - local ret + local REPLY _comp_count_args - case $ret in + case $REPLY in 1) _comp_compgen -- -W 'verify modify upgrade archive' ;; @@ -289,24 +289,24 @@ _comp_cmd_hciconfig() local cur prev words cword comp_args _comp_initialize -- "$@" || return - local ret + local REPLY if _comp_get_first_arg; then - case $ret in + case $REPLY in putkey | delkey) _comp_count_args - if ((ret == 2)); then + if ((REPLY == 2)); then _comp_cmd_hcitool__bluetooth_addresses fi ;; lm) _comp_count_args - if ((ret == 2)); then + if ((REPLY == 2)); then _comp_compgen -- -W 'MASTER SLAVE NONE ACCEPT' fi ;; ptype) _comp_count_args - if ((ret == 2)); then + if ((REPLY == 2)); then _comp_cmd_hcitool__bluetooth_packet_types fi ;; @@ -333,9 +333,9 @@ _comp_cmd_hciattach() if [[ $cur == -* ]]; then _comp_compgen -- -W '-n -p -t -b -s -l' else - local ret + local REPLY _comp_count_args - case $ret in + case $REPLY in 1) _comp_expand_glob COMPREPLY '/dev/tty*' ((${#COMPREPLY[@]})) && diff --git a/completions/ifup b/completions/ifup index b14c24b2310..bfeee82d809 100644 --- a/completions/ifup +++ b/completions/ifup @@ -28,10 +28,10 @@ _comp_cmd_ifupdown() return fi - local ret + local REPLY _comp_count_args -a "@(--allow|-i|--interfaces|--state-dir|-X|--exclude|-o)" - if ((ret == 1)); then + if ((REPLY == 1)); then _comp_compgen_configured_interfaces fi } && diff --git a/completions/isort b/completions/isort index 3b30f11bb27..a5c6dffe9e8 100644 --- a/completions/isort +++ b/completions/isort @@ -15,9 +15,9 @@ _comp_cmd_isort() return ;; --jobs | -j) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "{1..$ret}" + _comp_compgen -- -W "{1..$REPLY}" return ;; --multi-line | -m) diff --git a/completions/java b/completions/java index 56fbb0ac0fd..b7c2e4b23f0 100644 --- a/completions/java +++ b/completions/java @@ -7,60 +7,60 @@ _comp_cmd_java__classpath() } # exact classpath determination -# @var[out] ret Array to store classpaths +# @var[out] REPLY Array to store classpaths # @return 0 if at least one element is generated, or otherwise 1 _comp_cmd_java__find_classpath() { local i - ret= + REPLY= # search first in current options for ((i = 1; i < cword; i++)); do if [[ ${words[i]} == -@(cp|classpath) ]]; then - ret=${words[i + 1]} + REPLY=${words[i + 1]} break fi done # fall back to environment, followed by current directory - _comp_split -F : ret "${ret:-${CLASSPATH:-.}}" + _comp_split -F : REPLY "${REPLY:-${CLASSPATH:-.}}" } # exact sourcepath determination -# @var[out] ret Array to store sourcepaths +# @var[out] REPLY Array to store sourcepaths # @return 0 if at least one element is generated, or otherwise 1 _comp_cmd_java__find_sourcepath() { local i - ret= + REPLY= # search first in current options for ((i = 1; i < cword; i++)); do if [[ ${words[i]} == -sourcepath ]]; then - ret=${words[i + 1]} + REPLY=${words[i + 1]} break fi done # fall back to classpath - if [[ ! $ret ]]; then + if [[ ! $REPLY ]]; then _comp_cmd_java__find_classpath return fi - _comp_split -F : ret "$ret" + _comp_split -F : REPLY "$REPLY" } # available classes completion _comp_cmd_java__classes() { - local ret i + local REPLY i # find which classpath to use _comp_cmd_java__find_classpath - local -a classpaths=("${ret[@]}") + local -a classpaths=("${REPLY[@]}") # convert package syntax to path syntax cur=${cur//.//} @@ -105,11 +105,11 @@ _comp_cmd_java__classes() # available packages completion _comp_cmd_java__packages() { - local ret i files + local REPLY i files # find which sourcepath to use _comp_cmd_java__find_sourcepath || return 0 - local -a sourcepaths=("${ret[@]}") + local -a sourcepaths=("${REPLY[@]}") # convert package syntax to path syntax local cur=${cur//.//} diff --git a/completions/jq b/completions/jq index a12a16e4ef1..7021d2a60c7 100644 --- a/completions/jq +++ b/completions/jq @@ -63,13 +63,13 @@ _comp_cmd_jq() [[ $word != --?(json)args ]] || return done - local ret + local REPLY # TODO: DTRT with args taking 2 options # -f|--from-file are not counted here because they supply the filter _comp_count_args -a "@(--arg|--arg?(json|file)|--slurpfile|--indent|--run-tests|-${noargopts}L)" # 1st arg is filter - ((ret == 1)) && return + ((REPLY == 1)) && return # 2... are input files _comp_compgen_filedir 'json?(l)' diff --git a/completions/jsonschema b/completions/jsonschema index a150deeb34a..19a4439a059 100644 --- a/completions/jsonschema +++ b/completions/jsonschema @@ -20,9 +20,9 @@ _comp_cmd_jsonschema() return fi - local ret + local REPLY _comp_count_args -a "-*" - ((ret == 1)) || return + ((REPLY == 1)) || return _comp_compgen_filedir '@(json|schema)' } && complete -F _comp_cmd_jsonschema jsonschema diff --git a/completions/lrzip b/completions/lrzip index 16da0b97f20..6f40be771af 100644 --- a/completions/lrzip +++ b/completions/lrzip @@ -34,9 +34,9 @@ _comp_cmd_lrzip() return ;; --threads | -${noargopts}p) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "{1..$ret}" + _comp_compgen -- -W "{1..$REPLY}" return ;; esac diff --git a/completions/lvm b/completions/lvm index c6886f11c36..70581a7fc9e 100644 --- a/completions/lvm +++ b/completions/lvm @@ -49,7 +49,7 @@ _comp_cmd_lvm__sizes() # @param $1 glob matching args known to take an argument _comp_cmd_lvm__count_args() { - ret=0 + REPLY=0 local offset=1 if [[ ${words[0]} == lvm ]]; then offset=2 @@ -58,7 +58,7 @@ _comp_cmd_lvm__count_args() for ((i = offset; i < cword; i++)); do # shellcheck disable=SC2053 if [[ ${words[i]} != -* && $prev != $1 ]]; then - ((ret++)) + ((REPLY++)) fi prev=${words[i]} done @@ -334,9 +334,9 @@ _comp_cmd_vgcreate() if [[ $cur == -* ]]; then _comp_compgen_usage -- --help else - local ret + local REPLY _comp_cmd_lvm__count_args '@(-A|--autobackup|-M|--metadatatype|-s|--physicalextentsize)' - if ((ret == 0)); then + if ((REPLY == 0)); then _comp_cmd_lvm__volumegroups else _comp_cmd_lvm__physicalvolumes_all @@ -398,9 +398,9 @@ _comp_cmd_vgreduce() _comp_compgen_usage -- --help else - local ret + local REPLY _comp_cmd_lvm__count_args '@(-A|--autobackup)' - if ((ret == 0)); then + if ((REPLY == 0)); then _comp_cmd_lvm__volumegroups else _comp_cmd_lvm__physicalvolumes @@ -430,9 +430,9 @@ _comp_cmd_vgextend() if [[ $cur == -* ]]; then _comp_compgen_usage -- --help else - local ret + local REPLY _comp_cmd_lvm__count_args '@(-A|--autobackup|-L|--size)' - if ((ret == 0)); then + if ((REPLY == 0)); then _comp_cmd_lvm__volumegroups else _comp_cmd_lvm__physicalvolumes_all @@ -592,9 +592,9 @@ _comp_cmd_vgsplit() if [[ $cur == -* ]]; then _comp_compgen_usage -- --help else - local ret + local REPLY _comp_cmd_lvm__count_args '@(-A|--autobackup|-M|--metadatatype)' - if ((ret < 2)); then + if ((REPLY < 2)); then _comp_cmd_lvm__volumegroups else _comp_cmd_lvm__physicalvolumes @@ -730,9 +730,9 @@ _comp_cmd_lvcreate() if [[ $cur == -* ]]; then _comp_compgen_usage -- --help else - local ret + local REPLY _comp_cmd_lvm__count_args '@(-A|-C|-M|-Z|--autobackup|--contiguous|--persistent|--zero|-L|--size|-p|--permission|-n|--name)' - if ((ret == 0)); then + if ((REPLY == 0)); then _comp_cmd_lvm__volumegroups else _comp_cmd_lvm__physicalvolumes @@ -832,9 +832,9 @@ _comp_cmd_lvresize() if [[ $cur == -* ]]; then _comp_compgen_usage -- --help else - local ret + local REPLY _comp_cmd_lvm__count_args '@(-A|--autobackup|-L|--size)' - if ((ret == 0)); then + if ((REPLY == 0)); then _comp_cmd_lvm__logicalvolumes else _comp_cmd_lvm__physicalvolumes @@ -864,9 +864,9 @@ _comp_cmd_lvextend() if [[ $cur == -* ]]; then _comp_compgen_usage -- --help else - local ret + local REPLY _comp_cmd_lvm__count_args '@(-A|--autobackup|-L|--size)' - if ((ret == 0)); then + if ((REPLY == 0)); then _comp_cmd_lvm__logicalvolumes else _comp_cmd_lvm__physicalvolumes diff --git a/completions/lz4 b/completions/lz4 index 65b4a3b370b..8e2a77758fc 100644 --- a/completions/lz4 +++ b/completions/lz4 @@ -19,9 +19,9 @@ _comp_cmd_lz4() return fi - local ret word xspec="*.?(t)lz4" + local REPLY word xspec="*.?(t)lz4" _comp_count_args - local args=$ret + local args=$REPLY ((args > 2)) && return for word in "${words[@]}"; do diff --git a/completions/lzip b/completions/lzip index 31c6f37534b..cd33f60a9fe 100644 --- a/completions/lzip +++ b/completions/lzip @@ -18,9 +18,9 @@ _comp_cmd_lzip() decompress=set ;; --threads | -${noargopts}n) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "{1..$ret}" + _comp_compgen -- -W "{1..$REPLY}" return ;; --output | -${noargopts}o) diff --git a/completions/make b/completions/make index 2f07b67146e..87c678fbf26 100644 --- a/completions/make +++ b/completions/make @@ -95,9 +95,9 @@ _comp_cmd_make() return ;; --jobs | -${noargopts}j) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "{1..$((ret * 2))}" + _comp_compgen -- -W "{1..$((REPLY * 2))}" return ;; esac @@ -119,10 +119,10 @@ _comp_cmd_make() for ((i = 1; i < ${#words[@]}; i++)); do if [[ ${words[i]} == @(-${noargopts}C|--directory) ]]; then # Expand tilde expansion - local ret + local REPLY _comp_dequote "${words[i + 1]-}" && - [[ -d ${ret-} ]] && - makef_dir=(-C "$ret") + [[ -d ${REPLY-} ]] && + makef_dir=(-C "$REPLY") break fi done @@ -132,10 +132,10 @@ _comp_cmd_make() for ((i = 1; i < ${#words[@]}; i++)); do if [[ ${words[i]} == @(-${noargopts}f|--?(make)file) ]]; then # Expand tilde expansion - local ret + local REPLY _comp_dequote "${words[i + 1]-}" && - [[ -f ${ret-} ]] && - makef=(-f "$ret") + [[ -f ${REPLY-} ]] && + makef=(-f "$REPLY") break fi done diff --git a/completions/mkinitrd b/completions/mkinitrd index a81cfbb7299..4e11b0bef78 100644 --- a/completions/mkinitrd +++ b/completions/mkinitrd @@ -30,10 +30,10 @@ _comp_cmd_mkinitrd() --net-dev --fstab --nocompress --dsdt --bootchart' [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - local ret + local REPLY _comp_count_args - case $ret in + case $REPLY in 1) _comp_compgen_filedir ;; diff --git a/completions/mutt b/completions/mutt index 6eea3327848..ddc2eef0b5e 100644 --- a/completions/mutt +++ b/completions/mutt @@ -13,10 +13,10 @@ _comp_cmd_mutt__addresses() } # Find muttrc to use -# @var[out] ret muttrc filename +# @var[out] REPLY muttrc filename _comp_cmd_mutt__get_muttrc() { - ret= + REPLY= # Search COMP_WORDS for '-F muttrc' or '-Fmuttrc' argument set -- "${words[@]}" while (($# > 0)); do @@ -32,18 +32,18 @@ _comp_cmd_mutt__get_muttrc() shift done - if [[ ! $ret ]]; then + if [[ ! $REPLY ]]; then if [[ -f ~/.${muttcmd}rc ]]; then - ret=\~/.${muttcmd}rc + REPLY=\~/.${muttcmd}rc elif [[ -f ~/.${muttcmd}/${muttcmd}rc ]]; then - ret=\~/.${muttcmd}/${muttcmd}rc + REPLY=\~/.${muttcmd}/${muttcmd}rc fi fi } # Recursively build list of sourced config files # @param $1... Config file to process -# @var[out] ret List of config files +# @var[out] REPLY List of config files # @return 0 if any conffiles are generated, 1 if none is generated. _comp_cmd_mutt__get_conffiles() { @@ -52,10 +52,10 @@ _comp_cmd_mutt__get_conffiles() local file for file; do _comp_dequote "$file" - _comp_cmd_mutt__get_conffiles__visit "$ret" + _comp_cmd_mutt__get_conffiles__visit "$REPLY" done ((${#conffiles[@]})) || return 1 - ret=("${conffiles[@]}") + REPLY=("${conffiles[@]}") } # Recursion function for _comp_cmd_mutt__get_conffiles # @var[ref] conffiles List of config files found so far @@ -69,26 +69,26 @@ _comp_cmd_mutt__get_conffiles__visit() local -a newconffiles=($(command sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' "$1")) ((${#newconffiles[@]})) || return 0 - local file ret + local file REPLY for file in "${newconffiles[@]}"; do _comp_expand_tilde "$file" - _comp_cmd_mutt__get_conffiles__visit "$ret" + _comp_cmd_mutt__get_conffiles__visit "$REPLY" done } # @param $1 (cur) Current word to complete _comp_cmd_mutt__aliases() { - local cur=$1 muttrc muttcmd=${words[0]} ret + local cur=$1 muttrc muttcmd=${words[0]} REPLY local -a conffiles aliases _comp_cmd_mutt__get_muttrc - muttrc=$ret + muttrc=$REPLY [[ ! $muttrc ]] && return - local ret + local REPLY _comp_cmd_mutt__get_conffiles "$muttrc" || return 0 - conffiles=("${ret[@]}") + conffiles=("${REPLY[@]}") # shellcheck disable=SC2046 aliases=($(command sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \ "${conffiles[@]}")) @@ -106,9 +106,9 @@ _comp_cmd_mutt__query() if [[ ! $cur || ! $querycmd ]]; then queryresults=() else - local ret + local REPLY _comp_expand_tilde "$querycmd" - querycmd=$ret + querycmd=$REPLY # $querycmd is expected to be a command with arguments queryresults=($($querycmd | command sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p')) @@ -120,9 +120,9 @@ _comp_cmd_mutt__query() # @param $1 (cur) Current word to complete _comp_cmd_mutt__filedir() { - local cur=$1 folder muttrc spoolfile muttcmd=${words[0]} ret + local cur=$1 folder muttrc spoolfile muttcmd=${words[0]} REPLY _comp_cmd_mutt__get_muttrc - muttrc=$ret + muttrc=$REPLY if [[ $cur == [=+]* ]]; then folder="$("$muttcmd" -F "$muttrc" -Q folder 2>/dev/null | command sed -e 's|^folder=\"\(.*\)\"$|\1|')" [[ $folder ]] || folder=~/Mail diff --git a/completions/nc b/completions/nc index 8fb1617faee..22e297ca2a3 100644 --- a/completions/nc +++ b/completions/nc @@ -38,9 +38,9 @@ _comp_cmd_nc() fi # Complete 1st non-option arg only - local ret + local REPLY _comp_count_args -n "" -a "-*[IiMmOPpqsTVWwXx]" - ((ret == 1)) || return + ((REPLY == 1)) || return _comp_compgen_known_hosts -- "$cur" } && diff --git a/completions/nslookup b/completions/nslookup index 9179da75aeb..b04b03a4904 100644 --- a/completions/nslookup +++ b/completions/nslookup @@ -52,11 +52,11 @@ _comp_cmd_nslookup() return fi - local ret + local REPLY _comp_count_args - if ((ret <= 2)); then + if ((REPLY <= 2)); then _comp_compgen_known_hosts -- "$cur" - [[ $ret -eq 1 && $cur == @(|-) ]] && COMPREPLY+=(-) + [[ $REPLY -eq 1 && $cur == @(|-) ]] && COMPREPLY+=(-) fi } && complete -F _comp_cmd_nslookup nslookup @@ -89,11 +89,11 @@ _comp_cmd_host() return fi - local ret + local REPLY _comp_count_args -a "-*[ctmNRW]" - if ((ret == 1)); then + if ((REPLY == 1)); then _comp_compgen_known_hosts -- "$cur" - elif ((ret == 2)); then + elif ((REPLY == 2)); then local ipvx [[ ${words[*]} =~ \ -[^\ ]*([46]) ]] && ipvx=-${BASH_REMATCH[1]} # shellcheck disable=SC2086 diff --git a/completions/patch b/completions/patch index 8497788fe37..bba184ceb4a 100644 --- a/completions/patch +++ b/completions/patch @@ -55,9 +55,9 @@ _comp_cmd_patch() return fi - local ret + local REPLY _comp_count_args - case $ret in + case $REPLY in 1) _comp_compgen_filedir ;; diff --git a/completions/pkg-get b/completions/pkg-get index 01e770adbd5..a8ec1a84626 100644 --- a/completions/pkg-get +++ b/completions/pkg-get @@ -19,9 +19,9 @@ _comp_cmd_pkg_get__catalog_file() url=$(_comp_awk -F = ' $1=="url" { print $2 }' "$conffile") fi - ret="${url##*//}" - ret="${ret%%/*}" - ret="/var/pkg-get/catalog-$ret" + REPLY="${url##*//}" + REPLY="${REPLY%%/*}" + REPLY="/var/pkg-get/catalog-$REPLY" } && _comp_cmd_pkg_get() { @@ -46,10 +46,10 @@ _comp_cmd_pkg_get__catalog_file() if [[ $command ]]; then if [[ $command == @(-[Ddi]|describe|download|install) ]]; then - local ret + local REPLY _comp_cmd_pkg_get__catalog_file "$url" - if [[ -f $ret ]]; then - local packages_list=$(_comp_awk '$0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "$ret") + if [[ -f $REPLY ]]; then + local packages_list=$(_comp_awk '$0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "$REPLY") _comp_compgen -- -W "${packages_list}" fi fi diff --git a/completions/pkgadd b/completions/pkgadd index 0eba945724a..d8a0cffc9ad 100644 --- a/completions/pkgadd +++ b/completions/pkgadd @@ -46,9 +46,9 @@ _comp_cmd_pkgadd() pkginst_list=("${pkginst_list[@]%/pkginfo}") fi else - local ret + local REPLY _comp_dequote "$device" - _comp_split -l pkginst_list "$(strings "${ret-}" | + _comp_split -l pkginst_list "$(strings "${REPLY-}" | command sed -n 's/^PKG=//p' | sort -u)" fi ((${#pkginst_list[@]})) && diff --git a/completions/pkgutil b/completions/pkgutil index b7a9147563b..99af4d06eae 100644 --- a/completions/pkgutil +++ b/completions/pkgutil @@ -9,7 +9,7 @@ _comp_cmd_pkgutil__url2catalog() filename="${filename//\//_}" filename="/var/opt/csw/pkgutil/catalog.${filename}_$(uname -p)_$(uname -r)" - ret=$filename + REPLY=$filename } _comp_cmd_pkgutil() @@ -22,16 +22,16 @@ _comp_cmd_pkgutil() "/opt/csw/etc/pkgutil.conf" "/etc/opt/csw/pkgutil.conf") declare -a catalog_files=() - local i=$cword ret + local i=$cword REPLY while ((i-- > 1)); do if [[ ${words[i]} == -@(t|-temp) ]]; then local url="${words[i + 1]}" _comp_cmd_pkgutil__url2catalog "$url" - catalog_files=("$ret") + catalog_files=("$REPLY") elif [[ ${words[i]} == --config ]]; then - local ret + local REPLY _comp_dequote "${words[i + 1]}" - [[ ${ret-} ]] && configuration_files=("$ret") + [[ ${REPLY-} ]] && configuration_files=("$REPLY") elif [[ ${words[i]} == -@([iurdacUS]|-install|-upgrade|-remove|-download|-available|-compare|-catalog|-stream) ]]; then command="${words[i]}" fi @@ -77,7 +77,7 @@ _comp_cmd_pkgutil() mirrors=${mirrors:-http://mirror.opencsw.org/opencsw/testing} for mirror_url in $mirrors; do _comp_cmd_pkgutil__url2catalog "$mirror_url" - catalog_files+=("$ret") + catalog_files+=("$REPLY") done if [[ $command == -@([dius]|-download|-install|-upgrade|-stream) ]]; then diff --git a/completions/pylint b/completions/pylint index 266dcfafb55..704c1ec9e95 100644 --- a/completions/pylint +++ b/completions/pylint @@ -78,9 +78,9 @@ _comp_cmd_pylint() return ;; --jobs | -${noargopts}j) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "{1..$ret}" + _comp_compgen -- -W "{1..$REPLY}" return ;; --confidence) diff --git a/completions/pytest b/completions/pytest index d7516b3bc52..a3687f505ce 100644 --- a/completions/pytest +++ b/completions/pytest @@ -81,9 +81,9 @@ _comp_cmd_pytest() return ;; --numprocesses | -${noargopts}n) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "{1..$ret} auto" + _comp_compgen -- -W "{1..$REPLY} auto" return ;; --dist | --vcr-record?(-mode)) diff --git a/completions/quota b/completions/quota index c82b506c231..504284cf260 100644 --- a/completions/quota +++ b/completions/quota @@ -83,10 +83,10 @@ _comp_cmd_setquota() if [[ $cur == -* ]]; then _comp_cmd_quota__parse_help "$1" else - local ret + local REPLY _comp_count_args - case $ret in + case $REPLY in 1) _comp_cmd_quota__user_or_group ;; diff --git a/completions/sbopkg b/completions/sbopkg index 4554fc244d8..fb568c631f7 100644 --- a/completions/sbopkg +++ b/completions/sbopkg @@ -34,12 +34,12 @@ _comp_cmd_sbopkg() ;; esac - local i ret config + local i REPLY config config="/etc/sbopkg/sbopkg.conf" for ((i = ${#words[@]} - 2; i > 0; i--)); do if [[ ${words[i]} == -f ]]; then _comp_expand_tilde "${words[i + 1]}" - config=$ret + config=$REPLY break fi done diff --git a/completions/sh b/completions/sh index 9c4e704c965..5581bccb921 100644 --- a/completions/sh +++ b/completions/sh @@ -25,9 +25,9 @@ _comp_cmd_sh() return fi - local ret ext= + local REPLY ext= _comp_count_args -a "@(-c|[-+]o)" - ((ret == 1)) && ext="sh" + ((REPLY == 1)) && ext="sh" _comp_compgen_filedir $ext } && complete -F _comp_cmd_sh sh diff --git a/completions/slapt-get b/completions/slapt-get index e35557721a7..d8c2592a4fb 100644 --- a/completions/slapt-get +++ b/completions/slapt-get @@ -47,9 +47,9 @@ _comp_cmd_slapt_get() # search for config for ((i = ${#words[@]} - 1; i > 0; i--)); do if [[ ${words[i]} == -@(c|-config) ]]; then - local ret + local REPLY _comp_expand_tilde "${words[i + 1]-}" - config=$ret + config=$REPLY break fi done diff --git a/completions/slapt-src b/completions/slapt-src index 0b0f2359687..63dab92e7e1 100644 --- a/completions/slapt-src +++ b/completions/slapt-src @@ -42,9 +42,9 @@ _comp_cmd_slapt_src() # search for config for ((i = ${#words[@]} - 1; i > 0; i--)); do if [[ ${words[i]} == -@(c|-config) ]]; then - local ret + local REPLY _comp_expand_tilde "${words[i + 1]-}" - config=$ret + config=$REPLY break fi if [[ ${words[i]} == --config=?* ]]; then diff --git a/completions/ssh b/completions/ssh index 63e3ac07a53..c72854b483b 100644 --- a/completions/ssh +++ b/completions/ssh @@ -266,12 +266,12 @@ _comp_cmd_ssh__configfile() set -- "${words[@]}" while (($# > 0)); do if [[ $1 == -F* ]]; then - local ret + local REPLY if ((${#1} > 2)); then - _comp_dequote "${1:2}" && configfile=$ret + _comp_dequote "${1:2}" && configfile=$REPLY else shift - [[ ${1-} ]] && _comp_dequote "$1" && configfile=$ret + [[ ${1-} ]] && _comp_dequote "$1" && configfile=$REPLY fi break fi @@ -377,10 +377,10 @@ _comp_cmd_ssh() elif [[ $cur == -* ]]; then _comp_compgen_usage else - local ret + local REPLY # Keep glob sort in sync with cases above _comp_count_args -n "=" -a "-*[BbcDeLpRWEFSIiJlmOoQw]" - if ((ret > 1)); then + if ((REPLY > 1)); then compopt -o filenames _comp_compgen_commands else diff --git a/completions/vncviewer b/completions/vncviewer index 8ea14e0e957..8b9a039c3aa 100644 --- a/completions/vncviewer +++ b/completions/vncviewer @@ -2,9 +2,9 @@ _comp_cmd_vncviewer__bootstrap() { - local fname ret + local fname REPLY _comp_realcommand vncviewer - case $ret in + case $REPLY in *xvnc4viewer) fname=_comp_cmd_xvnc4viewer ;; *tightvncviewer) fname=_comp_cmd_tightvncviewer ;; *) fname=_comp_complete_known_hosts ;; diff --git a/completions/xdg-mime b/completions/xdg-mime index acdd09851eb..ce3f9885d03 100644 --- a/completions/xdg-mime +++ b/completions/xdg-mime @@ -25,9 +25,9 @@ _comp_cmd_xdg_mime() local cur prev words cword comp_args _comp_initialize -- "$@" || return - local ret + local REPLY _comp_count_args - local args=$ret + local args=$REPLY if ((args == 1)); then if [[ $cur == -* ]]; then _comp_compgen -- -W '--help --manual --version' diff --git a/completions/xdg-settings b/completions/xdg-settings index 7d24a91e6db..df03222fdbf 100644 --- a/completions/xdg-settings +++ b/completions/xdg-settings @@ -16,11 +16,11 @@ _comp_cmd_xdg_settings() return fi - local ret + local REPLY _comp_count_args - if ((ret == 1)); then + if ((REPLY == 1)); then _comp_compgen -- -W "get check set" - elif ((ret == 2)); then + elif ((REPLY == 2)); then _comp_compgen_split -- "$("$1" --list | _comp_awk '!/^Known/ { print $1 }')" fi } && diff --git a/completions/xz b/completions/xz index c89b3afa3f0..8d6c53bdf6e 100644 --- a/completions/xz +++ b/completions/xz @@ -26,9 +26,9 @@ _comp_cmd_xz() return ;; --threads | -${noargopts}T) - local ret + local REPLY _comp_get_ncpus - _comp_compgen -- -W "{0..$ret}" + _comp_compgen -- -W "{0..$REPLY}" return ;; --memlimit | --memlimit-compress | --memlimit-decompress | --memory | \ diff --git a/completions/zopflipng b/completions/zopflipng index 0392502e07e..76a0c30d60a 100644 --- a/completions/zopflipng +++ b/completions/zopflipng @@ -27,9 +27,9 @@ _comp_cmd_zopflipng() if [[ ${words[*]} != *\ --prefix=* ]]; then # 2 png args only if --prefix not given - local ret + local REPLY _comp_count_args - ((ret < 3)) && _comp_compgen_filedir png + ((REPLY < 3)) && _comp_compgen_filedir png else # otherwise arbitrary number of png args _comp_compgen_filedir png diff --git a/doc/api-and-naming.md b/doc/api-and-naming.md index 93edc3dc7bf..ff05cb625a2 100644 --- a/doc/api-and-naming.md +++ b/doc/api-and-naming.md @@ -7,7 +7,7 @@ inject them to the `COMPREPLY` array variable, as required for completions to work. Most other functions make use of "output" variables, i.e. assign values to -them. The most common one of these is named `ret`. Consult the commentary +them. The most common one of these is named `REPLY`. Consult the commentary before each function in the source to find out the specific names. `local`izing output variables before invoking a function that populates them is the caller's responsibility. diff --git a/test/t/test_mutt.py b/test/t/test_mutt.py index 75d7d1c27a7..e5b6387ade1 100644 --- a/test/t/test_mutt.py +++ b/test/t/test_mutt.py @@ -9,7 +9,7 @@ class TestMutt: def functions(self, bash): assert_bash_exec( bash, - '_comp_test__muttconffiles() { local ret; _comp_cmd_mutt__get_conffiles "$@" && printf "%s\\n" "${ret[@]}"; }', + '_comp_test__muttconffiles() { local REPLY; _comp_cmd_mutt__get_conffiles "$@" && printf "%s\\n" "${REPLY[@]}"; }', ) @pytest.mark.complete("mutt -") diff --git a/test/t/unit/test_unit_abspath.py b/test/t/unit/test_unit_abspath.py index ff356ccae43..97d506cce3a 100644 --- a/test/t/unit/test_unit_abspath.py +++ b/test/t/unit/test_unit_abspath.py @@ -13,9 +13,9 @@ def functions(self, bash): bash, ( "__tester() { " - "local ret; " + "local REPLY; " '_comp_abspath "$1"; ' - 'printf %s "$ret"; ' + 'printf %s "$REPLY"; ' "}" ), ) @@ -24,7 +24,7 @@ def test_non_pollution(self, bash): """Test environment non-pollution, detected at teardown.""" assert_bash_exec( bash, - "foo() { local ret=; _comp_abspath bar; }; foo; unset -f foo", + "foo() { local REPLY=; _comp_abspath bar; }; foo; unset -f foo", want_output=None, ) diff --git a/test/t/unit/test_unit_command_offset.py b/test/t/unit/test_unit_command_offset.py index 573252664e6..94636dd7f8b 100644 --- a/test/t/unit/test_unit_command_offset.py +++ b/test/t/unit/test_unit_command_offset.py @@ -95,7 +95,7 @@ def find_original_word_functions(self, bash): assert_bash_exec( bash, "_comp_test_reassemble() {" - " local IFS=$' \\t\\n' ret;" + " local IFS=$' \\t\\n' REPLY;" ' COMP_LINE=$1; _comp_split COMP_WORDS "$2"; COMP_CWORD=$((${#COMP_WORDS[@]}-1));' " _comp__reassemble_words = words cword;" "}", @@ -103,9 +103,9 @@ def find_original_word_functions(self, bash): assert_bash_exec( bash, "_comp_test_1() {" - ' local COMP_WORDS COMP_LINE COMP_CWORD words cword ret; _comp_test_reassemble "$1" "$2";' + ' local COMP_WORDS COMP_LINE COMP_CWORD words cword REPLY; _comp_test_reassemble "$1" "$2";' ' _comp__find_original_word "$3";' - ' echo "$ret";' + ' echo "$REPLY";' "}", ) diff --git a/test/t/unit/test_unit_count_args.py b/test/t/unit/test_unit_count_args.py index 86444d04d49..7b018e4894a 100644 --- a/test/t/unit/test_unit_count_args.py +++ b/test/t/unit/test_unit_count_args.py @@ -5,14 +5,14 @@ @pytest.mark.bashcomp( cmd=None, - ignore_env=r"^[+-](ret|cword|words|COMP_(WORDS|CWORD|LINE|POINT))=", + ignore_env=r"^[+-](REPLY|cword|words|COMP_(WORDS|CWORD|LINE|POINT))=", ) class TestUnitCountArgs(TestUnitBase): @pytest.fixture def functions(self, bash): assert_bash_exec( bash, - '_comp__test_unit() { local -a words=(); local cword ret=""; _comp__reassemble_words "<>&" words cword; _comp_count_args "$@"; echo "$ret"; }', + '_comp__test_unit() { local -a words=(); local cword REPLY=""; _comp__reassemble_words "<>&" words cword; _comp_count_args "$@"; echo "$REPLY"; }', ) def _test(self, *args, **kwargs): diff --git a/test/t/unit/test_unit_dequote.py b/test/t/unit/test_unit_dequote.py index 954573fddc1..0ac814d9fa7 100644 --- a/test/t/unit/test_unit_dequote.py +++ b/test/t/unit/test_unit_dequote.py @@ -12,7 +12,7 @@ class TestDequote: def test_1_char(self, bash): assert_bash_exec( bash, - '__tester() { local ret=dummy v=var;_comp_dequote "$1";local ext=$?;((${#ret[@]}))&&printf \'<%s>\' "${ret[@]}";echo;return $ext;}', + '__tester() { local REPLY=dummy v=var;_comp_dequote "$1";local ext=$?;((${#REPLY[@]}))&&printf \'<%s>\' "${REPLY[@]}";echo;return $ext;}', ) output = assert_bash_exec(bash, "__tester a", want_output=True) assert output.strip() == "" diff --git a/test/t/unit/test_unit_expand_tilde.py b/test/t/unit/test_unit_expand_tilde.py index e9506b59ca9..3552fd63f95 100644 --- a/test/t/unit/test_unit_expand_tilde.py +++ b/test/t/unit/test_unit_expand_tilde.py @@ -14,7 +14,7 @@ def test_2(self, bash): """Test environment non-pollution, detected at teardown.""" assert_bash_exec( bash, - '_x() { local ret; _comp_expand_tilde "~"; }; _x; unset -f _x', + '_x() { local REPLY; _comp_expand_tilde "~"; }; _x; unset -f _x', ) @pytest.fixture(scope="class") @@ -23,7 +23,7 @@ def functions(self, bash): # latter but plain_tilde follows $HOME assert_bash_exec( bash, - '_comp__test_unit() { local ret HOME=$1; _comp_expand_tilde "$2"; printf "%s\\n" "$ret"; }', + '_comp__test_unit() { local REPLY HOME=$1; _comp_expand_tilde "$2"; printf "%s\\n" "$REPLY"; }', ) @pytest.mark.parametrize("plain_tilde", (True, False)) diff --git a/test/t/unit/test_unit_get_first_arg.py b/test/t/unit/test_unit_get_first_arg.py index 4e451116f86..415e2178728 100644 --- a/test/t/unit/test_unit_get_first_arg.py +++ b/test/t/unit/test_unit_get_first_arg.py @@ -9,7 +9,7 @@ class TestUnitGetFirstArg: def functions(self, bash): assert_bash_exec( bash, - '_comp__test_unit() { local -a "words=$1"; local cword=$2 ret=; shift 2; _comp_get_first_arg "$@" && printf "%s\\n" "$ret"; return 0; }', + '_comp__test_unit() { local -a "words=$1"; local cword=$2 REPLY=; shift 2; _comp_get_first_arg "$@" && printf "%s\\n" "$REPLY"; return 0; }', ) def _test(self, bash, words, cword, args=""): diff --git a/test/t/unit/test_unit_quote.py b/test/t/unit/test_unit_quote.py index f570cab5274..35087825224 100644 --- a/test/t/unit/test_unit_quote.py +++ b/test/t/unit/test_unit_quote.py @@ -11,7 +11,7 @@ class TestUnitQuote(TestUnitBase): def test_1(self, bash): assert_bash_exec( bash, - '__tester() { local ret; _comp_quote "$1"; printf %s "$ret"; }', + '__tester() { local REPLY; _comp_quote "$1"; printf %s "$REPLY"; }', ) output = assert_bash_exec( bash, '__tester "a b"', want_output=True, want_newline=False diff --git a/test/t/unit/test_unit_quote_compgen.py b/test/t/unit/test_unit_quote_compgen.py index 35e013275f6..faf23fed9ff 100644 --- a/test/t/unit/test_unit_quote_compgen.py +++ b/test/t/unit/test_unit_quote_compgen.py @@ -11,7 +11,7 @@ class TestUnitQuoteCompgen: def functions(self, bash): assert_bash_exec( bash, - '_comp__test_quote_compgen() { local ret; _comp_quote_compgen "$1"; printf %s "$ret"; }', + '_comp__test_quote_compgen() { local REPLY; _comp_quote_compgen "$1"; printf %s "$REPLY"; }', ) @pytest.mark.parametrize( @@ -117,13 +117,13 @@ def test_github_issue_492_3(self, bash, functions): """Test code execution through unintended pathname expansions When there is a file named "quote=$(COMMAND)" (for - _comp_compgen_filedir) or "ret=$(COMMAND)" (for _comp_quote_compgen), + _comp_compgen_filedir) or "REPLY=$(COMMAND)" (for _comp_quote_compgen), the completion of the word '$* results in the execution of COMMAND. $ echo '$*[TAB] """ - os.mkdir("./ret=$(echo injected >&2)") + os.mkdir("./REPLY=$(echo injected >&2)") assert_bash_exec(bash, "_comp__test_quote_compgen $'\\'$*' >/dev/null") def test_github_issue_492_4(self, bash, functions): diff --git a/test/t/unit/test_unit_realcommand.py b/test/t/unit/test_unit_realcommand.py index 7c1e9f83940..4eb7b737109 100644 --- a/test/t/unit/test_unit_realcommand.py +++ b/test/t/unit/test_unit_realcommand.py @@ -13,10 +13,10 @@ def functions(self, bash): bash, ( "__tester() { " - "local ret rc; " + "local REPLY rc; " '_comp_realcommand "$1"; ' "rc=$?; " - 'printf %s "$ret"; ' + 'printf %s "$REPLY"; ' "return $rc; " "}" ), @@ -26,7 +26,7 @@ def test_non_pollution(self, bash): """Test environment non-pollution, detected at teardown.""" assert_bash_exec( bash, - "foo() { local ret=; _comp_realcommand bar; }; foo; unset -f foo", + "foo() { local REPLY=; _comp_realcommand bar; }; foo; unset -f foo", want_output=None, )