rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: "Smarasderagd" <smarry@vex.net>
To: cks@hawkwind.utcs.toronto.edu, rc@hawkwind.utcs.toronto.edu
Subject: Re: building rc on QNX4
Date: Mon, 8 May 2000 11:15:02 -0400	[thread overview]
Message-ID: <20000508151502.23583.qmail@pantransit.reptiles.org> (raw)

Chris Siebenmann <cks@hawkwind.utcs.toronto.edu> writes:
> Unfortunately the example doesn't work in several very useful
>situations: it will badly flub the common scripting idiom of
>'generate stuff | {while (read foo) {....}}', never processing
>most of the actual output.

My usual way through this situation has been to recode it as

for (i in `{generate stuff}) {...}

replacing ` with ``($nl) if I really want lines and not tokens. If the
input is big enough to cause problems for rc, I switch to awk, sed, or
whatever.  Complicated interactive scripts I usually write in awk/gawk.
This won't work to interact with a network connection, such as the news
and FTP snarfing scripts I use (see below.)

> In order to make this work, you need to find a utility that is
>guaranteed to read no more than the first line of standard input.
>Most utilities (eg awk) will happily eat an entire large buffer
>worth of standard input and then give you the first line back.
>This is unfortunate if you wanted to read the rest of the buffer's
>worth of input later.

I wrote a tiny C program "line" that reads a character at a time to ensure
that further input doesn't get eaten, and another one "spew" to handle
the "." on a line by itself ending a block of output protocol used by
news, mail, and others.  "line" wouldn't be necessary if news didn't
respond to article requests etc. with a response code line immediately
followed by the output.  You may notice that SMTP/NNTP don't put the
server in this situation...

             reply	other threads:[~2000-05-08 22:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-08 15:15 Smarasderagd [this message]
2000-05-09  8:22 ` Carlo Strozzi
  -- strict thread matches above, loose matches on Subject: below --
2000-05-09  4:34 Smarasderagd
2000-05-11 12:26 ` Gert-Jan Vons
2000-05-08 15:23 Sam Roberts
2000-05-09  8:25 ` Carlo Strozzi
2000-05-08 10:19 Bengt Kleberg
2000-05-06 21:47 Byron Rakitzis
2000-05-04 13:46 Sam Roberts
2000-05-04  8:45 Byron Rakitzis
2000-05-06 10:28 ` Carlo Strozzi
2000-05-07 17:46   ` Paul Haahr
2000-05-08  8:01     ` Carlo Strozzi
2000-05-06 16:35 ` Jeremy Fitzhardinge
     [not found] <sroberts@uniserve.com>
2000-04-26 15:02 ` Sam Roberts
2000-04-27 16:56   ` Scott Schwartz
2000-04-27 20:41     ` Sam Roberts
2000-04-27 17:39   ` Carlo Strozzi
2000-05-02 14:41     ` Tim Goodwin
2000-05-04 15:18       ` Carlo Strozzi
2000-05-08  8:29         ` Tim Goodwin
2000-05-08  8:58           ` Chris Siebenmann
2000-05-08  9:15             ` Tim Goodwin
2000-05-08 23:25               ` Stephen Tell
2000-05-08 11:50           ` David Luyer
2000-05-08 13:28           ` Carlo Strozzi

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20000508151502.23583.qmail@pantransit.reptiles.org \
    --to=smarry@vex.net \
    --cc=cks@hawkwind.utcs.toronto.edu \
    --cc=rc@hawkwind.utcs.toronto.edu \


* 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.
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).