From 4f303ecb27967c8fcd1a1c16236beee4dd50ddd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gross?= Date: Wed, 30 May 2012 17:46:46 +0200 Subject: [PATCH] Fix ifconfig output parsing against various OSes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien Gross --- conf/explorer/ifaces | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/conf/explorer/ifaces b/conf/explorer/ifaces index e5fd8a45..64ab8aa7 100755 --- a/conf/explorer/ifaces +++ b/conf/explorer/ifaces @@ -20,19 +20,22 @@ # # List all network interfaces in explorer/ifaces. One interface per line. # +# If your OS is not supported please provide a ifconfig output +# uname_s="$(uname -s)" -case "$uname_s" in - Linux) - ifconfig | sed -n 's/^\([^[:space:]]\+\)[[:space:]].*/\1/p' - exit 0 - ;; - Darwin|*BSD) - ifconfig | sed -n 's/^\([^:]*\): flags.*/\1/p' - exit 0 - ;; -esac +REGEXP='s/^(.*)(:[[:space:]]*flags=|Link encap).*/\1/p' -echo "Unknown OS" >&2 -exit 1 +case "$uname_s" in + Darwin) + ifconfig -a | sed -n -E "$REGEXP" + ;; + Linux|*BSD) + ifconfig -a | sed -n -r "$REGEXP" + ;; + *) + echo "Unsupported ifconfig output for $uname_s" >&2 + exit 1 + ;; +esac