From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eros.uknet.ac.uk ([192.91.199.2]) by archone.tamu.edu with SMTP id <18995>; Wed, 11 Dec 1991 16:13:54 -0600 Received: from robobar.co.uk by eros.uknet.ac.uk with UUCP id <5968-0@eros.uknet.ac.uk>; Wed, 11 Dec 1991 22:13:07 +0000 Received: by robobar.Co.Uk (smail2.5) id AA05918; 11 Dec 91 21:48:51 GMT (Wed) From: ronald@robobar.co.uk (Ronald S H Khoo) Date: Wed, 11 Dec 1991 15:48:50 -0600 Newsgroups: list.rc In-Reply-To: <22832.692454506@golem.UUCP> Organization: Robobar Ltd., Perivale, Middx., ENGLAND. X-Mailer: Mail User's Shell (7.2.2 4/12/91) To: david@golem.uucp Subject: Re: A lighter read function Cc: rc@archone.tamu.edu Message-Id: <9112112148.AA05916@robobar.Co.Uk> In article <22832.692454506@golem.UUCP> David J Fiander wrote: > line is available on all SCO UNIX systems, and I first saw it > on a BSD 4.2 system (I think). Besides it is easily written: > #include This looks wrong to me. line(1) does not use stdio. Where available, line(1) should preserve the seek position of the stream so that anyone who comes afterwards can read the rest. Trying to fseek back there ain't much good either, since input might come from a non-seekable device or pipe. Hence, line(1) must use single character reads, just like sh(1) does (what does rc(1L) do ?). Here is a demonstration of line(1)'s behaviour on a SCO UNIX machine: script 'typescript' started on Wed Dec 11 21:31:34 1991 $ grep LSEEK /usr/include/sys.s #define LSEEK 19 $ (line > /dev/null > perl -e 'print syscall(19,0,0,1)."\n"' # ie lseek(0, 0L, SEEK_CUR) > ) < /etc/passwd 24 $ (sed 1q > /dev/null > perl -e 'print syscall(19,0,0,1)."\n"' > ) < /etc/passwd 512 $ script 'typescript' ended on Wed Dec 11 21:33:10 1991 Please excuse the use of sh(1) -- I haven't had time to learn rc. Please excuse the use of perl(1L) -- I couldn't think of another way of executing lseek(2) from the command line ... (BTW, David, in case anyone you know wants an "alternative" approach to script(1) on SCO, mine's 83 lines of perl :-) -- Ronald Khoo +44 81 991 1142 (O) +44 71 229 7741 (H)