Skip to content

Commit a2d8ac2

Browse files
committed
refactor: avoid using deprecated _get_[pc]word
1 parent c2a87cc commit a2d8ac2

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

completions/ssh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,10 @@ _ssh_suboption()
217217
_comp_xfunc_ssh_suboption_check()
218218
{
219219
# Get prev and cur words without splitting on =
220-
local cureq=$(_get_cword :=) preveq=$(_get_pword :=)
221-
if [[ $cureq == *=* && $preveq == -*o ]]; then
222-
_ssh_suboption "$cureq" "${1-}"
220+
local cur prev
221+
_comp_get_comp_words_by_ref -n := cur prev
222+
if [[ $cur == *=* && $prev == -*o ]]; then
223+
_ssh_suboption "$cur" "${1-}"
223224
return $?
224225
fi
225226
return 1

completions/xsltproc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ _xsltproc()
3434
;;
3535
esac
3636

37-
[[ $cword -gt 2 && $(_get_cword '' 2) == --?(string)param ]] && return
37+
[[ $cword -gt 2 && ${words[cword - 2]} == --?(string)param ]] && return
3838

3939
if [[ $cur == -* ]]; then
4040
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))

test/t/test_umount.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def dummy_mnt(self, request, bash):
1919
assert_bash_exec(
2020
bash,
2121
"_mnt_completion() { "
22-
"local cur=$(_get_cword); "
23-
"_comp_cmd_umount__linux_fstab $(_get_pword) < mount/test-fstab; "
22+
"local cur prev;_comp_get_comp_words_by_ref cur prev; "
23+
'_comp_cmd_umount__linux_fstab "$prev" < mount/test-fstab; '
2424
"} && complete -F _mnt_completion _mnt",
2525
)
2626
request.addfinalizer(

test/t/unit/test_unit_filedir.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ class TestUnitFiledir:
1515
def functions(self, request, bash):
1616
assert_bash_exec(
1717
bash,
18-
"_f() { local cur=$(_get_cword); unset -v COMPREPLY; _filedir; }; "
18+
"_f() { local cur;_comp_get_comp_words_by_ref cur; unset -v COMPREPLY; _filedir; }; "
1919
"complete -F _f f; "
2020
"complete -F _f -o filenames f2",
2121
)
2222
assert_bash_exec(
2323
bash,
24-
"_g() { local cur=$(_get_cword); unset -v COMPREPLY; _filedir e1; }; "
24+
"_g() { local cur;_comp_get_comp_words_by_ref cur; unset -v COMPREPLY; _filedir e1; }; "
2525
"complete -F _g g",
2626
)
2727
assert_bash_exec(
2828
bash,
29-
"_fd() { local cur=$(_get_cword); unset -v COMPREPLY; _filedir -d; };"
29+
"_fd() { local cur;_comp_get_comp_words_by_ref cur; unset -v COMPREPLY; _filedir -d; };"
3030
"complete -F _fd fd",
3131
)
3232

test/t/unit/test_unit_get_comp_words_by_ref.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def test_22(self, bash):
134134
def test_23(self, bash):
135135
"""a -n|
136136
137-
This test makes sure `_get_cword' doesn't use `echo' to return its
138-
value, because -n might be interpreted by `echo' and thus would not
139-
be returned.
137+
This test makes sure `_comp_get_comp_words_by_ref' doesn't use
138+
`echo' to return its value, because -n might be interpreted by
139+
`echo' and thus would not be returned.
140140
"""
141141
output = self._test(bash, "(a -n)", 1, "a -n", 4)
142142
assert output == "-n,a"

test/t/unit/test_unit_ip_addresses.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ class TestUnitIpAddresses:
99
def functions(self, request, bash):
1010
assert_bash_exec(
1111
bash,
12-
"_ia() { local cur=$(_get_cword);unset -v COMPREPLY;"
13-
"_ip_addresses; }",
12+
"_ia() { local cur;_comp_get_comp_words_by_ref cur;"
13+
"unset -v COMPREPLY;_ip_addresses; }",
1414
)
1515
assert_bash_exec(bash, "complete -F _ia ia")
1616
assert_bash_exec(
1717
bash,
18-
"_iaa() { local cur=$(_get_cword);unset -v COMPREPLY;"
19-
"_ip_addresses -a; }",
18+
"_iaa() { local cur;_comp_get_comp_words_by_ref cur;"
19+
"unset -v COMPREPLY;_ip_addresses -a; }",
2020
)
2121
assert_bash_exec(bash, "complete -F _iaa iaa")
2222
assert_bash_exec(
2323
bash,
24-
" _ia6() { local cur=$(_get_cword);unset -v COMPREPLY;"
25-
"_ip_addresses -6; }",
24+
" _ia6() { local cur;_comp_get_comp_words_by_ref cur;"
25+
"unset -v COMPREPLY;_ip_addresses -6; }",
2626
)
2727
assert_bash_exec(bash, "complete -F _ia6 ia6")
2828

0 commit comments

Comments
 (0)