about summary refs log tree commit diff
path: root/Completion/Unix
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-11-11 23:16:26 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-11-11 23:16:26 +0000
commite41e00f4c896385568eb64fddc8a1ca0691ab79e (patch)
treec96468f2c3e0ac091901d7cfcba4d8350a7bb48a /Completion/Unix
parentc68317f5ebd65552dd2c5450b6f45f99ed3ce75c (diff)
downloadzsh-e41e00f4c896385568eb64fddc8a1ca0691ab79e.tar.gz
zsh-e41e00f4c896385568eb64fddc8a1ca0691ab79e.tar.xz
zsh-e41e00f4c896385568eb64fddc8a1ca0691ab79e.zip
Merge of 23190: tweak _net_interfaces for Linux.
Diffstat (limited to 'Completion/Unix')
-rw-r--r--Completion/Unix/Type/_net_interfaces15
1 files changed, 13 insertions, 2 deletions
diff --git a/Completion/Unix/Type/_net_interfaces b/Completion/Unix/Type/_net_interfaces
index dc7898c3d..666287259 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' \