zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: RE: PATCH: param stuff and was: PATCH: 3.1.5-pws-12: _brace_parameter
Date: Wed, 17 Mar 1999 15:59:06 +0100 (MET)	[thread overview]
Message-ID: <199903171459.PAA27145@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Andrej Borsenkow"'s message of Wed, 17 Mar 1999 17:35:30 +0300


Andrej Borsenkow wrote:

> > It's actually completely predictable, once you know the rule.
> >
> 
> 'course. What I tried to explain, that there is probably a dozen of people,
> who know these rules :-( (correct me if I'm wrong)
> 
> O.K. Is it intentional?
> 
> itsrm2% foo=(axb cxd)
> itsrm2% print -l ${(s/x/)foo}
> a
> b c
> d
> 
> I won't argue, if this is correct or not. I'd just to point out
> a) if this is intentional, it should be documented
> b) it is very different from word splitting (which is referred to in
> manual). In this case, *every* resulting word is splitted:
> 
> itsrm2% foo=("a b" "c d")
> itsrm2% print -l ${=foo}
> a
> b
> c
> d

The `s' flag just says where to split -- without it is done at the
well known places, with it it is done only at the string given with
the flag.

> The second question is, what is applied first - flags or modifications?
> Again, after soms tests :-)
> 
> itsrm2% foo=(ax1 bx1)
> itsrm2% print -l ${(s/x/)foo%%1*}
> a
>  b
> 
> I don't argue, that it may be predictable. Unfortunately, I simply fail to
> find the rule ...

Modification is done first. Splitting is done at the very end, in this 
case.

So the above does: apply the `%%1*', yielding the two elements `ax'
and `bx'. The `s' flag makes them be joined as usual and then broken at 
the `x's, yielding the three elements `a', ` b', and `'. Since you
didn't enclose it in quotes that last one is removed so you can't see
it. But with `"${(@s/x/)foo%%1*}" you can. And I can almost see you
trying `print -l "${(s/x/)foo%%1*}" now ;-) Perhaps surprisingly this
gives `a' and `', because without the `(@)' flag, the array elements
are first joined and re-separated at the `x's and then the `%%1*' is
applied -- which looks a bit like a bug, but then again, maybe not.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


             reply	other threads:[~1999-03-17 15:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-17 14:59 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-03-17 10:35 Sven Wischnowsky
1999-03-17  9:09 Sven Wischnowsky
1999-03-17  9:59 ` Andrej Borsenkow
1999-03-17 10:08   ` Peter Stephenson
1999-03-17 14:35     ` Andrej Borsenkow
1999-03-17 14:52       ` Peter Stephenson
1999-03-16 11:50 Sven Wischnowsky
1999-03-15  9:46 Sven Wischnowsky
1999-03-15 13:49 ` Peter Stephenson
1999-03-16 18:07 ` Andrej Borsenkow

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=199903171459.PAA27145@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --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).