From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3972 invoked from network); 30 Aug 1999 16:44:54 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 30 Aug 1999 16:44:54 -0000 Received: (qmail 23145 invoked by alias); 30 Aug 1999 16:44:44 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7556 Received: (qmail 23138 invoked from network); 30 Aug 1999 16:44:43 -0000 Message-Id: <9908301610.AA17542@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk Subject: Re: PATCH: new parameter expansion type? In-Reply-To: ""Bart Schaefer""'s message of "Mon, 30 Aug 1999 16:05:58 DFT." <990830160558.ZM6355@candle.brasslantern.com> Date: Mon, 30 Aug 1999 18:10:45 +0200 From: Peter Stephenson "Bart Schaefer" wrote: > On Aug 30, 11:49am, Sven Wischnowsky wrote: > } Subject: PATCH: new parameter expansion type? > } > } ${name^pattern^then^else} > } > } Gives you the (substituted) `then' string if the expansion of `name' > } matches the `pattern' and otherwise it gives you the `else' string. > > Isn't this just the same as > > ${${${(M)name#pattern}:+then}:-else} > > except of course that you have to be a little selective about whether > you use # or % to delimit the pattern? This seems to be the case; I've included it in 6-pws-2, but I'll probably back it off in 6-pws-3, unless there's a good reason otherwise. I was thinking about a more general ternary expression syntax, which would require doing some work to pre-expansion argument lists. Something like ${[[ ]] ... | ... } i.e. the true/false bits are treated like part of an ordinary argument list (but can't have redirections). I suspect it's going to be too clumsy, however. You can get the same effect with if's and arrays, obviously. -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy