summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2013-02-01 20:17:03 +0200
committerVille Skyttä <ville.skytta@iki.fi>2013-02-01 20:17:03 +0200
commitb78ef321bedfdf8071627366de74451967846f98 (patch)
tree09258627404f955a18736f744de67f69bdfec050
parent19ce23282ca6c00b482ac8044b64d91dbb3b62e6 (diff)
downloadbash-completion-b78ef321bedfdf8071627366de74451967846f98.tar.gz
_mac_addresses: Try local interfaces with "ip link" if ifconfig is N/A.
-rw-r--r--bash_completion11
1 files changed, 7 insertions, 4 deletions
diff --git a/bash_completion b/bash_completion
index 869218fc..d56644f8 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