about summary refs log tree commit diff
path: root/Functions/TCP
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-05-29 12:51:15 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-05-29 12:51:15 +0000
commit6c6ce048e71e80b3b64b7339df7162398287c99f (patch)
tree5979d8e585c048a34fc0d7b28b7264005df2ee4d /Functions/TCP
parentc4679383109f8e4f93c13b1eb30d352503b943e0 (diff)
downloadzsh-6c6ce048e71e80b3b64b7339df7162398287c99f.tar.gz
zsh-6c6ce048e71e80b3b64b7339df7162398287c99f.tar.xz
zsh-6c6ce048e71e80b3b64b7339df7162398287c99f.zip
Tomasz Pala <gotar@polanet.pl>: users/12884:
new completions for iftop and tcpdump
Diffstat (limited to 'Functions/TCP')
-rw-r--r--Functions/TCP/tcp_fd_handler26
1 files changed, 15 insertions, 11 deletions
diff --git a/Functions/TCP/tcp_fd_handler b/Functions/TCP/tcp_fd_handler
index 8774a2666..9f2e8cd09 100644
--- a/Functions/TCP/tcp_fd_handler
+++ b/Functions/TCP/tcp_fd_handler
@@ -1,6 +1,6 @@
-local line name=${tcp_by_fd[$1]}
+local line fd=$1 sess=${tcp_by_fd[$1]}
 local TCP_HANDLER_ACTIVE=1
-if [[ -n $name ]]
+if [[ -n $sess ]]
 then
   local TCP_INVALIDATE_ZLE
   if (( $# > 2 )); then
@@ -10,10 +10,14 @@ then
   else
     TCP_INVALIDATE_ZLE=1
   fi
-  if ! tcp_read -d -u $1; then
+  if ! tcp_read -d -u $fd; then
+    if (( ${+functions[tcp_on_awol]} )); then
+      tcp_on_awol $sess $fd
+      (( $? == 100 )) || return $?
+    fi
     [[ -n $TCP_INVALIDATE_ZLE ]] && zle -I
-    print "[TCP fd $1 (session $name) gone awol; removing from poll list]" >& 2
-    zle -F $1
+    print "[TCP fd $fd (session $sess) gone awol; removing from poll list]" >& 2
+    zle -F $fd
     return 1
   fi
   return 0
@@ -21,16 +25,16 @@ else
   zle -I
   # Handle fds not in the TCP set similarly.
   # This does the drain thing, to try and get as much data out as possible.
-  if ! read -u $1 line; then
-    print "[Reading on $1 failed; removing from poll list]" >& 2
-    zle -F $1
+  if ! read -u $fd line; then
+    print "[Reading on $fd failed; removing from poll list]" >& 2
+    zle -F $fd
     return 1
   fi
-  line="fd$1:$line"
+  line="fd$fd:$line"
   local newline
-  while read -u $1 -t newline; do
+  while read -u $fd -t newline; do
     line="${line}
-fd$1:$newline"
+fd$fd:$newline"
   done
 fi
 print -r - $line