From dd60228fb054bcc7ad1f222d1de6c7f351c00069 Mon Sep 17 00:00:00 2001 From: Zoran Dzelajlija Date: Mon, 30 Jan 2006 13:15:15 +0000 Subject: [PATCH] r96: ispravna verzija bugfixa za visestruke default route. --- functions.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/functions.sh b/functions.sh index a50c280..84af780 100644 --- a/functions.sh +++ b/functions.sh @@ -88,15 +88,19 @@ cp_get_ifdefault() { RET="" case $1 in - dev) RET=`route -n | \ - awk 'BEGIN {m = 2^32} - /^0.0.0.0\b/{if ($5 < m) {r = $8; m = $5}} - END {print r}'` - addr) RET=`route -n | \ - awk 'BEGIN {m = 2^32} - /^0.0.0.0\b/{if ($5 < m) {r = $2; m = $5}} - END {print r}'` - *) echo "cp_get_ifdefault: Argument required (dev or addr)" >&2 ;; + dev) + RET=`route -n | awk 'BEGIN {m = 2^32} + /^0\.0\.0\.0[ \t]/ {if ($5 < m) {r = $8; m = $5}} + END {print r}'` + ;; + addr) + RET=`route -n | awk 'BEGIN {m = 2^32} + /^0\.0\.0\.0[ \t]/ {if ($5 < m) {r = $2; m = $5}} + END {print r}'` + ;; + *) + echo "cp_get_ifdefault: Argument required (dev or addr)" >&2 + ;; esac [ -z "$RET" -a "$1" ] && echo "cp_get_ifdefault: No default route" >&2 -- 1.7.10.4