From a3ad33daf96db36ac4aeb57f8db10562f5393d65 Mon Sep 17 00:00:00 2001 From: Norbert Lange Date: Fri, 7 Dec 2018 16:12:06 +0100 Subject: [PATCH] net-lib: remove calls to ip with -oneline option busybox seems to not properly support this option, and it can be be safely ommitted or replaced with piping the output through head. Rev 2: * rebased on master * addressed open points from review --- modules.d/40network/net-lib.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh index 964ed3ab..19a2fa53 100755 --- a/modules.d/40network/net-lib.sh +++ b/modules.d/40network/net-lib.sh @@ -14,20 +14,20 @@ is_ip() { get_ip() { local iface="$1" ip="" - ip=$(ip -o -f inet addr show $iface) + ip=$(ip -f inet addr show $iface) ip=${ip%%/*} ip=${ip##* } echo $ip } iface_for_remote_addr() { - set -- $(ip -o route get to $1) - echo $5 + set -- $(ip route get to $1 | sed 's/.*\bdev\b//p;q') + echo $1 } iface_for_ip() { - set -- $(ip -o addr show to $1) - echo $2 + set -- $(ip addr show to $1) + echo ${2%:} } iface_for_mac() { @@ -593,7 +593,7 @@ wait_for_if_link() { timeout=$(($timeout*10)) while [ $cnt -lt $timeout ]; do - li=$(ip -o link show dev $1 2>/dev/null) + li=$(ip link show dev $1 2>/dev/null) [ -n "$li" ] && return 0 sleep 0.1 cnt=$(($cnt+1)) @@ -609,7 +609,7 @@ wait_for_if_up() { timeout=$(($timeout*10)) while [ $cnt -lt $timeout ]; do - li=$(ip -o link show up dev $1) + li=$(ip link show up dev $1) if [ -n "$li" ]; then case "$li" in *\