From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from oldp.astro.wisc.edu ([128.104.39.15]) by hawkwind.utcs.toronto.edu with SMTP id <2223>; Sun, 16 May 1993 02:49:29 -0400 Received: by oldp.astro.wisc.edu (5.65/DEC-Ultrix/4.3) id AA09549; Sun, 16 May 1993 01:49:14 -0500 Message-Id: <9305160649.AA09549@oldp.astro.wisc.edu> To: rc@hawkwind.utcs.toronto.edu Subject: Re: read Date: Sun, 16 May 1993 02:49:13 -0400 From: Alan Watson X-Mts: smtp I have just realized that my implementation of read returns the wrong status if you type: ; read x foo 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 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.