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: Tue, 16 Mar 1999 12:50:22 +0100 (MET) [thread overview]
Message-ID: <199903161150.MAA25602@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Peter Stephenson's message of Mon, 15 Mar 1999 14:49:12 +0100
Peter Stephenson wrote:
> > The behavior is a bit weird, though, because `${foo-bar}' uses
> > `multsub', too. I haven't changed the call to it, yet, so the result
> > is that the `bar' is broken into an array -- always. This means that
> > `${#:-$foo}' will yield `1' for strings and the number of elements
> > if `bar' is `$baz' where `baz' is an array. I didn't change it
> > because I wanted to ask what it should do first, suggestions are:
> >
> > 1) let it treat the `bar' always as a string (i.e. let it never be
> > split into array elements); I guess this is what most people
> > would expect (and in the manual the thing is called `word')
>
> Since (without shwordsplit)
>
> % args() { print $#; }
> % args ${foo:-foo bar}
> 1
>
> this is the natural thing to do.
I liked this one best, too, so the patch below implements it.
> > 2) like 1), but if combined with the `A' flag, let it be treated as
> > an array
>
> Some extension like this is reasonable, but the obvious candidate is
> ${(w)#:-foo bar}, which is supposed to have exactly this effect on $# for a
> string.
>
> % foo="foo bar"
> % print ${(w)#foo}
> 2
Right, hadn't thought of that.
Bye
Sven
--- os/subst.c Mon Mar 15 10:52:31 1999
+++ Src/subst.c Tue Mar 16 12:46:13 1999
@@ -1273,7 +1273,7 @@
case '-':
if (vunset) {
val = dupstring(s);
- multsub(&val, &aval, &isarr, NULL);
+ multsub(&val, NULL, &isarr, NULL);
copied = 1;
}
break;
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-03-17 8:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-16 11:50 Sven Wischnowsky [this message]
1999-03-25 12:00 ` ${...:-...} again and subst clarification E: " Andrej Borsenkow
-- strict thread matches above, loose matches on Subject: below --
1999-03-17 14:59 Sven Wischnowsky
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-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=199903161150.MAA25602@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).