diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2008-06-23 13:38:09 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2008-06-23 13:38:09 +0000 |
commit | 0d7df628a47f4d944a266fe547d1db3c6b55b6f1 (patch) | |
tree | d6f64308dfdf429f6d62908f9ddb0ca81ae8ac0d | |
parent | 4f9c07dc05d25b8b4abf1d6e9886cebd9b5ed7bf (diff) | |
download | zsh-0d7df628a47f4d944a266fe547d1db3c6b55b6f1.tar.gz zsh-0d7df628a47f4d944a266fe547d1db3c6b55b6f1.tar.xz zsh-0d7df628a47f4d944a266fe547d1db3c6b55b6f1.zip |
25237: TCP function system: make tcp_on_open return status significant
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Doc/Zsh/tcpsys.yo | 9 | ||||
-rw-r--r-- | Functions/TCP/tcp_open | 31 |
3 files changed, 34 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog index a75d568f3..77551ef16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/Doc/Zsh/tcpsys.yo b/Doc/Zsh/tcpsys.yo index 9d05a5ce6..d592f77c9 100644 --- a/Doc/Zsh/tcpsys.yo +++ b/Doc/Zsh/tcpsys.yo @@ -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))( 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 |