[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 2.0-101-gb78ef32

Ville Skyttä ville.skytta at iki.fi
Fri Feb 1 18:17:58 UTC 2013


The following commit has been merged in the master branch:
commit b78ef321bedfdf8071627366de74451967846f98
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Fri Feb 1 20:17:03 2013 +0200

    _mac_addresses: Try local interfaces with "ip link" if ifconfig is N/A.

diff --git a/bash_completion b/bash_completion
index 869218f..d56644f 100644
--- a/bash_completion
+++ b/bash_completion
@@ -821,12 +821,15 @@ _mac_addresses()
     local re='\([A-Fa-f0-9]\{2\}:\)\{5\}[A-Fa-f0-9]\{2\}'
     local PATH="$PATH:/sbin:/usr/sbin"
 
-    # Local interfaces (Linux: HWaddr or ether, FreeBSD: ether)
-    COMPREPLY+=( $( ifconfig -a 2>/dev/null | sed -ne \
+    # Local interfaces
+    # - ifconfig on Linux: HWaddr or ether
+    # - ifconfig on FreeBSD: ether
+    # - ip link: link/ether
+    COMPREPLY+=( $( { ifconfig -a || ip link show; } 2>/dev/null | sed -ne \
         "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]].*/\1/p" -ne \
         "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" -ne \
-        "s/.*[[:space:]]ether[[:space:]]\{1,\}\($re\)[[:space:]].*/\1/p" -ne \
-        "s/.*[[:space:]]ether[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p"
+        "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]].*|\2|p" -ne \
+        "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]]*$|\2|p"
         ) )
 
     # ARP cache

-- 
bash-completion



More information about the Bash-completion-commits mailing list