Skip to content

Commit 7fba87c

Browse files
authored
docs(api-and-naming): use REPLY for return variable instead of ret (#987)
#537 (comment)
1 parent 00ef82b commit 7fba87c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+353
-345
lines changed

bash_completion

Lines changed: 73 additions & 73 deletions
Large diffs are not rendered by default.

bash_completion.d/000_bash_completion_compat.bash

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ have()
5858

5959
# This function shell-quotes the argument
6060
# @deprecated 2.12 Use `_comp_quote` instead. Note that `_comp_quote` stores
61-
# the results in the variable `ret` instead of writing them to stdout.
61+
# the results in the variable `REPLY` instead of writing them to stdout.
6262
quote()
6363
{
6464
local quoted=${1//\'/\'\\\'\'}
@@ -68,33 +68,33 @@ quote()
6868
# @deprecated 2.12 Use `_comp_quote_compgen`
6969
quote_readline()
7070
{
71-
local ret
71+
local REPLY
7272
_comp_quote_compgen "$1"
73-
printf %s "$ret"
73+
printf %s "$REPLY"
7474
}
7575

7676
# This function is the same as `_comp_quote_compgen`, but receives the second
7777
# argument specifying the variable name to store the result.
7878
# @param $1 Argument to quote
7979
# @param $2 Name of variable to return result to
8080
# @deprecated 2.12 Use `_comp_quote_compgen "$1"` instead. Note that
81-
# `_comp_quote_compgen` stores the result in a fixed variable `ret`.
81+
# `_comp_quote_compgen` stores the result in a fixed variable `REPLY`.
8282
_quote_readline_by_ref()
8383
{
84-
[[ $2 == ret ]] || local ret
84+
[[ $2 == REPLY ]] || local REPLY
8585
_comp_quote_compgen "$1"
86-
[[ $2 == ret ]] || printf -v "$2" %s "$ret"
86+
[[ $2 == REPLY ]] || printf -v "$2" %s "$REPLY"
8787
}
8888

8989
# This function shell-dequotes the argument
9090
# @deprecated 2.12 Use `_comp_dequote' instead. Note that `_comp_dequote`
91-
# stores the results in the array `ret` instead of writing them to stdout.
91+
# stores the results in the array `REPLY` instead of writing them to stdout.
9292
dequote()
9393
{
94-
local ret
94+
local REPLY
9595
_comp_dequote "$1"
9696
local rc=$?
97-
printf %s "$ret"
97+
printf %s "$REPLY"
9898
return $rc
9999
}
100100

@@ -198,14 +198,14 @@ _get_pword()
198198

199199
# Get real command.
200200
# @deprecated 2.12 Use `_comp_realcommand` instead.
201-
# Note that `_comp_realcommand` stores the result in the variable `ret`
201+
# Note that `_comp_realcommand` stores the result in the variable `REPLY`
202202
# instead of writing it to stdout.
203203
_realcommand()
204204
{
205-
local ret
205+
local REPLY
206206
_comp_realcommand "$1"
207207
local rc=$?
208-
printf "%s\n" "$ret"
208+
printf "%s\n" "$REPLY"
209209
return $rc
210210
}
211211

@@ -328,14 +328,14 @@ _parse_help()
328328
if [[ $1 == - ]]; then
329329
args=(-)
330330
else
331-
local ret opt IFS=$' \t\n'
331+
local REPLY opt IFS=$' \t\n'
332332
_comp_dequote "$1"
333333
_comp_split opt "${2:---help}"
334-
args=(-c "$ret" ${opt[@]+"${opt[@]}"})
334+
args=(-c "$REPLY" ${opt[@]+"${opt[@]}"})
335335
fi
336-
local -a ret=()
337-
_comp_compgen -Rv ret help "${args[@]}" || return 1
338-
((${#ret[@]})) && printf '%s\n' "${ret[@]}"
336+
local -a REPLY=()
337+
_comp_compgen -Rv REPLY help "${args[@]}" || return 1
338+
((${#REPLY[@]})) && printf '%s\n' "${REPLY[@]}"
339339
return 0
340340
}
341341

@@ -352,23 +352,23 @@ _parse_usage()
352352
if [[ $1 == - ]]; then
353353
args=(-)
354354
else
355-
local ret opt IFS=$' \t\n'
355+
local REPLY opt IFS=$' \t\n'
356356
_comp_dequote "$1"
357357
_comp_split opt "${2:---usage}"
358-
args=(-c "$ret" ${opt[@]+"${opt[@]}"})
358+
args=(-c "$REPLY" ${opt[@]+"${opt[@]}"})
359359
fi
360-
local -a ret=()
361-
_comp_compgen -Rv ret usage "${args[@]}" || return 1
362-
((${#ret[@]})) && printf '%s\n' "${ret[@]}"
360+
local -a REPLY=()
361+
_comp_compgen -Rv REPLY usage "${args[@]}" || return 1
362+
((${#REPLY[@]})) && printf '%s\n' "${REPLY[@]}"
363363
return 0
364364
}
365365

366366
# @deprecated 2.12 Use `_comp_get_ncpus`.
367367
_ncpus()
368368
{
369-
local ret
369+
local REPLY
370370
_comp_get_ncpus
371-
printf %s "$ret"
371+
printf %s "$REPLY"
372372
}
373373

374374
# Expand variable starting with tilde (~).
@@ -381,14 +381,14 @@ _ncpus()
381381
#
382382
# @deprecated 2.12 Use `_comp_expand_tilde`. The new function receives the
383383
# value instead of a variable name as $1 and always returns the result to the
384-
# variable `ret`.
384+
# variable `REPLY`.
385385
__expand_tilde_by_ref()
386386
{
387387
[[ ${1+set} ]] || return 0
388-
[[ $1 == ret ]] || local ret
388+
[[ $1 == REPLY ]] || local REPLY
389389
_comp_expand_tilde "${!1-}"
390390
# shellcheck disable=SC2059
391-
[[ $1 == ret ]] || printf -v "$1" "$ret"
391+
[[ $1 == REPLY ]] || printf -v "$1" "$REPLY"
392392
}
393393

394394
# @deprecated 2.12 Use `_comp_compgen -a cd_devices`
@@ -449,7 +449,7 @@ _fstypes()
449449
# @deprecated 2.12 Use `_comp_get_first_arg`. Note that the new function
450450
# `_comp_get_first_arg` operates on `words` and `cword` instead of `COMP_WORDS`
451451
# and `COMP_CWORD`. The new function considers a command-line argument after
452-
# `--` as an argument. The new function returns the result in variable `ret`
452+
# `--` as an argument. The new function returns the result in variable `REPLY`
453453
# instead of `arg`.
454454
_get_first_arg()
455455
{
@@ -471,7 +471,7 @@ _get_first_arg()
471471
# @param $3 glob Options that should be counted as args
472472
# @var[out] args Return the number of arguments
473473
# @deprecated 2.12 Use `_comp_count_args`. Note that the new function
474-
# `_comp_count_args` returns the result in variable `ret` instead of `args`.
474+
# `_comp_count_args` returns the result in variable `REPLY` instead of `args`.
475475
# In the new function, `-` is also counted as an argument. The new function
476476
# counts all the arguments after `--`.
477477
# shellcheck disable=SC2178 # assignments are not intended for global "args"

completions/2to3

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ _comp_cmd_2to3()
1616
return
1717
;;
1818
-j | --processes)
19-
local ret
19+
local REPLY
2020
_comp_get_ncpus
21-
_comp_compgen -- -W "{1..$ret}"
21+
_comp_compgen -- -W "{1..$REPLY}"
2222
return
2323
;;
2424
-o | --output-dir)

completions/7z

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ _comp_cmd_7z()
8484
return
8585
fi
8686

87-
local ret
87+
local REPLY
8888
_comp_count_args
89-
if ((ret == 2)); then
89+
if ((REPLY == 2)); then
9090
_comp_compgen_filedir_xspec unzip
9191
# TODO: parsing 7z i output?
9292
# - how to figure out if the format is input or output?

completions/Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,9 +1222,9 @@ install-data-hook: ss = $(SETUP_SYMLINKS) $(DESTDIR)$(bashcompdir)
12221222
install-data-hook: symlinks
12231223

12241224
check-local:
1225-
ret=0; \
1225+
REPLY=0; \
12261226
for file in $(bashcomp_DATA); do \
12271227
$${bashcomp_bash:-$${BASH:-bash}} \
1228-
-O extglob -n $(srcdir)/$$file || ret=$$?; \
1228+
-O extglob -n $(srcdir)/$$file || REPLY=$$?; \
12291229
done; \
1230-
exit $$ret
1230+
exit $$REPLY

completions/_cal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ _comp_cmd_cal()
2828
return
2929
fi
3030

31-
local ret
31+
local REPLY
3232
_comp_count_args
33-
((ret == 1)) && _comp_compgen -- -W '{1..12}'
33+
((REPLY == 1)) && _comp_compgen -- -W '{1..12}'
3434
} &&
3535
complete -F _comp_cmd_cal cal ncal
3636

completions/_umount.linux

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ _comp_cmd_umount__reply_compgen_array()
1515
# argument.
1616
local i wlist
1717
for i in ${!COMPREPLY[*]}; do
18-
local ret
19-
printf -v ret %q "${COMPREPLY[i]}"
20-
_comp_quote "$ret"
21-
wlist+=$ret$'\n'
18+
local REPLY
19+
printf -v REPLY %q "${COMPREPLY[i]}"
20+
_comp_quote "$REPLY"
21+
wlist+=$REPLY$'\n'
2222
done
2323

2424
# We also have to add another round of escaping to $cur.

completions/_xm

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ _comp_cmd_xm()
1717

1818
# TODO: split longopt
1919

20-
local ret command commands options
20+
local REPLY command commands options
2121

2222
commands='console vncviewer create new delete destroy domid domname
2323
dump-core list mem-max mem-set migrate pause reboot rename reset
@@ -80,15 +80,15 @@ _comp_cmd_xm()
8080
vcpu-list | vcpu-pin | vcpu-set | block-list | \
8181
network-list | vtpm-list)
8282
_comp_count_args
83-
case $ret in
83+
case $REPLY in
8484
2)
8585
_comp_cmd_xm__domain_names
8686
;;
8787
esac
8888
;;
8989
migrate)
9090
_comp_count_args
91-
case $ret in
91+
case $REPLY in
9292
2)
9393
_comp_cmd_xm__domain_names
9494
;;
@@ -102,7 +102,7 @@ _comp_cmd_xm()
102102
;;
103103
save)
104104
_comp_count_args
105-
case $ret in
105+
case $REPLY in
106106
2)
107107
_comp_cmd_xm__domain_names
108108
;;
@@ -113,7 +113,7 @@ _comp_cmd_xm()
113113
;;
114114
sysrq)
115115
_comp_count_args
116-
case $ret in
116+
case $REPLY in
117117
2)
118118
_comp_cmd_xm__domain_names
119119
;;
@@ -124,7 +124,7 @@ _comp_cmd_xm()
124124
;;
125125
block-attach)
126126
_comp_count_args
127-
case $ret in
127+
case $REPLY in
128128
2)
129129
_comp_cmd_xm__domain_names
130130
;;
@@ -141,7 +141,7 @@ _comp_cmd_xm()
141141
;;
142142
block-detach)
143143
_comp_count_args
144-
case $ret in
144+
case $REPLY in
145145
2)
146146
_comp_cmd_xm__domain_names
147147
;;
@@ -153,7 +153,7 @@ _comp_cmd_xm()
153153
;;
154154
network-attach)
155155
_comp_count_args
156-
case $ret in
156+
case $REPLY in
157157
2)
158158
_comp_cmd_xm__domain_names
159159
;;
@@ -165,7 +165,7 @@ _comp_cmd_xm()
165165
;;
166166
network-detach)
167167
_comp_count_args
168-
case $ret in
168+
case $REPLY in
169169
2)
170170
_comp_cmd_xm__domain_names
171171
;;
@@ -202,7 +202,7 @@ _comp_cmd_xm()
202202
esac
203203

204204
_comp_count_args
205-
case $ret in
205+
case $REPLY in
206206
2)
207207
_comp_cmd_xm__domain_names
208208
;;

completions/ant

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _comp_cmd_ant__targets()
99
# parse buildfile for targets
1010
while read -rd '>' line; do
1111
if [[ $line =~ \<(target|extension-point)[[:space:]].*name=[\"\']([^\"\']+) ]]; then
12-
ret+=("${BASH_REMATCH[2]}")
12+
REPLY+=("${BASH_REMATCH[2]}")
1313
fi
1414
done <"$1"
1515

@@ -87,12 +87,12 @@ _comp_cmd_ant()
8787
fi
8888
[[ ! -f $buildfile ]] && return
8989

90-
local ret=()
90+
local REPLY=()
9191

9292
# fill targets
9393
_comp_cmd_ant__targets "$buildfile"
9494

95-
_comp_compgen -- -W '"${ret[@]}"'
95+
_comp_compgen -- -W '"${REPLY[@]}"'
9696
fi
9797
} &&
9898
complete -F _comp_cmd_ant ant phing

completions/arp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ _comp_cmd_arp()
3333
return
3434
fi
3535

36-
local ret
36+
local REPLY
3737
_comp_count_args -a "@(--device|--protocol|--file|--hw-type|-${noargopts}[iApfHt])"
38-
case $ret in
38+
case $REPLY in
3939
1)
4040
local ips=$("$1" -an | command sed -ne \
4141
's/.*(\([0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}\)).*/\1/p')

0 commit comments

Comments
 (0)