From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10788 invoked from network); 3 Feb 2003 23:15:37 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 3 Feb 2003 23:15:37 -0000 Received: (qmail 3725 invoked by alias); 3 Feb 2003 23:15:17 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5866 Received: (qmail 3718 invoked from network); 3 Feb 2003 23:15:17 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 3 Feb 2003 23:15:17 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [64.56.232.6] by sunsite.dk (MessageWall 1.0.8) with SMTP; 3 Feb 2003 23:15:17 -0000 Received: (from parkw@localhost) by node1.opengeometry.net (8.11.6/8.11.6) id h13NFIr08909 for zsh-users@sunsite.dk; Mon, 3 Feb 2003 18:15:18 -0500 Date: Mon, 3 Feb 2003 18:15:18 -0500 From: William Park To: zsh-users@sunsite.dk Subject: Re: (feature request) Shell script within shell script Message-ID: <20030203231518.GA8900@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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030201073655.GA3893@node1.opengeometry.net> User-Agent: Mutt/1.4i On Sat, Feb 01, 2003 at 02:36:55AM -0500, William Park wrote: > Dear Zsh expert, > > When writing a shell script, quite often, I have to write bunch of > separate Awk/Python/Perl/etc scripts that are more than few lines. I > tend to lose track of which script does what, and get bitten over two > levels of quotes. > > Essentially, I wish I could do something like > > herefile test1 << "EOF" > #! /usr/bin/gawk -f > ... > ... > EOF > > and > > herefile test2 << "EOF" > #! /usr/bin/python > ... > ... > EOF > > so that invocation and usage of 'test1' and 'test2' will be the same as > if they were separate real files. > > Can Zsh do this now? If not, does Zsh have standard mechanism to > provide this kind of extensions? I've finally managed to find a solution. It's called "process substitution": function test1 () { awk -f <( cat <<"EOF" ... ... EOF ) } and function test2 () { python <( cat <<"EOF" ... ... EOF ) } -- William Park, Open Geometry Consulting, Linux solution for data management and processing.