From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2218 invoked by alias); 24 Nov 2014 15:26:41 -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: 19424 Received: (qmail 7110 invoked from network); 24 Nov 2014 15:26:39 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=isUSKLzLA20reF3s+sLSDFD8oNmyRb77g7fGYrM/rp0=; b=jz5z2rq8ZXgfv7WYeuQUEBuVYrXCTpvUkbt6uyLDozfYbmDOfjpLgHxYspcbf1oEoa gLwGRAaj1qDnLTp/smyqIWADISw6e5Ee7bSvjik8sVCuGaWtprW9slhbQDk0HtwoiN+G QZKq+nVqR6vpA2vHBDiXEcQWdmEsRP2pvCJfpYwRh+Wgeg2Qb7EEpwqakUPGzxwY0LE7 gU/5eDlwCdMv4Dgz0o0goRLFQd1/h6hmB72zHfcG1NrkzLT9e7DsmKCnF2SgIYw+jZii IidDUnYYKgn5mp+pCy1XjntTGIOhpKnKS4muMNmOmYaUKwd0W12d1bGAS81I1MXio4eB Xx+Q== X-Received: by 10.194.87.34 with SMTP id u2mr35355600wjz.42.1416842790453; Mon, 24 Nov 2014 07:26:30 -0800 (PST) Date: Mon, 24 Nov 2014 15:26:28 +0000 From: Stephane Chazelas To: Peter Stephenson Cc: Zsh hackers list Subject: Re: ${^var} and word splitting Message-ID: <20141124152628.GA5749@chaz.gmail.com> Mail-Followup-To: Peter Stephenson , Zsh hackers list References: <20141124095637.GA5716@chaz.gmail.com> <20141124111201.161d8cf2__23261.8202259347$1416827641$gmane$org@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141124111201.161d8cf2__23261.8202259347$1416827641$gmane$org@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.21 (2010-09-15) 2014-11-24 11:12:01 +0000, Peter Stephenson: > 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. OK thanks. that's a difference from other shells I was not aware of and it seems to be as documented indeed. The source of my confusion can be simplified to: ~$ a=' 1 2 3 ' ~$ printf '%s\n' "${=a}" 1 2 3 ~$ In other shells, leading/trailing _IFS white space_ characters are ignored as part of word splitting, not in zsh. 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 ? -- Stephane