From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pantransit.reptiles.org ([209.157.133.146]) by hawkwind.utcs.toronto.edu with SMTP id <25789>; Mon, 8 May 2000 18:52:08 -0400 Received: (qmail 23584 invoked by uid 204); 8 May 2000 15:15:02 -0000 Date: Mon, 8 May 2000 11:15:02 -0400 Message-ID: <20000508151502.23583.qmail@pantransit.reptiles.org> From: "Smarasderagd" To: cks@hawkwind.utcs.toronto.edu, rc@hawkwind.utcs.toronto.edu Subject: Re: building rc on QNX4 Chris Siebenmann 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...