zsh-workers
 help / color / mirror / code / Atom feed
From: Eric Cook <llua@gmx.com>
To: zsh-workers@zsh.org
Subject: [PATCH] _find_net_interfaces: use /sys/class/net/* for interface names in linux
Date: Mon, 10 Aug 2015 20:49:03 -0400	[thread overview]
Message-ID: <1439254143-4608-1-git-send-email-llua@gmx.com> (raw)

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


             reply	other threads:[~2015-08-11  0:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-11  0:49 Eric Cook [this message]
2015-08-11  9:47 ` Oliver Kiddle
2015-08-11 13:27   ` Eric Cook
2015-08-12  0:25   ` Eric Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439254143-4608-1-git-send-email-llua@gmx.com \
    --to=llua@gmx.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).