Skip to content

Commit 06bfe23

Browse files
akinomyogascop
andcommitted
fix(_command_offset): receive index in COMP_WORDS through compat name
Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
1 parent eaad33a commit 06bfe23

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

bash_completion

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,6 +2353,12 @@ _comp_command_offset()
23532353
#
23542354
_comp_command()
23552355
{
2356+
# We unset the shell variable `words` locally to tell
2357+
# `_comp_command_offset` that the index is intended to be that in
2358+
# `COMP_WORDS` instead of `words`.
2359+
local words
2360+
unset -v words
2361+
23562362
local offset i
23572363

23582364
# find actual offset, as position of the first non-option

bash_completion.d/000_bash_completion_compat.bash

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,17 @@ _cd()
245245
_comp_cmd_cd "$@"
246246
}
247247

248+
# @deprecated Use `_comp_command_offset` instead. Note that the new interface
249+
# `_comp_command_offset` is changed to receive an index in `words` instead of
250+
# that in `COMP_WORDS` as `_command_offset` did.
251+
_command_offset()
252+
{
253+
# We unset the shell variable `words` locally to tell
254+
# `_comp_command_offset` that the index is intended to be that in
255+
# `COMP_WORDS` instead of `words`.
256+
local words
257+
unset -v words
258+
_comp_command_offset "$@"
259+
}
260+
248261
# ex: filetype=sh

0 commit comments

Comments
 (0)