Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] _find_net_interfaces: use /sys/class/net/* for interface names in linux



ip(8) seems to add a suffix to the interface name for certain interface
types. The ones i've noticed are macvtaps, macvlans and recently
bridges.

% ip link add link eth0 name tap0 address 00:22:33:44:55:66 \
type macvtap mode bridge

or with iproute2 4.0.x:
% ip link add br0 type bridge

% ip link show <tab> # will show @eth0 or @NONE appended to tap0 or br0.

There doesn't seem to be a option to suppress that behavior and @ is a
legal character for interface names. So chopping off suffix with more
parameter expansion doesn't seem like the correct thing to do.

I also wasn't able to find the type of tunnels mentioned in
http://www.zsh.org/mla/workers/2007/msg00111.html that doesn't show up
in /proc/sys/net/ipv4/conf/. Maybe at some point since then, that was
fixed. But to avoid some kind of regression /sys/class/net/ seems usable
for the time being.
---
 Completion/Unix/Type/_find_net_interfaces | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Completion/Unix/Type/_find_net_interfaces b/Completion/Unix/Type/_find_net_interfaces
index 0c70335..f90f310 100644
--- a/Completion/Unix/Type/_find_net_interfaces
+++ b/Completion/Unix/Type/_find_net_interfaces
@@ -23,7 +23,7 @@ case $OSTYPE in
   irix*) net_intf_list=( ${${${(f)"$(/usr/etc/netstat -i)"}%% *}[2,-1]} ) ;;
   *linux*)
     if (( $+commands[ip] )); then
-      net_intf_list=( ${${(m)${(f)"$(ip -o link)"}#*: }%%: *} )
+      net_intf_list=( /sys/class/net/*(N:t)  )
     fi
   ;&
 
-- 
2.5.0



Messages sorted by: Reverse Date, Date, Thread, Author