zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _find_net_interfaces: use /sys/class/net/* for interface names in linux
@ 2015-08-11  0:49 Eric Cook
  2015-08-11  9:47 ` Oliver Kiddle
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Cook @ 2015-08-11  0:49 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-12  0:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-11  0:49 [PATCH] _find_net_interfaces: use /sys/class/net/* for interface names in linux Eric Cook
2015-08-11  9:47 ` Oliver Kiddle
2015-08-11 13:27   ` Eric Cook
2015-08-12  0:25   ` Eric Cook

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).