5
0
mirror of https://github.com/ArduPilot/ardupilot synced 2025-01-05 15:38:29 -04:00

Tools: completion bash: correct word reuse skipping

This commit is contained in:
Pierre Kancir 2020-04-03 17:38:17 +02:00 committed by Andrew Tridgell
parent 3262175f86
commit 5736e28693
3 changed files with 42 additions and 34 deletions
Tools/completion/bash

View File

@ -37,6 +37,14 @@ _ap_bin()
opts+=" --sim-port-in"
opts+=" --sim-port-out"
opts+=" --irlock-port"
# Prevent word reuse
lim=$((COMP_CWORD - 1))
for i in $(seq 0 $lim); do
if [[ $opts == *"${COMP_WORDS[i]}"* ]]; then
opts=${opts//${COMP_WORDS[i]}/}
opts=${opts//--${COMP_WORDS[i]}/}
fi
done
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
}

View File

@ -55,8 +55,8 @@ _sim_vehicle() {
lim=$((COMP_CWORD - 1))
for i in $(seq 0 $lim); do
if [[ $opts == *"${COMP_WORDS[i]}"* ]]; then
opts=${opts/" ${COMP_WORDS[i]}"/}
opts=${opts/" --${COMP_WORDS[i]}"/}
opts=${opts//${COMP_WORDS[i]}/}
opts=${opts//--${COMP_WORDS[i]}/}
fi
done

View File

@ -46,8 +46,8 @@ _waf()
for i in $( seq 0 $lim )
do
if [[ $opts == *"${COMP_WORDS[i]}"* ]]; then
opts=${opts/" ${COMP_WORDS[i]}"}
opts=${opts/" --${COMP_WORDS[i]}"}
opts=${opts//${COMP_WORDS[i]}/}
opts=${opts//--${COMP_WORDS[i]}/}
fi
done