From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <69f5b2e51adfc734027e4cf14ffa8286@collyer.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] rc here docs From: Geoff Collyer In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Sun, 31 Aug 2003 19:23:31 -0700 Topicbox-Message-UUID: 261a9a64-eacc-11e9-9e20-41e7f4b1d025 Getting here documents right inside functions and loops and loops inside functions and in the background is tricky. Even Bourne didn't get it right (see BUGS in V7's sh(1)). I think the SVR2 shell (thus the V8 shell) got it mostly right, but I didn't push it hard. There are two main issues to sort out: when to start reading a given here document (and collecting it into a temp file or perhaps into memory nowadays) and when to remove the temp file. This needs to work in the presence of notes too. So consider scripts like this one: fn sigint sigexit { { for (i in 1 2 3) { cat <