From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay2.UU.NET ([192.48.96.7]) by hawkwind.utcs.toronto.edu with SMTP id <2683>; Thu, 23 Sep 1993 11:30:30 -0400 Received: from spool.uu.net (via LOCALHOST) by relay2.UU.NET with SMTP (5.61/UUNET-internet-primary) id AA04699; Thu, 23 Sep 93 11:30:16 -0400 Received: from srg.UUCP by uucp6.uu.net with UUCP/RMAIL (queueing-rmail) id 112841.16827; Thu, 23 Sep 1993 11:28:41 EDT Received: from ceres.srg.af.mil by srg.srg.af.mil id aa07017; Thu, 23 Sep 93 11:19:17 EDT From: culliton@srg.af.mil (Tom Culliton x2278) X-Mailer: SCO System V Mail (version 3.2) To: rc@hawkwind.utcs.toronto.edu, vons@cesar.crbca1.sinet.slb.com Subject: Re: A patch to add builtin read (small bug) Date: Thu, 23 Sep 1993 11:19:22 -0400 Message-Id: <9309231119.aa03974@ceres.srg.af.mil> > The patch dropped in nicely in my virgin 1.4, no problems. At least one of those bug fixes I mentioned prevents a crash, you really should look into them. > I was just wondering about the following case: > > ; x=(foo bar) > ; read x < /dev/null > ; echo $status > 1 > ; whatis x > x=(foo bar) > > This suggests that something has been read before encountering EOF, > which is obviously not the case, so I assume the read should set x to ''. Doing: read x |For Chris, if you don't care about setting a different ifs, you can > |split the line without a fork by using eval: > | read x;eval 'x=('$x')' > > This doesn't work: (Examples with embedded '#' and '=' deleted) Yeah, it's a stunt, and I should have made the standard disclaimer that pathalogical cases would kill it. > If a read function is added, why not make it a bit more practical by using > $ifs? If makes it more useful, and the code above a bit more elegant. > I wouldn't mind adding this myself, but I'm not too familiar with the > rc internals. > > Gert-Jan Because you lose information that you can't get back. For example if you are trying to parse the entries from /etc/passwd to find the home directories, and the comment field is blank: joeblow:x:200:50::/usr/joeblow:/bin/rc You get the following list: x=(joeblow x 200 50 /usr/joeblow /bin/rc) and when you try to retrieve $x(6) which should be the directory you get /bin/rc instead! This may not be the worlds best example but I hope my point is clear. The way read works now preserves potentially important information. Tom