summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2012-01-12 20:38:31 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2012-01-12 20:38:31 -0800
commite7649f117af827a855baeaa2fc72a5cf1a09f31c (patch)
tree64aa36a5fea3cd62d344c78fd05b054ce8d88caf /net
parent66f4305e1cb596c3243a67e83beed0cb6d973eb8 (diff)
downloadopenrc-e7649f117af827a855baeaa2fc72a5cf1a09f31c.tar.gz
openrc-e7649f117af827a855baeaa2fc72a5cf1a09f31c.tar.bz2
openrc-e7649f117af827a855baeaa2fc72a5cf1a09f31c.tar.xz
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>
Diffstat (limited to 'net')
-rw-r--r--net/iproute2.sh35
1 files changed, 23 insertions, 12 deletions
diff --git a/net/iproute2.sh b/net/iproute2.sh
index 9b89352..09912bf 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -101,24 +101,35 @@ _add_address()
ip addr add "$@" dev "${IFACE}" 2>/dev/null
return 0
fi
-
+ local x
local address netmask broadcast peer anycast label scope
local valid_lft preferred_lft home nodad
local confflaglist
address="$1" ; shift
while [ -n "$*" ]; do
- case "$1" in
- netmask)
- netmask="/$(_netmask2cidr "$2")" ; shift ; shift ;;
- broadcast|brd)
- broadcast="$2" ; shift ; shift ;;
- pointopoint|pointtopoint|peer)
- peer="$2" ; shift ; shift ;;
- anycast|label|scope|valid_lft|preferred_lft)
- eval "$1=$2" ; shift ; shift ;;
- home|nodad)
+ x=$1 ; shift
+ case "$x" in
+ netmask|ne*)
+ netmask="/$(_netmask2cidr "$1")" ; shift ;;
+ broadcast|brd|br*)
+ broadcast="$1" ; shift ;;
+ pointopoint|pointtopoint|peer|po*|pe*)
+ peer="$1" ; shift ;;
+ anycast|label|scope|valid_lft|preferred_lft|a*|l*|s*|v*|pr*)
+ 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
- confflaglist="${confflaglist} $1" ; shift ;;
+ confflaglist="${confflaglist} $x" ; ;;
+ *)
+ ewarn "Unknown argument to config_$IFACE: $x"
esac
done