From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <56beac6b65153d337a33b24e20172a60@quanstro.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] late to the party - Here docs From: erik quanstrom Date: Wed, 7 Nov 2007 15:19:02 -0500 In-Reply-To: <40711DDA-D0EC-496B-BB91-9132B3ADBD78@mac.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: eddbac68-ead2-11e9-9d60-3106f5b1d025 > Exactly: they are an aesthetic convenience compared with multiple > echo invocations > but so are quotes compared with multiple backslashes. > >>> though it is annoying they can't be used in fn definitions. > > That's a bug which could be fixed ... > > >> i was thinking about this topic again the other day during an >> idle moment. here documents are part of the parsing routine. >> but they don't end up in rc's machine language. > > Does this mean they don't work in loops too? it could be fixed. there must be a reason duff never made here documents work. i think they just don't fit the pattern. one justification i've seen for them is that they don't require the whole here doc to be in the shell's memory. the other is that "quoting is easier". unfortunately, to have here documents work within functions, the whole here doc needs to be in the shell's memory. so much for reason #1. and one of the reasons for developing rc was to cut down on the different quoting rules. the bourne shell has \-quoting, "-quoting, '-quoting and here document quoting rules. rc has ' quoting, \ quoting (only at the end of lines) and here document quoting. from your example, i'm not so sure why this { echo select $blah blah';' echo $imbibe_rat_urine }|mysql --blah-blah is so terrible. it turns out that you can use a here document in a loop ; for(i in 1 2 3) cat < ! } fu: '/bin/fu' directory entry not found } fu: '/bin/fu' directory entry not found } fu: '/bin/fu' directory entry not found since nobody's bothered to fix this, it's likely that it's just not used very much. - erik