From: Norbert Lange Date: Fri, 7 Dec 2018 15:12:06 +0000 (+0100) Subject: net-lib: remove calls to ip with -oneline option X-Git-Tag: 050~148^2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F500%2Fhead;p=thirdparty%2Fdracut.git 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 --- diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh index 964ed3ab8..19a2fa53a 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 *\