From b63b1e7346c98bbb2c45db0c008c86be2c96935c Mon Sep 17 00:00:00 2001 From: jankkm Date: Fri, 22 Mar 2024 12:11:38 +0100 Subject: [PATCH] More than single digit enXX ethernet devices Allow ethernet devices higher than en9 --- src/helpers.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/helpers.sh b/src/helpers.sh index 39a3262..f6241df 100755 --- a/src/helpers.sh +++ b/src/helpers.sh @@ -60,10 +60,7 @@ getWifiName() { # $1 = networksetup -listallhardwareports # $! = String getEthernetName() { - local LIST=${1-$(networksetup -listallhardwareports)} - local DETAILS=$(echo "$LIST" | grep -A 2 -E "$ETHERNET_REGEX") - local ADAPTER=$(echo "$DETAILS" | grep "Device:" | sed -e 's/^Device: \(en[0-9]\{1,3\}\)$/\1/') - echo $(networksetup -listnetworkserviceorder | sed -n "/Device: $ADAPTER)$/{x;p;d;}; x" | sed -e 's/^([0-9]*) \(.*\)$/\1/') + echo $(networksetup -listnetworkserviceorder | sed -n "/Device: $(getEthernetInterface))$/{x;p;d;}; x" | sed -e 's/^([0-9]*) \(.*\)$/\1/') } # Get wifi interface name @@ -81,7 +78,7 @@ getWifiInterface() { getEthernetInterface() { local LIST=${1-$(networksetup -listallhardwareports)} local DETAILS=$(echo "$LIST" | grep -A 2 -E "$ETHERNET_REGEX") - echo "$DETAILS" | grep -m 1 -o -e en[0-9] + echo "$DETAILS" | grep -m 1 -o -e 'en[0-9]\{1,3\}' } # Get wifi mac address