mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-25 05:10:28 +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>
|
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:
|
* 25236: Doc/Zsh/contrib.yo, Functions/MIME/zsh-mime-setup:
|
||||||
zsh-mime-setup -l can take suffix arguments.
|
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.
|
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
|
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.
|
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
|
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 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
|
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
|
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
|
in the parameter tt($TCP_SESS); see below for more detail about the
|
||||||
parameters used by the system.
|
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)
|
findex(tcp_close)
|
||||||
item(tt(tcp_close [-qn] [ -a | -l) var(sess)tt(,... |) var(sess) tt(... ]))(
|
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)
|
findex(tcp_on_open)
|
||||||
item(tt(tcp_on_open) var(sess) var(fd))(
|
item(tt(tcp_on_open) var(sess) var(fd))(
|
||||||
This is called after a new session has been defined with the session name
|
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)
|
findex(tcp_on_rename)
|
||||||
item(tt(tcp_on_rename) var(oldsess) var(fd) var(newsess))(
|
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
|
tcp_by_name[$sess]=$fd
|
||||||
|
|
||||||
[[ -o zle && -z $nozle ]] && zle -F $fd tcp_fd_handler
|
[[ -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 [[ -z $quiet ]]; then
|
||||||
if (( ${#sessargs} )); then
|
if (( ${#sessargs} )); then
|
||||||
print "Session $sess" \
|
print "Session $sess" \
|
||||||
|
|
@ -188,14 +211,6 @@ for sess in $sessnames; do
|
||||||
print "Session $sess (fd $fd) opened OK."
|
print "Session $sess (fd $fd) opened OK."
|
||||||
fi
|
fi
|
||||||
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
|
done
|
||||||
|
|
||||||
if [[ -z $TCP_SESS ]]; then
|
if [[ -z $TCP_SESS ]]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue