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: Here documents
Date: Thu, 17 Dec 1992 13:29:03 -0500	[thread overview]
Message-ID: <9212171829.AA21554@oldp.astro.wisc.edu> (raw)

Paul writes:

> heredocs get turned into here strings

Ah, finally a justification for here strings (my number three
candidate for elimination from rc after ` without {} and ``{}).

>>       2. Should a here document be read from rc's stdin, rather than the
>>       source of its commands?  Would this break any existing scripts?
>
>no, that's what redirection, pipes, and normal standard input processing do.
>it would break just about every script.

I was thinking more of interactive invocations of rc (or, perhaps more
accurately, I was emphatically not thinking about scripts).  A better
suggestion would be that if we are at EOF on the source of command
input, a here document should be read from stdin; this would allow my
example [3] to work.

Byron writes:

> As to your question about whether input should be read from stdin
> "if there's a redirection of stdin". What does this mean? 

I mean that when I specify both a redirection of stdin (by putting a
pipe in front of a command or using an explicit `<') and a here
document, that the here document should be read from the source of
stdin.  In concrete terms, this would take a hypothetical:

	; foo | bar <<EOF

and transform it into:

	; { { echo 'cat <<EOF' ; foo } | rc } | bar

> In general,
> it's not possible to tell if there's a redirection of stdin.

Really?  Yes, rc cannot tell if its stdin has been redirected, but
surely it can tell if it is asked to redirect the stdin of a command.
Perhaps not, as rc does not fault any of:

	; cat foo | cat <bar
	
	; cat >foo | cat

	; cat <foo <bar

	; cat >foo >bar

for having multiple redirections of stdin and stdout.  To be honest, I
would be happiest if rc had issued error messages for my examples [2]
and [3], but from Byron's statement this would appear to be
impossible.  I have to say I am somewhat surprised.

Perhaps Byron's description of the source of here documents should be
added to the man page, just for completeness.

Alan.



             reply	other threads:[~1992-12-17 18:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-12-17 18:29 Alan Watson [this message]
1992-12-18  3:08 ` Scott Merrilees
  -- strict thread matches above, loose matches on Subject: below --
1992-12-17 19:19 Byron Rakitzis
1992-12-17 17:12 Paul Haahr
1992-12-17 14:10 Alan Watson
1992-12-17  9:00 Alan Watson
1992-12-08 17:17 raymondc

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=9212171829.AA21554@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).