From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-relay-1.mv.us.adobe.com ([130.248.1.1]) by hawkwind.utcs.toronto.edu with SMTP id <2749>; Thu, 17 Dec 1992 12:15:40 -0500 Received: by mail-relay-1.mv.us.adobe.com; id AA02667; Thu, 17 Dec 92 09:15:25 -0800 Received: by utopia.mv.us.adobe.com (NeXT-1.0 (From Sendmail 5.52)/NX3.0S) id AA04914; Thu, 17 Dec 92 09:12:51 PST Date: Thu, 17 Dec 1992 12:12:51 -0500 From: Paul Haahr Message-Id: <9212171712.AA04914@utopia.mv.us.adobe.com> Received: by NeXT Mailer (1.63) To: Alan Watson Subject: Re: Here documents Cc: rc mailing list > 1. Can someone provide a more definitive definition of the > source of here documents. here documents are always read from the same place as where commands are read. they are also read at parse time, not execution time. this is done to support here docs in functions and loops, which i believe are not supported by td's rc. (use rc -nx to explore what's going on: heredocs get turned into here strings.) ;; rc -nx ; cat << EOF hello, $USER EOF cat <<<'hello, '^$^USER^' ' ; > 2. Should a here document be read from rc's stdin, rather than the > source of its commands? Would this break any existing scripts? > This would allow example [3] to work. no, that's what redirection, pipes, and normal standard input processing do. it would break just about every script. > 3. Should a here document be read from a command's stdin, > rather than the shell input? Would this break any existing scripts? > This would allow example [2] to work. no, for the same reasons. ---- as to your examples, i don't see why you're using here docs: > [2] ; { echo '$foo' ; echo EOF } | cat < [3] ; { echo '$foo' ; echo EOF } | rc -c 'cat < [4] ; { echo 'cat < I am intrigued that such subtleties exist in an apparently > straightforward feature of the language. heredocs don't fit naturally into the model of the rest of the shell, but are so useful as to warrant an exception. i think byron's solution (here strings and conversion at parse time) is elegant and clever, and, when understood, makes the answers to ``what if?'' questions obvious.