zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@cambridgesiliconradio.com>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: Re: PATCH: Re: expansion
Date: Fri, 16 Jun 2000 13:20:54 +0100	[thread overview]
Message-ID: <0FW8002NDYAS0Z@la-la.cambridgesiliconradio.com> (raw)
In-Reply-To: "Your message of Fri, 16 Jun 2000 13:22:10 +0200." <200006161122.NAA30744@beta.informatik.hu-berlin.de>

Sven wrote:
> What's going on here? With -f:
>   % a='a{b,c}d'
>   % setopt braceccl
>   % b=( ${${(q)a}:gs/\\{/{/:gs/\\}/}/} )
>   % echo $b
>   a,d abd acd
> 
> Oops. (Yes, works with just `echo ${${(q)a}...}', too.)

Yes, I'd use this:
  print ${${(q)a}:gs/\\\{/\{/:gs/\\\}/\}/}
to make sure all the relevant braces are quoted, or perhaps even better
(pattern matching is better about untokenising, because it only needs to do
it once while parsing):
  print ${${(q)a}//(#b)\\([{}])/$match[1]}

This is not very well handled at present; all sorts of things are a bit
more heavily tokenised than you might want at various places in
paramsubst(), because it's very hard to work out in the middle of all the
other streams of logic about substitution.

There's another glitch with braces I haven't looked at but I had to work
around in the parameter tests (possibly the most boring piece of zsh code
ever written):

%   array=(once bitten twice shy)              
%   print IF{${array},THEN}ELSE              
IF{once bitten twice shy,THEN}ELSE

Double-quoting ${array} fixes it, even more bizarrely.  This doesn't depend
on braceccl.  What's more, the full expansion works with RCEXPANDPARAM:

% print IF{${^array},THEN}ELSE 
IFonceELSE IFTHENELSE IFbittenELSE IFTHENELSE IFtwiceELSE IFTHENELSE IFshyELSE IFTHENELSE

-- 
Peter Stephenson <pws@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


  reply	other threads:[~2000-06-16 12:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-16 11:22 Sven Wischnowsky
2000-06-16 12:20 ` Peter Stephenson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-06-16  7:30 Sven Wischnowsky
2000-06-15 15:15 Sven Wischnowsky
2000-06-15 15:32 ` Bart Schaefer
2000-06-15  9:40 Sven Wischnowsky
2000-06-15  9:09 Sven Wischnowsky
2000-06-15  8:26 Sven Wischnowsky
2000-06-15  9:13 ` Bart Schaefer
2000-06-15  9:22   ` Peter Stephenson
2000-06-15 14:54 ` Oliver Kiddle
2000-06-14 16:07 Oliver Kiddle
2000-06-14 18:34 ` Peter Stephenson
2000-06-08  8:37 Sven Wischnowsky

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=0FW8002NDYAS0Z@la-la.cambridgesiliconradio.com \
    --to=pws@cambridgesiliconradio.com \
    --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).