* PATCH: tcp_send -c
@ 2006-08-08 11:24 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2006-08-08 11:24 UTC (permalink / raw)
To: Zsh hackers list
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-08-08 11:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-08 11:24 PATCH: tcp_send -c Peter Stephenson
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).