Skip to content

Commit 27eb6c2

Browse files
committed
refactor: rename _quote_readline_by_ref => _comp_quote_compgen
1 parent b1d163e commit 27eb6c2

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

bash_completion

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ _comp_quote()
135135
ret=\'${1//\'/\'\\\'\'}\'
136136
}
137137

138-
# @see _quote_readline_by_ref()
138+
# @see _comp_quote_compgen()
139139
quote_readline()
140140
{
141141
local ret
142-
_quote_readline_by_ref "$1" ret
142+
_comp_quote_compgen "$1" ret
143143
printf %s "$ret"
144144
} # quote_readline()
145145

@@ -637,7 +637,7 @@ __ltrim_colon_completions()
637637
# - https://www.mail-archive.com/[email protected]/msg01944.html
638638
# @param $1 Argument to quote
639639
# @param $2 Name of variable to return result to
640-
_quote_readline_by_ref()
640+
_comp_quote_compgen()
641641
{
642642
if [[ $1 == \'* ]]; then
643643
# Leave out first character
@@ -656,7 +656,7 @@ _quote_readline_by_ref()
656656
local "$2" && _comp_upvars -v "$2" "$value"
657657
fi
658658
fi
659-
} # _quote_readline_by_ref()
659+
} # _comp_quote_compgen()
660660

661661
# This function performs file and directory completion. It's better than
662662
# simply using 'compgen -f', because it honours spaces in filenames.
@@ -682,7 +682,7 @@ _filedir()
682682
IFS=$'\n'
683683
else
684684
local quoted
685-
_quote_readline_by_ref "${cur-}" quoted
685+
_comp_quote_compgen "${cur-}" quoted
686686

687687
# Munge xspec to contain uppercase version too
688688
# https://lists.gnu.org/archive/html/bug-bash/2010-09/msg00036.html

bash_completion.d/000_bash_completion_compat.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ _comp_deprecate_func _upvars _comp_upvars
1313
_comp_deprecate_func __reassemble_comp_words_by_ref _comp__reassemble_words
1414
_comp_deprecate_func __get_cword_at_cursor_by_ref _comp__get_cword_at_cursor
1515
_comp_deprecate_func _get_comp_words_by_ref _comp_get_words
16+
_comp_deprecate_func _quote_readline_by_ref _comp_quote_compgen
1617

1718
# Backwards compatibility for compat completions that use have().
1819
# @deprecated should no longer be used; generally not needed with dynamically

test/t/unit/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ EXTRA_DIST = \
2121
test_unit_pids.py \
2222
test_unit_pnames.py \
2323
test_unit_quote.py \
24-
test_unit_quote_readline.py \
24+
test_unit_quote_compgen.py \
2525
test_unit_split.py \
2626
test_unit_tilde.py \
2727
test_unit_unlocal.py \

test/t/unit/test_unit_quote_readline.py renamed to test/t/unit/test_unit_quote_compgen.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
@pytest.mark.bashcomp(cmd=None, temp_cwd=True)
9-
class TestUnitQuoteReadline:
9+
class TestUnitQuoteCompgen:
1010
def test_exec(self, bash):
1111
assert_bash_exec(bash, "quote_readline '' >/dev/null")
1212

@@ -36,9 +36,9 @@ def test_github_issue_492_1(self, bash):
3636
Reported at https://github.com/scop/bash-completion/pull/492
3737
3838
Arbitrary commands could be unintendedly executed by
39-
_quote_readline_by_ref. In the following example, the command
40-
"touch 1.txt" would be unintendedly created before the fix. The file
41-
"1.txt" should not be created by completion on the following line:
39+
_comp_quote_compgen. In the following example, the command "touch
40+
1.txt" would be unintendedly created before the fix. The file "1.txt"
41+
should not be created by completion on the following line:
4242
4343
$ echo '$(touch file.txt)[TAB]
4444
@@ -97,10 +97,10 @@ def test_github_issue_526_1(self, bash):
9797
Ref [2] https://github.com/scop/bash-completion/pull/526
9898
9999
The escape sequences in the local variable of "value" in
100-
"_quote_readline_by_ref" needs to be unescaped by passing it to printf
101-
as the format string. This causes a problem in the following case
102-
[where the spaces after "alpha\" is a TAB character inserted in the
103-
command string by "C-v TAB"]:
100+
"_comp_quote_compgen" needs to be unescaped by passing it to printf as
101+
the format string. This causes a problem in the following case [where
102+
the spaces after "alpha\" is a TAB character inserted in the command
103+
string by "C-v TAB"]:
104104
105105
$ echo alpha\ b[TAB]
106106

0 commit comments

Comments
 (0)