about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-02-26 15:30:18 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-02-26 15:30:18 +0000
commit8a411bf1c9215e075b755f2bcb40b3a033a53b91 (patch)
tree14f592b7fc08fcf09ba0f3e6371bf0d5b5640c4d
parent37bada4bf1248c92b31ef48eae28081047c53ce1 (diff)
downloadzsh-8a411bf1c9215e075b755f2bcb40b3a033a53b91.tar.gz
zsh-8a411bf1c9215e075b755f2bcb40b3a033a53b91.tar.xz
zsh-8a411bf1c9215e075b755f2bcb40b3a033a53b91.zip
23190: tweak _net_interfaces for Linux
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Unix/Type/_net_interfaces15
2 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 7319b235b..4dec8bdfc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-02-26  Peter Stephenson  <pws@csr.com>
 
+	* 23190: Completion/Unix/Type/_net_interfaces: use ifconfig
+	on Linux and fall back to old method in order to pick up
+	additional interface types.
+
 	* unposted: Completion/Unix/Commands/_ip: tweak ip route
 	show abbreviations.
 
diff --git a/Completion/Unix/Type/_net_interfaces b/Completion/Unix/Type/_net_interfaces
index dc7898c3d..682d8c5a8 100644
--- a/Completion/Unix/Type/_net_interfaces
+++ b/Completion/Unix/Type/_net_interfaces
@@ -14,8 +14,19 @@ case $OSTYPE in
   ;;
   darwin*|freebsd*|dragonfly*) intf=( $(ifconfig -l) ) ;;
   irix*) intf=( ${${${(f)"$(/usr/etc/netstat -i)"}%% *}[2,-1]} ) ;;
-  linux*) intf=( /proc/sys/net/ipv4/conf/*~*(all|default)(N:t) ) ;;
-  *) intf=( $(ifconfig -a|sed -n 's/^\([^ 	:]*\).*/\1/p') ) ;;
+
+  *)
+  # Make sure ifconfig is in the path.
+  local PATH=$PATH
+  PATH=/sbin:$PATH
+  intf=( $(ifconfig -a 2>/dev/null | sed -n 's/^\([^ 	:]*\).*/\1/p') )
+  if [[${#intf} -eq 0 &&  -d /proc/sys/net/ipv4/conf ]]; then
+    # On linux we used to use the following as the default.
+    # However, we now use ifconfig since it finds additional devices such
+    # as tunnels.  So only do this if that didn't work.
+    intf=( /proc/sys/net/ipv4/conf/*~*(all|default)(N:t) )
+  fi
+  ;;
 esac
 
 _wanted interfaces expl 'network interface' \