mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
Tools: completion bash: correct word reuse skipping
This commit is contained in:
parent
3262175f86
commit
5736e28693
@ -37,6 +37,14 @@ _ap_bin()
|
|||||||
opts+=" --sim-port-in"
|
opts+=" --sim-port-in"
|
||||||
opts+=" --sim-port-out"
|
opts+=" --sim-port-out"
|
||||||
opts+=" --irlock-port"
|
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}) )
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ _sim_vehicle() {
|
|||||||
lim=$((COMP_CWORD - 1))
|
lim=$((COMP_CWORD - 1))
|
||||||
for i in $(seq 0 $lim); do
|
for i in $(seq 0 $lim); do
|
||||||
if [[ $opts == *"${COMP_WORDS[i]}"* ]]; then
|
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
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ _waf()
|
|||||||
for i in $( seq 0 $lim )
|
for i in $( seq 0 $lim )
|
||||||
do
|
do
|
||||||
if [[ $opts == *"${COMP_WORDS[i]}"* ]]; then
|
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
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user