zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] Forcing array interpretation in parameter substitution
Date: Thu, 13 Apr 2017 14:03:53 -0700	[thread overview]
Message-ID: <170413140353.ZM11819@torch.brasslantern.com> (raw)
In-Reply-To: <etPan.58efa764.3d1b58ba.15fbc@MacMini.local>

On Apr 13,  6:29pm, Sebastian Gniazdowski wrote:
}
} Just realized that this isn't a "5.0.2" or so thing.
} 
} I wonder if there can be any workaround for older versions

This is sort of ugly, because (z) itself is failing to return an array
when the string to be split has only one word.  The workaround described
in users/22497 does the right thing for (s::) but not for (z).

For (z) you need to force array-ness by splitting some other way and
then also add (z).  E.g.:

var="abc"; echo ${${(Afz)reply::=$var}[1]}

Of course if there are embedded newlines that are quoted, (f) will
break them incorrectly, so you need something more like

echo ${${(Aps:\0:z)reply::=$var}[1]}

Which still breaks if you have embedded NUL bytes in $var, but ...


  reply	other threads:[~2017-04-13 21:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-13 16:29 Sebastian Gniazdowski
2017-04-13 21:03 ` Bart Schaefer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-02-25 22:47 Bart Schaefer

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=170413140353.ZM11819@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).