From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3249 invoked from network); 7 Feb 2003 20:25:29 -0000 Received: from ns2.primenet.com.au (HELO primenet.com.au) (@203.24.36.3) by ns1.primenet.com.au with SMTP; 7 Feb 2003 20:25:29 -0000 Received: (qmail 13041 invoked from network); 7 Feb 2003 20:25:27 -0000 Received: from sunsite.dk (130.225.247.90) by proxy.melb.primenet.com.au with SMTP; 7 Feb 2003 20:25:27 -0000 Received: (qmail 6888 invoked by alias); 7 Feb 2003 20:23:30 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5892 Received: (qmail 6881 invoked from network); 7 Feb 2003 20:23:30 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 7 Feb 2003 20:23:30 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [64.56.232.6] by sunsite.dk (MessageWall 1.0.8) with SMTP; 7 Feb 2003 20:23:29 -0000 Received: (from parkw@localhost) by node1.opengeometry.net (8.11.6/8.11.6) id h17KNOj31186 for zsh-users@sunsite.dk; Fri, 7 Feb 2003 15:23:24 -0500 Date: Fri, 7 Feb 2003 15:23:24 -0500 From: William Park To: zsh-users@sunsite.dk Subject: Re: (feature request) Shell script within shell script Message-ID: <20030207202324.GA31158@node1.opengeometry.net> Mail-Followup-To: zsh-users@sunsite.dk References: <20030128042243.GA3888@node1.opengeometry.net> <20030128104034.GA6470@node1.opengeometry.net> <20030131204945.GA1189@node1.opengeometry.net> <20030201073655.GA3893@node1.opengeometry.net> <20030203231518.GA8900@node1.opengeometry.net> <1030204091832.ZM15610@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1030204091832.ZM15610@candle.brasslantern.com> User-Agent: Mutt/1.4i On Tue, Feb 04, 2003 at 09:18:32AM +0000, Bart Schaefer wrote: > On Feb 3, 6:15pm, William Park wrote: > } > } I've finally managed to find a solution. It's called "process > } substitution": > } function test1 () { > } awk -f <( cat <<"EOF" > } ... > } ... > } EOF > } ) > } } > > Just watch out for what happens if you ever have unbalanced > parentheses in the content of the here-document. A classic solution: function test1 () { exec 10<<"EOF" ... ... EOF awk -f /dev/fd/10 exec 10<&- } I didn't have to patch anything. I just have to keep track of fd's instead of external files. If the here-documents don't change, then I can put 'exec' outside the function. -- William Park, Open Geometry Consulting, Linux solution for data management and processing.