From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28105 invoked from network); 17 Mar 1999 08:51:19 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 17 Mar 1999 08:51:19 -0000 Received: (qmail 16965 invoked by alias); 17 Mar 1999 08:48:54 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5830 Received: (qmail 10433 invoked from network); 17 Mar 1999 08:33:14 -0000 Date: Tue, 16 Mar 1999 12:50:22 +0100 (MET) Message-Id: <199903161150.MAA25602@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Peter Stephenson's message of Mon, 15 Mar 1999 14:49:12 +0100 Subject: Re: PATCH: param stuff and was: PATCH: 3.1.5-pws-12: _brace_parameter 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