rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: Alan Watson <alan@oldp.astro.wisc.edu>
To: rc@hawkwind.utcs.toronto.edu
Subject: Re: read
Date: Sun, 16 May 1993 02:49:13 -0400	[thread overview]
Message-ID: <9305160649.AA09549@oldp.astro.wisc.edu> (raw)

I have just realized that my implementation of read returns the
wrong status if you type:

   ; read x
   foo<ctrl-d>

More seriously, and strengthening my suggestion that read should be a
builtin, I cannot find a way to get `awk' to simulate `line'.  In
response to the above input, line would print "foo\n" and set status to
1.  The obvious awk replacement, i.e.,

   ; fn line { awk '{print $0; exit 0}END{print $0; exit 1}' }

does not work in this way, rather I have to press <ctrl-d> twice, and
then it prints "foo\n0\nfoo\n1\n".

Your mission, should you choose to accept it, is to come up with a
portable (i.e., you can't use line) read which implements v7 semantics
on EOF (i.e., if anything was typed before EOF then set the variable to
this, otherwise unset it, and return 1 if an EOF is seen).  Actually, a
working implementation of line will be sufficient (although, obviously,
the C code for line will not do).

I'd also very much appreciate it if someone could restore my faith in
awk by explaining its output!

Alan.


             reply	other threads:[~1993-05-16  6:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-05-16  6:49 Alan Watson [this message]
1993-05-16  7:12 ` read Chris Siebenmann
  -- strict thread matches above, loose matches on Subject: below --
1993-05-18  2:13 read Alan Watson
1993-05-16  7:51 read Alan Watson
1993-05-15  4:14 read Alan Watson

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=9305160649.AA09549@oldp.astro.wisc.edu \
    --to=alan@oldp.astro.wisc.edu \
    --cc=rc@hawkwind.utcs.toronto.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).