Skip to content

Commit 9a7f4a3

Browse files
committed
pinctrl: completion: Careful with the current word
If the last word on the line doesn't have a trailing space then it should still be considered for completion. Be careful to avoid looking at the final element in COMP_WORDS to ensure that happens. Signed-off-by: Phil Elwell <[email protected]>
1 parent 8bf9919 commit 9a7f4a3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pinctrl/pinctrl-completion.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ _pinctrl ()
66
_init_completion -s || return;
77

88
i=1
9-
while [[ ${COMP_WORDS[$i]} =~ ^- ]]; do
9+
while [[ $i -lt $cword && ${COMP_WORDS[$i]} =~ ^- ]]; do
1010
arg=${COMP_WORDS[$i]}
1111
if [[ "$arg" == "-c" ]]; then
1212
chip=${COMP_WORDS[$((i + 1))]}
@@ -19,7 +19,7 @@ _pinctrl ()
1919
fi
2020
done
2121

22-
if [[ ${COMP_WORDS[$i]} =~ ^(get|set|funcs|poll|help) ]]; then
22+
if [[ $i -lt $cword && ${COMP_WORDS[$i]} =~ ^(get|set|funcs|poll|help) ]]; then
2323
cmd=${COMP_WORDS[$i]}
2424
i=$((i + 1))
2525
elif [[ ${COMP_WORDS[$i]} =~ ^[A-Z0-9] ]]; then
@@ -70,7 +70,7 @@ _pinctrl ()
7070
CHIPS=($(pinctrl -v -p 0 | grep 'gpios)' | cut -d' ' -f4 | sort | uniq))
7171
chips="${CHIPS[@]}"
7272
COMPREPLY+=($(compgen -W "$chips" -- $cur))
73-
elif [[ "$cur" == "-" ]]; then
73+
elif [[ "$cur" =~ ^- ]]; then
7474
COMPREPLY+=($(compgen -W "-p -h -v -c" -- $cur))
7575
elif [[ "$chip" == "" ]]; then
7676
COMPREPLY+=($(compgen -W "get set poll funcs help" -- $cur))

0 commit comments

Comments
 (0)