From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3711 invoked from network); 30 Aug 1999 16:06:18 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 30 Aug 1999 16:06:18 -0000 Received: (qmail 18637 invoked by alias); 30 Aug 1999 16:06:10 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7554 Received: (qmail 18628 invoked from network); 30 Aug 1999 16:06:02 -0000 From: "Bart Schaefer" Message-Id: <990830160558.ZM6355@candle.brasslantern.com> Date: Mon, 30 Aug 1999 16:05:58 +0000 In-Reply-To: <199908300949.LAA20865@beta.informatik.hu-berlin.de> Comments: In reply to Sven Wischnowsky "PATCH: new parameter expansion type?" (Aug 30, 11:49am) References: <199908300949.LAA20865@beta.informatik.hu-berlin.de> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk Subject: Re: PATCH: new parameter expansion type? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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? I'm not particularly excited by the ^test^true^false syntax nor by the trick of making "." magic in the true/false strings. I vote against this patch, in its current form at least. Sorry, Sven. } Ok, the `.' thingy is just because I couldn't think of a better } character/syntax (suggestions?) and this isn't as powerful as I would } like it because `then' and `else' can't expand to arrays. Maybe we } could make `${(A)foo^?^$arr1^$arr2}' do that (and maybe we could do } the same for `${(A)foo:-$arr}'. This is essentially the same problem as ${(A)foo:=string} where it would be nice to be able to have "string" be interpreted as an array. I pointed out the parsing problem with this back at that time. It would be nice to have a solution; Andrej suggested ${(A)foo:=(val1 val2 ...)} but it will require a change to the parser to make that work. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com