Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: $^=var and leading/trailing blanks
- X-seq: zsh-workers 39602
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: $^=var and leading/trailing blanks
- Date: Mon, 10 Oct 2016 20:18:36 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=sf0ObxJJ+oZW/gm9BZp3FjcJznju7yd4Rie4CgqGrtQ=; b=ruR1f71n70M9Z2Zlaice/xQ+GO7U2P5JVTq8kXHVZg4tJ7vaPEgtywf0IicNawMZM3 kuZ8Aec9aIHBHb4Q6mw97HRhzHv+zwHkQfc3uwnrWDYU998R1tGQ1aaFKCzbvn2PacTa 8gDV66Sgfiu25zT21bkgF5dzsgtTq6mElnTbuTwBn5k/zUWe0FJFy36g/RVwh35S0A2Q /nAHSiIqjamteOk4XSfvUvI8iPG3kOZKtlq+qKUlbXaY1RWbTL9cwH3Tapzudht3EzbC +8i4437XvJ4GJUeJkSZ+yQriv+NwV6liOXFuilmURNQh5ZjQv2j92gLPdwnhRzfYoUrr iv1A==
- In-reply-to: <20161008151244.GA7037@chaz.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20161008151244.GA7037@chaz.gmail.com>
On Sat, Oct 8, 2016 at 8:12 AM, Stephane Chazelas
<stephane.chazelas@xxxxxxxxx> wrote:
>
> Why the extra first and last element the the first two commands?
This is sort of explained under the s:: expansion flag:
For historical reasons, the usual behaviour that empty array
elements are retained inside double quotes is disabled for arrays
generated by splitting; hence the following:
line="one::three"
print -l "${(s.:.)line}"
produces two lines of output for one and three and elides the
empty field. To override this behaviour, supply the "(@)" flag as
well, i.e. "${(@s.:.)line}".
When you add the rcexpandparam flag, you get "the usual behavior" back
again (otherwise an array of only empty elements would behave like an
empty array and discard everything). When you nest the expansions,
the inner split gets the empty elements removed when it expands, and
then rcexpandparam applies to the remaining elements of that result.
You don't get two elements for the two leading spaces because
shwordsplit behaves that way. If you use (s: :) instead, then you do
get one empty element for each space.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author