From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: PATCH: tcp_send -c
Date: Tue, 08 Aug 2006 12:24:27 +0100 [thread overview]
Message-ID: <200608081124.k78BOR7g007020@news01.csr.com> (raw)
Minor addition to tcp_send I realised I needed now I have a scope I can
programme remotely...
Index: Doc/Zsh/tcpsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/tcpsys.yo,v
retrieving revision 1.9
diff -u -r1.9 tcpsys.yo
--- Doc/Zsh/tcpsys.yo 20 Mar 2006 11:06:25 -0000 1.9
+++ Doc/Zsh/tcpsys.yo 8 Aug 2006 11:22:27 -0000
@@ -185,13 +185,18 @@
See tt(tcp_log) for how to control where data is sent by tt(tcp_read).
)
findex(tcp_send)
-xitem(tt(tcp_send [-nq] [ -s) var(sess) tt(| -l) var(sess)tt(,... ]) var(data) tt(...))
-item(tt(tcp_send [-nq] -a) var(data) tt(...))(
+xitem(tt(tcp_send [-cnq] [ -s) var(sess) tt(| -l) var(sess)tt(,... ]) var(data) tt(...))
+item(tt(tcp_send [-cnq] -a) var(data) tt(...))(
Send the supplied data strings to all the specified sessions in turn. The
underlying operation differs little from a `tt(print -r)' to the session's
file descriptor, although it attempts to prevent the shell from dying owing
to a tt(SIGPIPE) caused by an attempt to write to a defunct session.
+The option tt(-c) causes tt(tcp_send) to behave like tt(cat). It reads
+lines from standard input until end of input and sends them in turn to the
+specified session+LPAR()s+RPAR() exactly as if they were given as var(data)
+arguments to individual tt(tcp_send) commands.
+
The option tt(-n) prevents tt(tcp_send) from putting a newline at the end
of the data strings.
Index: Functions/TCP/tcp_send
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/TCP/tcp_send,v
retrieving revision 1.3
diff -u -r1.3 tcp_send
--- Functions/TCP/tcp_send 25 Jul 2003 10:53:45 -0000 1.3
+++ Functions/TCP/tcp_send 8 Aug 2006 11:22:28 -0000
@@ -1,14 +1,16 @@
emulate -L zsh
setopt extendedglob cbases
-local opt quiet all sess fd nonewline
+local opt quiet all sess fd nonewline cat line
local -a sessions write_fds
integer mystat
-while getopts "al:nqs:" opt; do
+while getopts "acl:nqs:" opt; do
case $opt in
(a) all=1
;;
+ (c) cat=1
+ ;;
(n) nonewline=-n
;;
(q) quiet=1
@@ -55,21 +57,29 @@
local TCP_SESS
-for TCP_SESS in $sessions; do
+while true; do
+ if [[ -n $cat ]]; then
+ read -r line || break
+ else
+ line="$*"
+ fi
+ for TCP_SESS in $sessions; do
fd=${tcp_by_name[$TCP_SESS]}
if [[ -z $fd ]]; then
- print "No such session: $TCP_SESS" >&2
- mystat=1
- continue
+ print "No such session: $TCP_SESS" >&2
+ mystat=1
+ continue
fi
- print -u $fd $nonewline -r -- $*
+ print -u $fd $nonewline -r -- $line
if [[ $? -ne 0 || -n $TCP_FD_CLOSED ]]; then
- print "Session ${TCP_SESS}: fd $fd unusable." >&2
- unset TCP_FD_CLOSED
+ print "Session ${TCP_SESS}: fd $fd unusable." >&2
+ unset TCP_FD_CLOSED
fi
if [[ -n $TCP_OUTPUT ]]; then
- tcp_output -P "$TCP_OUTPUT" -S $TCP_SESS -F $fd -q "${(j. .)*}"
+ tcp_output -P "$TCP_OUTPUT" -S $TCP_SESS -F $fd -q "${(j. .)*}"
fi
+ done
+ [[ -z $cat ]] && break
done
return $mystat
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
reply other threads:[~2006-08-08 11:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200608081124.k78BOR7g007020@news01.csr.com \
--to=pws@csr.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).