mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
25237: TCP function system: make tcp_on_open return status significant
This commit is contained in:
parent
4f9c07dc05
commit
0d7df628a4
3 changed files with 34 additions and 9 deletions
|
@ -1,5 +1,8 @@
|
|||
2008-06-23 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 25237: Doc/Zsh/tcpsys.yo, Functions/TCP/tcp_open: make
|
||||
tcp_on_open return status significant.
|
||||
|
||||
* 25236: Doc/Zsh/contrib.yo, Functions/MIME/zsh-mime-setup:
|
||||
zsh-mime-setup -l can take suffix arguments.
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ alphanumerics or underscores, and certainly do include whitespace.
|
|||
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 @@ The first session to be opened becomes the current session and subsequent
|
|||
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 @@ the time the function is called.
|
|||
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))(
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue