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

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

Eric Cook wrote:
> 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.

One example, is aliases. So if you do something like
  ifconfig eth0:1
then ifconfig will show eth0:1 while /sys/class won't.

There may be cases where we don't want to complete those, however.

> 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
>    ;&

The (( $+commands[ip] )) isn't really applicable after that change.

Also did you notice that we still have the following further down in the
    if [[ -d /proc/sys/net/ipv4/conf ]]; then
      # On linux we used to use the following as the default.
      # However, we now use ip or ifconfig since it finds additional devices such
      # as tunnels.  So only do this if that didn't work.
      net_intf_list=( /proc/sys/net/ipv4/conf/*~*(all|default)(N:t) )

I think the /proc path there will work for older Linux installations
than the /sys path you use and it still works with new systems.


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