about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Unix/Type/_bind_addresses15
2 files changed, 19 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 68766f9d0..ce6eedb21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2006-10-03  Clint Adams  <clint@zsh.org>
 
+	* 22811: R. Ramkumar: Completion/Unix/Type/_bind_addresses:
+	helper function to give local IP addresses to which a program
+	might bind a socket.
+
 	* 22810: Completion/Unix/Command/_gpg: fix malformed
 	--encrypt-to line.
 
diff --git a/Completion/Unix/Type/_bind_addresses b/Completion/Unix/Type/_bind_addresses
new file mode 100644
index 000000000..606de3ffb
--- /dev/null
+++ b/Completion/Unix/Type/_bind_addresses
@@ -0,0 +1,15 @@
+#autoload
+
+local expl
+
+case $OSTYPE in
+  aix*) _hosts "$@" ;;
+  darwin*|freebsd*|dragonfly*) _hosts "$@" ;;
+  irix*) _hosts "$@" ;;
+  # Couldn't find anything special for linux except for /proc/net/dev
+  # Is there any proc file which gives the formatted ip?
+  linux*) ;&
+  *)
+    _wanted bind-addresses expl 'bind address' compadd "$@" - \
+      ${${${(M)${(f)"$(ifconfig -a)"}:#*addr:*}##*addr:}%% *}
+esac