From: Michal Politowski <mpol@charybda.icm.edu.pl>
To: zsh-users@zsh.org
Subject: Re: (s,:,) made right ("" is also an element)
Date: Fri, 13 Mar 2015 11:42:36 +0100 [thread overview]
Message-ID: <20150313104236.GA31303@meep.pl> (raw)
In-Reply-To: <20150313101208.GA5325@ramirez.u-strasbg.fr>
On Fri, 13 Mar 2015 11:12:08 +0100, Marc Chantreux wrote:
> hello,
>
> say i have
>
> PATH="/usr/bin::/bin"
> print -l ${(s,:,)PATH}
> foo=( ${(s,:,)PATH} )
> print $#foo
>
> because i have an empty element (which is also an element)
>
> i got
>
> /usr/bin
> /bin
> 2
>
>
> i expect
>
> /usr/bin
>
> /bin
> 3
>
> does someone know how to fix zsh?
print -l "${(@s,:,)PATH}"
foo=("${(@s,:,)PATH)")
It's described in the manual:
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}".
--
Michał Politowski
Talking has been known to lead to communication if practiced carelessly.
next prev parent reply other threads:[~2015-03-13 10:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 10:12 Marc Chantreux
2015-03-13 10:42 ` Michal Politowski [this message]
2015-03-13 14:16 ` Marc Chantreux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150313104236.GA31303@meep.pl \
--to=mpol@charybda.icm.edu.pl \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).