Skip to content

Commit 0d0531b

Browse files
committed
fix(timeout): always treat word after duration as command
The current implementation skips option-like words even after a duration argument is seen. This patch always uses the next word of the duration argument as command name for `_comp_command_offset`.
1 parent a12f438 commit 0d0531b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

completions/timeout

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22

33
_comp_cmd_timeout()
44
{
5-
local cur prev words cword was_split comp_args i found=""
5+
local cur prev words cword was_split comp_args i
66
_comp_initialize -s -- "$@" || return
77

88
local noargopts='!(-*|*[ks]*)'
9-
for ((i = 1; i <= cword; i++)); do
9+
for ((i = 1; i < cword; i++)); do
1010
if [[ ${words[i]} != -* ]]; then
11-
if [[ $found ]]; then
12-
_comp_command_offset $i
13-
return
14-
fi
15-
found=set
11+
_comp_command_offset "$((i + 1))"
12+
return
1613
fi
1714
# shellcheck disable=SC2254
1815
[[ ${words[i]} == -@(-kill-after|-signal|${noargopts}[ks]) ]] && ((i++))

0 commit comments

Comments
 (0)