[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 2.0-103-g3064e9d

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


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

    _available_interfaces: Without -a, try with "ip link" if ifconfig is N/A.

diff --git a/bash_completion b/bash_completion
index 4b58196..ea8ee50 100644
--- a/bash_completion
+++ b/bash_completion
@@ -896,18 +896,19 @@ _kernel_versions()
 #
 _available_interfaces()
 {
-    local cmd
+    local cmd PATH=$PATH:/sbin
 
     if [[ ${1:-} == -w ]]; then
         cmd="iwconfig"
     elif [[ ${1:-} == -a ]]; then
+        # TODO: the corresponding ip link one
         cmd="ifconfig"
     else
-        cmd="ifconfig -a"
+        cmd="{ ifconfig -a || ip link show; }"
     fi
 
-    COMPREPLY=( $( eval PATH="$PATH:/sbin" $cmd 2>/dev/null | \
-        awk '/^[^ \t]/ { print $1 }' ) )
+    COMPREPLY=( $( eval $cmd 2>/dev/null | awk \
+        '/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }' ) )
     COMPREPLY=( $( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" ) )
 }
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list