From: Han Pingtian <hanpt@linux.vnet.ibm.com>
To: zsh-workers@zsh.org
Subject: Re: (s) splitting - is there any way to provide "dynamic" separator
Date: Sat, 11 Oct 2014 08:38:17 +0800 [thread overview]
Message-ID: <20141011003817.GA2786@localhost.localdomain> (raw)
In-Reply-To: <5437856D.3050700@gmail.com>
On Fri, Oct 10, 2014 at 01:06:21PM +0600, Vasiliy Ivanov wrote:
> On 10.10.2014 07:45, Bart Schaefer wrote:
> > On Oct 9, 9:00pm, Vasiliy Ivanov wrote:
> > }
> > } Sorry if I (maybe) missed something obvious, but I failed to find a
> > } way to use separator from parameter
> > } (e.g. a='1:2:3'; sep=':'; print -l ${(s.$sep.)a}).
> >
> > Something like this:
> >
> > print -l ${(ps.\0.)a//$sep/$'\0'}
> >
> > (Assuming there are no nul-bytes in the value of $a to begin with.)
> >
>
> Thanks, this seems more elegant than «eval» way, but I failed to understand this:
>
> % a='11::22:33'; b=("${(@s.:.)a}"); print $#b
> 4 (as expected)
>
> but (I expected same result)
>
> % a='11::22:33'; sep=':'; b=("${(@ps.\0.)a//$sep/$'\0'}"); print $#b
> 1
>
% a=11::22:33;print -l ${(ps.\0.)a//:/$'\0'}
11
22
33
% a=11::22:33;print -l "${(ps.\0.)a//:/$'\0'}"
11$''$''22$''33
%
Looks like $'\0' in double-quotes is converted to $'' and it doesn't equal
to \0 ?
next prev parent reply other threads:[~2014-10-11 0:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-09 15:00 (s) splitting – is there any way to provide «dynamic» separator Vasiliy Ivanov
2014-10-09 21:14 ` Peter Stephenson
2014-10-09 21:48 ` Mikael Magnusson
2014-10-10 18:26 ` Peter Stephenson
2014-10-13 10:30 ` Peter Stephenson
2014-10-10 1:45 ` (s) splitting - is there any way to provid e "dynamic" separator Bart Schaefer
2014-10-10 7:06 ` (s) splitting - is there any way to provide " Vasiliy Ivanov
2014-10-11 0:38 ` Han Pingtian [this message]
2014-10-11 3:31 ` Bart Schaefer
2014-10-11 11:52 ` Han Pingtian
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=20141011003817.GA2786@localhost.localdomain \
--to=hanpt@linux.vnet.ibm.com \
--cc=zsh-workers@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).