From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19743 invoked by alias); 11 Aug 2016 00:39:39 -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: 39019 Received: (qmail 641 invoked from network); 11 Aug 2016 00:39:39 -0000 X-Qmail-Scanner-Diagnostics: from mail-pa0-f49.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.220.49):SA:0(0.0/5.0):. Processed in 0.191896 secs); 11 Aug 2016 00:39:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts) 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=k6jiWCYQkKS+7CZUWke2lnIiwxgsJo0nsqZWNiF+rNg=; b=OlEpOJEViDNw42TMjoLHEJmzxyuw2VQEUhs4hpx1AZ7OrykGrnRJFGKNYcjjNHp/UG VG+iLNzL75UcyZTCLfQEWmIuv6WTT1B1LATfgJ16dzzppBCt0K7p9Qy+QX2nsQGtYxAy NECG7Xz8dWpGr5CMXXfRcHOv1hs+6imq14kjVaWGBx/h81KfsBiEI9WwQar37c2H3C2l PG5lnZnP1qTL/yTjCOwNCoTfV73Mn+7zhr7+psa/n3qm0jdXwOUEGlfRpndKMEWCCLJO WEAEfwYRow8X0wy6SWyALUtKMN+d4vXS91Fx5Z6XOlFR8G/EMkvr4yRFzO3g9/9r85Zx 38qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=k6jiWCYQkKS+7CZUWke2lnIiwxgsJo0nsqZWNiF+rNg=; b=PNFf9RJL3UDy9DFCTh9CcugH6+1jFHymUawgVBMsgqRENAsyPtmVx13JexMQzt1Xl/ MqMtHRKuWBPfsbk8NtBT4MgoynjDmu6shnm9okEdIDflTWtyJNdo9KG0qtZ3BGJ6jwH2 bDrTBUbWwcdSiVMhYsfOCxZmgL2QI3SUF3D0RLWWu/sVTqKKo8njz0iW93eUU5MwkESF ij7KrJyszRpqoCAUHckv+Gv7MVo86oBRcsUMOugY26ijWhD5pocNg0hep/0eNfH2wms2 UZKqwPEr/SvTTaS99vdCmPQhUirr0MuIzs8nytHO8F0+8wW5UwPx9KcW7/y3GWVDZ3i9 1whw== X-Gm-Message-State: AEkoousFyYKigtiaoRvnhsB/M1eBiZ87yyNv5LdThpZIC16aQrtPp8P4aZV+qxucRZvBag== X-Received: by 10.66.48.133 with SMTP id l5mr11956634pan.151.1470875972926; Wed, 10 Aug 2016 17:39:32 -0700 (PDT) From: Bart Schaefer Message-Id: <160810173935.ZM26818@torch.brasslantern.com> Date: Wed, 10 Aug 2016 17:39:35 -0700 In-Reply-To: <20160810135613.6c4fa427@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: [bug] shwordsplit not working on $@ when $# > 1" (Aug 10, 1:56pm) References: <20160808111626.GA19766@chaz.gmail.com> <20160808192734.21923640@ntlworld.com> <160808182124.ZM9355@torch.brasslantern.com> <20160810135613.6c4fa427@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: [bug] shwordsplit not working on $@ when $# > 1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Aug 10, 1:56pm, Peter Stephenson wrote: } Subject: Re: [bug] shwordsplit not working on $@ when $# > 1 } } > Existing tests still pass, but then they always did, this needs a } > new one. Holding off until we think of other edge cases. } } This tests the significant cases with $@. OK, this replaces both workers/39009 and workers/39013 -- to the latter it adds three more tests based on workers/39018. I also re-ordered the statements in the 39013 tests to make it obvious that IFS doesn't have an effect on the "set -- ..." statements. diff --git a/Src/subst.c b/Src/subst.c index e3af156..ae3e4c4 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -3454,13 +3454,22 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, * exception is that ${name:-word} and ${name:+word} will have already * done any requested splitting of the word value with quoting preserved. */ - if (ssub || (spbreak && isarr >= 0) || spsep || sep) { + if (ssub || spbreak || spsep || sep) { + int force_split = !ssub && (spbreak || spsep); if (isarr) { - val = sepjoin(aval, sep, 1); - isarr = 0; - ms_flags = 0; + if (nojoin == 0) { + val = sepjoin(aval, sep, 1); + isarr = 0; + ms_flags = 0; + } else if (force_split && nojoin == 2) { + /* Hack to simulate splitting individual elements: + * first join on what we later use to split + */ + val = sepjoin(aval, spsep, 1); + isarr = 0; + } } - if (!ssub && (spbreak || spsep)) { + if (force_split && !isarr) { aval = sepsplit(val, spsep, 0, 1); if (!aval || !aval[0]) val = dupstring(""); @@ -3527,7 +3536,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, } /* * TODO: It would be really quite nice to abstract the - * isarr and !issarr code into a function which gets + * isarr and !isarr code into a function which gets * passed a pointer to a function with the effect of * the promptexpand bit. Then we could use this for * a lot of stuff and bury val/aval/isarr inside a structure diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index 7cb297e..35630c5 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -1920,3 +1920,58 @@ print $array 0:"-" works after "[" in same expression (Dash problem) >foo two three + + ( + setopt shwordsplit + set -- whim:wham:whom + IFS=: + print -l $@ + ) +0:Splitting of $@ on IFS: single element +>whim +>wham +>whom + + ( + setopt shwordsplit + set -- one:two bucklemy:shoe + IFS=: + print -l $@ + ) +0:Splitting of $@ on IFS: multiple elements +# No forced joining in this case +>one +>two +>bucklemy +>shoe + + ( + set -- one:two bucklemy:shoe + print -l ${(s.:.)@} + ) +0:Splitting of $@ on (s): multiple elements +# Forced joining in this case +>one +>two bucklemy +>shoe + + ( + set -- one:two bucklemy:shoe + print -l ${(@s.:.)@} + ) +0:Splitting of $@ on (@s): multiple elements +# Forced non-joining in this case +>one +>two +>bucklemy +>shoe + + ( + set -- one:two bucklemy:shoe + IFS= + setopt shwordsplit + print -l ${@} + ) +0:Joining of $@ does not happen when IFS is empty +>one:two +>bucklemy:shoe