From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13297 invoked by alias); 24 Nov 2014 16:05:34 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19425 Received: (qmail 19213 invoked from network); 24 Nov 2014 16:05:31 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f4-b7f126d000001e9a-b3-547354ede360 Date: Mon, 24 Nov 2014 15:55:24 +0000 From: Peter Stephenson To: Zsh hackers list Subject: Re: ${^var} and word splitting Message-id: <20141124155524.0739b3ec@pwslap01u.europe.root.pri> In-reply-to: <20141124152628.GA5749@chaz.gmail.com> References: <20141124095637.GA5716@chaz.gmail.com> <20141124111201.161d8cf2__23261.8202259347$1416827641$gmane$org@pwslap01u.europe.root.pri> <20141124152628.GA5749@chaz.gmail.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplluLIzCtJLcpLzFFi42I5/e/4Vd23IcUhBgdeK1vsOLmS0YHRY9XB D0wBjFFcNimpOZllqUX6dglcGf2nWpgLbvBU7F2wg72B8TNnFyMnh4SAicSKBxMZIWwxiQv3 1rN1MXJxCAksZZRYu2U9O5TDJNG34z5LFyMHB4uAqsTiq3UgDWwChhJTN80GaxYR0JCYsncn mC0soC7R9ryPFcTmFbCXmL9sFxOIzSlgLHHm/1QWiJk7GCXezTnHDJLgF9CXuPr3ExPEFfYS M6+cYYRoFpT4MfkeC4jNLKAlsXlbEyuELS+xec1b5gmMArOQlM1CUjYLSdkCRuZVjKKppckF xUnpuYZ6xYm5xaV56XrJ+bmbGCFB+GUH4+JjVocYBTgYlXh4f/QUhgixJpYVV+YeYpTgYFYS 4e32Kg4R4k1JrKxKLcqPLyrNSS0+xMjEwSnVwLjeafcJBv/L3BNOCt7dMS/rX5REs9xnvx0b nqzZsch8SU85s7o2e+JLl7bFDkxtFxkTO5SnKU56HLCjuN/xpVbUVbu7yh1O0w73GQhNeqUc 7rKcNY6VnTni78bO+H1fT5VtWtj7RGPOMa64lvU5m2XFDKycquPmKik7nwlT2s7q3LQpd37d TyWW4oxEQy3mouJEAIcbpO4gAgAA On Mon, 24 Nov 2014 15:26:28 +0000 Stephane Chazelas wrote: > If I understand correctly, in zsh the removing of those are > accounted to null-removal in things like: > > $ print -l $=a > 1 > 2 > 3 > > But then it's not clear why they are removed there and not in: > > a=':a::b:' > IFS=: > print -l $=a I looked at the code and you're exactly right: it's not clear. There's a parameter determining how the split function behaves and there's an argument allownull that I already noted I didn't understand in the comment to sepsplit(), determining whether the argument being set will be empty or will be set to something that has no effect except preventing the argument being removed later. In the case in question this is zero. Consequently it's easy to change the behaviour in the second case... This doesn't cause any test failures. Unless anyone has any ideas why we do this, maybe we should simplify it like this? If anyone does have ideas, we should write a test for that case. There's one other case in parameter substitution to do with assignment within the substitution that presumably ought to be consistent. diff --git a/Src/subst.c b/Src/subst.c index 61aa1c1..17f35be 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -3322,7 +3322,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags) isarr = 0; } if (!ssub && (spbreak || spsep)) { - aval = sepsplit(val, spsep, 0, 1); + aval = sepsplit(val, spsep, 1, 1); if (!aval || !aval[0]) val = dupstring(""); else if (!aval[1]) pws