about summary refs log tree commit diff
path: root/Functions/TCP
diff options
context:
space:
mode:
Diffstat (limited to 'Functions/TCP')
-rw-r--r--Functions/TCP/tcp_open31
1 files changed, 23 insertions, 8 deletions
diff --git a/Functions/TCP/tcp_open b/Functions/TCP/tcp_open
index cd1afed28..60bcb5e5d 100644
--- a/Functions/TCP/tcp_open
+++ b/Functions/TCP/tcp_open
@@ -180,6 +180,29 @@ for sess in $sessnames; do
     tcp_by_name[$sess]=$fd
 
     [[ -o zle && -z $nozle ]] && zle -F $fd tcp_fd_handler
+
+    # needed for new completion system, so I'm not too sanguine
+    # about requiring this here...
+    if zmodload -i zsh/parameter; then
+	if (( ${+functions[tcp_on_open]} )); then
+	    if ! tcp_on_open $sess $fd; then
+	        if [[ -z $quiet ]]; then
+		    if (( ${#sessargs} )); then
+		        print "Session $sess" \
+"(host $sessargs[1], port $sessargs[2] fd $fd): tcp_on_open FAILED."
+		    else
+		        print "Session $sess (fd $fd) tcp_on_open FAILED."
+		    fi
+		    tcp_close -- $sess
+		else
+		    tcp_close -q -- $sess
+	        fi
+		stat=1
+		continue
+	    fi
+	fi
+    fi
+
     if [[ -z $quiet ]]; then
 	if (( ${#sessargs} )); then
 	    print "Session $sess" \
@@ -188,14 +211,6 @@ for sess in $sessnames; do
 	    print "Session $sess (fd $fd) opened OK."
 	fi
     fi
-
-    # needed for new completion system, so I'm not too sanguine
-    # about requiring this here...
-    if zmodload -i zsh/parameter; then
-	if (( ${+functions[tcp_on_open]} )); then
-	    tcp_on_open $sess $fd
-	fi
-    fi
 done
 
 if [[ -z $TCP_SESS ]]; then