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

This commit is contained in:
Ville Skyttä 2013-02-01 20:40:49 +02:00
parent aa516acdc5
commit 3064e9d707

View File

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