net/iproute2: Handle shortened arguments

Allow users to shorten iproute arguments to the shortest unique argument
that will match a flag of iproute2.

X-Gentoo-Bug: 398721
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=398721

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
This commit is contained in:
Robin H. Johnson 2012-01-12 20:38:31 -08:00
parent 66f4305e1c
commit e7649f117a

View File

@ -101,24 +101,35 @@ _add_address()
ip addr add "$@" dev "${IFACE}" 2>/dev/null ip addr add "$@" dev "${IFACE}" 2>/dev/null
return 0 return 0
fi fi
local x
local address netmask broadcast peer anycast label scope local address netmask broadcast peer anycast label scope
local valid_lft preferred_lft home nodad local valid_lft preferred_lft home nodad
local confflaglist local confflaglist
address="$1" ; shift address="$1" ; shift
while [ -n "$*" ]; do while [ -n "$*" ]; do
case "$1" in x=$1 ; shift
netmask) case "$x" in
netmask="/$(_netmask2cidr "$2")" ; shift ; shift ;; netmask|ne*)
broadcast|brd) netmask="/$(_netmask2cidr "$1")" ; shift ;;
broadcast="$2" ; shift ; shift ;; broadcast|brd|br*)
pointopoint|pointtopoint|peer) broadcast="$1" ; shift ;;
peer="$2" ; shift ; shift ;; pointopoint|pointtopoint|peer|po*|pe*)
anycast|label|scope|valid_lft|preferred_lft) peer="$1" ; shift ;;
eval "$1=$2" ; shift ; shift ;; anycast|label|scope|valid_lft|preferred_lft|a*|l*|s*|v*|pr*)
home|nodad) case $x in
a*) x=anycast ;;
l*) x=label ;;
s*) x=scope ;;
v*) x=valid_lft ;;
pr*) x=preferred_lft ;;
esac
eval "$x=$1" ; shift ;;
home|nodad|h*|no*)
case $x in h*) x=home ;; n*) x=nodad ;; esac
# FIXME: If we need to reorder these, this will take more code # FIXME: If we need to reorder these, this will take more code
confflaglist="${confflaglist} $1" ; shift ;; confflaglist="${confflaglist} $x" ; ;;
*)
ewarn "Unknown argument to config_$IFACE: $x"
esac esac
done done