rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: culliton@srg.af.mil (Tom Culliton x2278)
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	[thread overview]
Message-ID: <9309231119.aa03974@ceres.srg.af.mil> (raw)

> 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 </etc/passwd

doesn't work either, but my brain isn't working well emough at the
moment to figure out why.  Anybody got a clue?

>   |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


             reply	other threads:[~1993-09-23 15:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-09-23 15:19 Tom Culliton x2278 [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-09-23 18:10 Tom Culliton x2278
1993-09-23 16:03 gjv%atlas%cesar
1993-09-23 15:36 Arnold Robbins
1993-09-23  7:30 gjv%atlas%cesar

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=9309231119.aa03974@ceres.srg.af.mil \
    --to=culliton@srg.af.mil \
    --cc=rc@hawkwind.utcs.toronto.edu \
    --cc=vons@cesar.crbca1.sinet.slb.com \
    /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).