From 3064e9d707404e5aa59bb8b643d02208fb0f9daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 1 Feb 2013 20:40:49 +0200 Subject: [PATCH] _available_interfaces: Without -a, try with "ip link" if ifconfig is N/A. --- bash_completion | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bash_completion b/bash_completion index 4b581966..ea8ee507 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" ) ) }