zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: new parameter expansion type?
Date: Mon, 30 Aug 1999 18:10:45 +0200	[thread overview]
Message-ID: <9908301610.AA17542@ibmth.df.unipi.it> (raw)
In-Reply-To: ""Bart Schaefer""'s message of "Mon, 30 Aug 1999 16:05:58 DFT." <990830160558.ZM6355@candle.brasslantern.com>

"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

${[[ <test> ]] <true1> <true2> ... | <false1> <false2> ... }

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 <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


  reply	other threads:[~1999-08-30 16:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-30  9:49 Sven Wischnowsky
1999-08-30 10:06 ` Andrej Borsenkow
1999-08-30 10:58 ` Tanaka Akira
1999-08-30 16:05 ` Bart Schaefer
1999-08-30 16:10   ` Peter Stephenson [this message]
1999-08-30 10:38 Sven Wischnowsky
1999-08-31 13:18 ` Andrej Borsenkow
1999-08-31  8:50 Sven Wischnowsky
1999-08-31 17:47 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9908301610.AA17542@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).