route(1) completion code cleanups.
This commit is contained in:
parent
774d50a9c9
commit
50b4b8459f
@ -84,23 +84,18 @@ _route()
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COMPREPLY=( $( compgen -W 'add del -host -net netmask metric mss \
|
# Remove already given options from completions
|
||||||
window irtt reject mod dyn reinstate dev \
|
local i found
|
||||||
default gw' -- "$cur" ) )
|
for opt in add del -host -net netmask metric mss window irtt reject mod \
|
||||||
|
dyn reinstate dev default gw; do
|
||||||
COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \
|
found=false
|
||||||
(while read -d ' ' i; do
|
for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do
|
||||||
[ "$i" == "" ] && continue
|
[ "${COMP_WORDS[i]}" = "$opt" ] && found=true && break
|
||||||
# flatten array with spaces on either side,
|
|
||||||
# otherwise we cannot grep on word
|
|
||||||
# boundaries of first and last word
|
|
||||||
COMPREPLY=" ${COMPREPLY[@]} "
|
|
||||||
# remove word from list of completions
|
|
||||||
COMPREPLY=( ${COMPREPLY/ $i / } )
|
|
||||||
done
|
done
|
||||||
echo "${COMPREPLY[@]}")
|
$found || COMPREPLY[${#COMPREPLY[@]}]="$opt"
|
||||||
) )
|
done
|
||||||
return 0
|
|
||||||
|
COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) )
|
||||||
} &&
|
} &&
|
||||||
complete -F _route route
|
complete -F _route route
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user