From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4799 invoked by alias); 18 Oct 2012 15:35:12 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30740 Received: (qmail 3629 invoked from network); 18 Oct 2012 15:34:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 209.85.214.171 is neither permitted nor denied by SPF record at ntlworld.com) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:x-gm-message-state; bh=tuJTeCh9RnwmM7QuYh30dLqMJjNkh+/MDPUfXNSq64k=; b=oPsVxILCRHVSmuKoIdsDt6oVGPIdzLQnFBhUloFiLz9tQLADwZWddSXENq4YIuq8N/ IWDiNB88MZVgao/iEK+dh97tLVaqCPJjLk7fx5UfTHy2C5BRRkFEyWiUWQB567JvUJbD hnUiATNkjXE+MLNYRtB4bfiDxgbxJiU4Mv7hRBdH86kZi4jzE2iiD/UKekvvBvkxZwhn OUndtrHbpBaYwibt6tUpKFlW2lcZx2G07UwehSvYWv1UfxFL1CjoOrQXtI6E2GOjVdz+ exdBwt9Lw+HaItURAcAZUOB2ADUP/y9VoFWIQyxl3KEP/wSR92h97Qe2P0httZHhonNq dK9A== MIME-Version: 1.0 X-Originating-IP: [80.239.194.50] In-Reply-To: <121018080751.ZM2795@torch.brasslantern.com> References: <20121017202030.46014a7a@pws-pc.ntlworld.com> <20121017211603.6189d6f4@pws-pc.ntlworld.com> <121018080751.ZM2795@torch.brasslantern.com> Date: Thu, 18 Oct 2012 16:27:00 +0100 Message-ID: Subject: Re: Segfault in =( ) substitution From: Peter Stephenson To: zsh-workers@zsh.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQmaIdmOBZdAS6dmMnPUs2FpwmqzP/geFi/9mbDD5vD1uJCCnVBc4nyMOI9reVo7RozNnome On 18 October 2012 16:07, Bart Schaefer wrote: > On Oct 17, 9:16pm, Peter Stephenson wrote: > : > : I suppose it's worth pointing out you can now do things like this... > : > : () { > : print File $1: > : cat $1 > : } =(print This be the verse) > > More than worth pointing out, it's worth putting in the docs as an > example! > > Question is, whether it's better as an example of anonymous functions or > of process substitution. Index: Doc/Zsh/expn.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v retrieving revision 1.146 diff -p -u -r1.146 expn.yo --- Doc/Zsh/expn.yo 18 Oct 2012 08:28:48 -0000 1.146 +++ Doc/Zsh/expn.yo 18 Oct 2012 15:24:50 -0000 @@ -483,6 +483,24 @@ example(LPAR()mycmd =(myoutput)RPAR() &! as the forked subshell will wait for the command to finish then remove the temporary file. +A general workaround to ensure a process substitution endures for +an appropriate length of time is to pass it as a parameter to +an anonymous shell function (a piece of shell code that is run +immediately with function scope). For example, this code: + +example(LPAR()RPAR() { + print File $1: + cat $1 +} =+LPAR()print This be the verse+RPAR()) + +outputs something resembling the following + +example(File /tmp/zsh6nU0kS: +This be the verse) + +The temporary file created by the process substitution will be deleted +when the function exits. + texinode(Parameter Expansion)(Command Substitution)(Process Substitution)(Expansion) sect(Parameter Expansion) cindex(parameter expansion) pws