From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11543 invoked by alias); 9 Oct 2014 21:15:04 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33409 Received: (qmail 20590 invoked from network); 9 Oct 2014 21:15:02 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Originating-IP: [80.3.229.105] X-Spam: 0 X-Authority: v=2.1 cv=AoZg3YNP c=1 sm=1 tr=0 a=uz1KDxDNIq33yePw376BBA==:117 a=uz1KDxDNIq33yePw376BBA==:17 a=NLZqzBF-AAAA:8 a=uObrxnre4hsA:10 a=jPJDawAOAc8A:10 a=IkcTkHD0fZMA:10 a=pGLkceISAAAA:8 a=Z4Zf1xvDB_3q6S40I-cA:9 a=QEXdDO2ut3YA:10 a=MSl-tDqOz04A:10 a=_dQi-Dcv4p4A:10 Date: Thu, 9 Oct 2014 22:14:59 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: (s) splitting =?UTF-8?B?4oCT?= is there any way to provide =?UTF-8?B?wqtkeW5hbWljwrs=?= separator Message-ID: <20141009221459.7512f179@pws-pc.ntlworld.com> In-Reply-To: <5436A310.7040101@gmail.com> References: <5436A310.7040101@gmail.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, 09 Oct 2014 21:00:32 +0600 Vasiliy Ivanov wrote: > Sorry if I (maybe) missed something obvious, but I failed to find a way t= o use separator from > parameter (e.g. a=3D'1:2:3'; sep=3D':'; print -l ${(s.$sep.)a}). > I think this is because expansion/substitution are not available in > flags? If so, is there any another way for such a =C2=ABdynamic=C2=BB sp= litting? I don't think you've missed anything obvious or elegant. One way is (){ local IFS=3D$sep print -l ${=3Da} } Or if you can rely on not having whitespace print -l ${=3D${a//:/ }} Or, of course, eval print -l '${(s.'$sep'.)a}' as long as you can sanity check $sep. Of course there's nothing to stop us adding a simple parameter substitution as a special case at this point (or any similarly delimited parameter argument) ... Can't see how this can do much harm since it sure as heck *looks* like a parameter expansion. diff --git a/Src/subst.c b/Src/subst.c index 1aa9b98..5727c12 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -1385,12 +1385,23 @@ static char * untok_and_escape(char *s, int escapes, int tok_arg) { int klen; - char *dst; + char *dst =3D NULL; =20 - untokenize(dst =3D dupstring(s)); - if (escapes) { - dst =3D getkeystring(dst, &klen, GETKEYS_SEP, NULL); - dst =3D metafy(dst, klen, META_HREALLOC); + if ((*s =3D=3D String || *s =3D=3D Qstring) && s[1]) { + char *pstart =3D s+1, *pend; + for (pend =3D pstart; *pend; pend++) + if (!iident(*pend)) + break; + if (!*pend) { + dst =3D dupstring(getsparam(pstart)); + } + } + if (dst =3D=3D NULL) { + untokenize(dst =3D dupstring(s)); + if (escapes) { + dst =3D getkeystring(dst, &klen, GETKEYS_SEP, NULL); + dst =3D metafy(dst, klen, META_HREALLOC); + } } if (tok_arg) shtokenize(dst); --=20 Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/