From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8163 invoked by alias); 24 Nov 2014 11:12:08 -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: 19423 Received: (qmail 17057 invoked from network); 24 Nov 2014 11:12:06 -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-17-54731282be25 Date: Mon, 24 Nov 2014 11:12:01 +0000 From: Peter Stephenson To: Zsh hackers list Subject: Re: ${^var} and word splitting Message-id: <20141124111201.161d8cf2@pwslap01u.europe.root.pri> In-reply-to: <20141124095637.GA5716@chaz.gmail.com> References: <20141124095637.GA5716@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+NgFuphluLIzCtJLcpLzFFi42I5/e/4Vd0moeIQg83rRS12nFzJ6MDoserg B6YAxigum5TUnMyy1CJ9uwSujEPPvzIXbOCo6H7wl7WBcQ5bFyMnh4SAiUTjnRuMELaYxIV7 68HiQgJLGSUaf8l3MXKB2EwSt5ueMYEkWARUJR6v6GcBsdkEDCWmbpoN1iwioCExZe9OMFtY QF2i7XkfK4jNK2Av8fDWfHYQm1PAWGLajT1MEAuMJM43fGMGsfkF9CWu/v3EBHGEvcTMK2cY IXoFJX5Mvge2i1lAS2LztiZWCFteYvOat8wTGAVmISmbhaRsFpKyBYzMqxhFU0uTC4qT0nMN 9YoTc4tL89L1kvNzNzFCQvDLDsbFx6wOMQpwMCrx8P7oKQwRYk0sK67MPcQowcGsJMK7j7E4 RIg3JbGyKrUoP76oNCe1+BAjEwenVAOj7/+7MWfP1XQ/UXKPVJhsM/n3y87gSU/NZzdsPfeV 25+FR9L6VtTyfSHa6gVnri0QaSth5T+ueWRZcIPuVqdfMzWUGVvnxJ6NFDmYPY/5qGzMZPHM 1xnv/y0XaNn7936xoM3T2o9hi1oNOGoqZK4oW0dmCh2tTK3sNGZQy3c0MuE59jt1YqcSS3FG oqEWc1FxIgDh1n4yHwIAAA== On Mon, 24 Nov 2014 09:56:37 +0000 Stephane Chazelas wrote: > $ a=' 1 2 3 ' > $ print -l $=a > 1 > 2 > 3 > $ print -l x$^=a > x > x1 > x2 > x3 > x > $ print -l x${^${=a}} > x1 > x2 > x3 > > > Why the extra "x" lines with x$^=a ? In the case of $^=a, the steps are - split a. There's whitespace start and end so you get null elements corresponding to those. - add the x's in front - remove remaining null elements, but there aren't any. With nested expansion, you get - split a: same result - remove null elements (before the x's get added). - add the x's - remove null elements for this level (but there aren't any more) C.f. $ print -l x${^"${(@)=a}"} x x1 x2 x3 x which has been told explicitly to keep the null elements despite the nesting. -- Peter Stephenson Principal Software Engineer Tel: +44 (0)1223 434724 Samsung Cambridge Solution Centre St John's House, St John's Innovation Park, Cowley Road, Cambridge, CB4 0DS, UK