rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: ronald@robobar.co.uk (Ronald S H Khoo)
To: david@golem.uucp
Cc: rc@archone.tamu.edu
Subject: Re: A lighter read function
Date: Wed, 11 Dec 1991 15:48:50 -0600	[thread overview]
Message-ID: <9112112148.AA05916@robobar.Co.Uk> (raw)
In-Reply-To: <22832.692454506@golem.UUCP>


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 <stdio.h>

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 <ronald@robobar.co.uk> +44 81 991 1142 (O) +44 71 229 7741 (H)


  parent reply	other threads:[~1991-12-11 22:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-12-11  4:32 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 [this message]
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

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=9112112148.AA05916@robobar.Co.Uk \
    --to=ronald@robobar.co.uk \
    --cc=david@golem.uucp \
    --cc=rc@archone.tamu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

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