Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Forcing array interpretation in parameter substitution
- X-seq: zsh-workers 40971
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [PATCH] Forcing array interpretation in parameter substitution
- Date: Thu, 13 Apr 2017 14:03:53 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=1oIpWtzUuJdNdKH8W4gNrN8xycd2BoW/l4rb+9wfndA=; b=cbGThHUCCLbgOv9aqsdOF9pTsvJE3LDD/VBCV0Rms28RqXMBDp1x0DLn6Qr7Mvmzse 8fqvoSKvS61zQPsDh4BFVXu3L7WAviCL3TGaUrutcW2esLqV7ebyukUqSUrqFQVr00Yv QhX7aqo+58DRdN3+mhpX8c7yEXnZo5GnxeWjpqNhp6Ok3CJkp1sXOiY6wGJ23ZhH1Ocp l0qtGMh5f6Jfi0KhYb/06t+ByfPB5vUDrueqEEPryRakOGOhqTui0gTcEspCFmXuK8uD WwTkLUgoMFiICLZUUNjqu8x0HaVKRWeYhsl+Qqbh1pfEnKIR1kMj7uz148z2YMWFe5ic vn2A==
- In-reply-to: <etPan.58efa764.3d1b58ba.15fbc@MacMini.local>
- 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: <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 ...
Messages sorted by:
Reverse Date,
Date,
Thread,
Author