Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: tcp_on_open return status
- X-seq: zsh-workers 25237
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: tcp_on_open return status
- Date: Mon, 23 Jun 2008 14:36:47 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
This enhances the TCP function handlers so that a bad return status from
tcp_on_open causes the open to fail. This is actually an
incompatibility, but I doubt if enough people are using the system to
make this a significant problem.
Index: Doc/Zsh/tcpsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/tcpsys.yo,v
retrieving revision 1.13
diff -u -r1.13 tcpsys.yo
--- Doc/Zsh/tcpsys.yo 29 May 2008 12:51:19 -0000 1.13
+++ Doc/Zsh/tcpsys.yo 23 Jun 2008 13:35:05 -0000
@@ -71,6 +71,7 @@
In the second case, one or more sessions to be opened are given by name.
A single session name is given after tt(-s) and a comma-separated list
after tt(-l); both options may be repeated as many times as necessary.
+A failure to open any session causes tt(tcp_open) to abort.
The host and port are read from the file tt(.ztcp_sessions) in the same
directory as the user's zsh initialisation files, i.e. usually the home
directory, but tt($ZDOTDIR) if that is set. The file consists of lines
@@ -117,6 +118,9 @@
calls to tt(tcp_open) do not change it. The current session is stored
in the parameter tt($TCP_SESS); see below for more detail about the
parameters used by the system.
+
+The function tt(tcp_on_open), if defined, is called when a session
+is opened. See the description below.
)
findex(tcp_close)
item(tt(tcp_close [-qn] [ -a | -l) var(sess)tt(,... |) var(sess) tt(... ]))(
@@ -483,7 +487,10 @@
findex(tcp_on_open)
item(tt(tcp_on_open) var(sess) var(fd))(
This is called after a new session has been defined with the session name
-and file descriptor as arguments.
+and file descriptor as arguments. If it returns a non-zero status,
+opening the session is assumed to fail and the session is closed
+again; however, tt(tcp_open) will continue to attempt to open any
+remaining sessions given on the command line.
)
findex(tcp_on_rename)
item(tt(tcp_on_rename) var(oldsess) var(fd) var(newsess))(
Index: Functions/TCP/tcp_open
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/TCP/tcp_open,v
retrieving revision 1.4
diff -u -r1.4 tcp_open
--- Functions/TCP/tcp_open 8 Aug 2005 16:49:10 -0000 1.4
+++ Functions/TCP/tcp_open 23 Jun 2008 13:35:05 -0000
@@ -180,6 +180,29 @@
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 @@
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
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author