From 2087e14b8e7874dd7581c78e6b06c55daf538630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 22 Aug 2021 09:53:31 +0200 Subject: [PATCH] testgetifaddr.sh: Always use the first IP addr from 'ip -4 addr' Terminate the awk after getting the first interface name and IP address from 'ip -4 addr' output. Otherwise, the test fails if the interface in question has multiple IP addresses, as the test program returns the first address, while awk prints all. --- miniupnpd/testgetifaddr.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/miniupnpd/testgetifaddr.sh b/miniupnpd/testgetifaddr.sh index 90a9628..2a26a24 100755 --- a/miniupnpd/testgetifaddr.sh +++ b/miniupnpd/testgetifaddr.sh @@ -12,8 +12,8 @@ case $OS in *) IP="`which ip`" || exit 1 EXTIF="`LC_ALL=C $IP -4 route | grep 'default' | sed -e 's/.*dev[[:space:]]*//' -e 's/[[:space:]].*//'`" || exit 1 - EXTIF="`LC_ALL=C $IP -4 addr show $EXTIF | awk '/[0-9]+:/ { print $2 }' | cut -d ":" -f 1`" - EXTIP="`LC_ALL=C $IP -4 addr show $EXTIF | awk '/inet/ { print $2 }' | cut -d "/" -f 1`" + EXTIF="`LC_ALL=C $IP -4 addr show $EXTIF | awk '/[0-9]+:/ { print $2; exit 0 }' | cut -d ":" -f 1`" + EXTIP="`LC_ALL=C $IP -4 addr show $EXTIF | awk '/inet/ { print $2; exit 0 }' | cut -d "/" -f 1`" ;; esac