Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ${^var} and word splitting
- X-seq: zsh-users 19424
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: ${^var} and word splitting
- Date: Mon, 24 Nov 2014 15:26:28 +0000
- Cc: Zsh hackers list <zsh-users@xxxxxxx>
- 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==
- In-reply-to: <20141124111201.161d8cf2__23261.8202259347$1416827641$gmane$org@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: Peter Stephenson <p.stephenson@xxxxxxxxxxx>, Zsh hackers list <zsh-users@xxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20141124095637.GA5716@chaz.gmail.com> <20141124111201.161d8cf2__23261.8202259347$1416827641$gmane$org@pwslap01u.europe.root.pri>
2014-11-24 11:12:01 +0000, Peter Stephenson:
> On Mon, 24 Nov 2014 09:56:37 +0000
> Stephane Chazelas <stephane.chazelas@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author