@@ -139,7 +139,7 @@ _comp_quote()
139
139
quote_readline ()
140
140
{
141
141
local ret
142
- _comp_quote_compgen " $1 " ret
142
+ _comp_quote_compgen " $1 "
143
143
printf %s " $ret "
144
144
} # quote_readline()
145
145
@@ -624,7 +624,7 @@ __ltrim_colon_completions()
624
624
625
625
# This function quotes the argument in a way so that readline dequoting
626
626
# results in the original argument. This is necessary for at least
627
- # `compgen' which requires its arguments quoted/escaped:
627
+ # `compgen` which requires its arguments quoted/escaped:
628
628
#
629
629
# $ ls "a'b/"
630
630
# c
@@ -635,25 +635,25 @@ __ltrim_colon_completions()
635
635
# See also:
636
636
# - https://lists.gnu.org/archive/html/bug-bash/2009-03/msg00155.html
637
637
# - https://www.mail-archive.com/[email protected] /msg01944.html
638
- # @param $1 Argument to quote
639
- # @param $2 Name of variable to return result to
638
+ # @param $1 Argument to quote
639
+ # @var[out] ret Quoted result is stored in this variable
640
+ # shellcheck disable=SC2178 # The assignment is not intended for the global "ret"
640
641
_comp_quote_compgen ()
641
642
{
642
643
if [[ $1 == \' * ]]; then
643
644
# Leave out first character
644
- printf -v " $2 " %s " $ {1: 1}"
645
+ ret= $ {1: 1}
645
646
else
646
- printf -v " $2 " %q " $1 "
647
+ printf -v ret %q " $1 "
647
648
648
649
# If result becomes quoted like this: $'string', re-evaluate in order
649
650
# to drop the additional quoting. See also:
650
651
# https://www.mail-archive.com/[email protected] /msg01942.html
651
- if [[ ${ ! 2} == \$\' * \' ]]; then
652
- local value=${! 2 : 2:- 1} # Strip beginning $' and ending '.
653
- value=${value// ' %' /%% } # Escape % for printf format.
652
+ if [[ $ret == \$\' * \' ]]; then
653
+ local value=${ret : 2:- 1} # Strip beginning $' and ending '.
654
+ value=${value// ' %' /%% } # Escape % for printf format.
654
655
# shellcheck disable=SC2059
655
- printf -v value " $value " # Decode escape sequences of \....
656
- local " $2 " && _comp_upvars -v " $2 " " $value "
656
+ printf -v ret " $value " # Decode escape sequences of \....
657
657
fi
658
658
fi
659
659
} # _comp_quote_compgen()
@@ -681,8 +681,9 @@ _filedir()
681
681
$reset
682
682
IFS=$' \n '
683
683
else
684
- local quoted
685
- _comp_quote_compgen " ${cur-} " quoted
684
+ local ret
685
+ _comp_quote_compgen " ${cur-} "
686
+ local quoted=$ret
686
687
687
688
# Munge xspec to contain uppercase version too
688
689
# https://lists.gnu.org/archive/html/bug-bash/2010-09/msg00036.html
0 commit comments