rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Re: A lighter read function
@ 1991-12-11  4:32 DaviD W. Sanderson
  1991-12-11 12:28 ` David J. Fiander
  0 siblings, 1 reply; 9+ messages in thread
From: DaviD W. Sanderson @ 1991-12-11  4:32 UTC (permalink / raw)
  To: rc

[Apologies to the list; I am unable to reply to "golem!david"]

> exactly the same functionality as the example source, except it
> uses line(1) and doesn't do the assignment if the read fails.

line(1) is not available everywhere.  At least not on the 4.3BSD-utah
systems I use.  Perhaps rephrasing in terms of `sed 1q' would be better.

DaviD W. Sanderson (dws@cs.wisc.edu)


^ permalink raw reply	[flat|nested] 9+ messages in thread
* A lighter read function
@ 1991-12-11  3:53 David J. Fiander
  0 siblings, 0 replies; 9+ messages in thread
From: David J. Fiander @ 1991-12-11  3:53 UTC (permalink / raw)
  To: The rc user community

Having seen, and been shocked at, the read example that comes
with the rc sources, I decided to try to write one that doesn't
require all of awk to run.  The following function provides
exactly the same functionality as the example source, except it
uses line(1) and doesn't do the assignment if the read fails.

nl='
'
fn read {
	x=() ifs=$nl {
		x = `{line || echo 1^$nl^1; echo 0} 
		if (~ $x(2) 0) $1 = $x(1)
		return $x(2)
	}
}

--
David J. Fiander   |email [Fr., = enamel] Used attrib. in `email ink', ink
<david@golem.uucp> |used on glass, porcelain, etc.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1991-12-13  2:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-12-11  4:32 A lighter read function DaviD W. Sanderson
1991-12-11 12:28 ` David J. Fiander
1991-12-11 19:28   ` Chris Siebenmann
1991-12-13  0:58     ` David J. Fiander
1991-12-13  1:37       ` Chris Siebenmann
1991-12-13  1:47       ` David Hogan
1991-12-11 21:48   ` Ronald S H Khoo
1991-12-12 12:16     ` David J. Fiander
  -- strict thread matches above, loose matches on Subject: below --
1991-12-11  3:53 David J. Fiander

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