From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6692 invoked from network); 8 Feb 2003 02:31:51 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 8 Feb 2003 02:31:51 -0000 Received: (qmail 21536 invoked by alias); 8 Feb 2003 02:31:26 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5897 Received: (qmail 21529 invoked from network); 8 Feb 2003 02:31:26 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 8 Feb 2003 02:31:26 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.46.181.248] by sunsite.dk (MessageWall 1.0.8) with SMTP; 8 Feb 2003 2:31:24 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id h182VQU27172 for zsh-users@sunsite.dk; Fri, 7 Feb 2003 18:31:26 -0800 From: "Bart Schaefer" Message-Id: <1030208023126.ZM27171@candle.brasslantern.com> Date: Sat, 8 Feb 2003 02:31:26 +0000 In-Reply-To: <20030207202324.GA31158@node1.opengeometry.net> Comments: In reply to William Park "Re: (feature request) Shell script within shell script" (Feb 7, 3:23pm) 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> <20030207202324.GA31158@node1.opengeometry.net> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-users@sunsite.dk Subject: Re: (feature request) Shell script within shell script MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Feb 7, 3:23pm, William Park wrote: } } 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. Did you actually try that? It certainly doesn't work for me. You can't use two-or-more-digit numbers to represent FDs for redirection: zagzig% cat 10< foo bar heredoc> EOF cat: 10: No such file or directory It works if you change 10 to 9, but it's overkill. All you need is: awk -f /dev/fd/9 9<<\EOF ... ... EOF And if you happen to encounter a command that requires a real seekable file for its input, you can do this: awk -f =(<&9) 9<<\EOF ... ... EOF However, I'd like to point out that this is not what you originally asked for. You asked how to create a script, complete with #! line, and execute it, not how to feed a here-document to a command that expects a file name.