From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,RDNS_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: (qmail 1464 invoked from network); 11 Mar 2020 10:14:36 -0000 Received-SPF: pass (primenet.com.au: domain of zsh.org designates 203.24.36.2 as permitted sender) receiver=inbox.vuxu.org; client-ip=203.24.36.2 envelope-from= Received: from unknown (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTP; 11 Mar 2020 10:14:36 -0000 Received: (qmail 14613 invoked by alias); 11 Mar 2020 10:14:18 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24722 Received: (qmail 16597 invoked by uid 1010); 11 Mar 2020 10:14:17 -0000 X-Qmail-Scanner-Diagnostics: from mailout2.w1.samsung.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25744. spamassassin: 3.4.2. Clear:RC:0(210.118.77.12):SA:0(-7.0/5.0):. Processed in 3.078323 secs); 11 Mar 2020 10:14:17 -0000 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.samsung.com designates 210.118.77.12 as permitted sender) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200311101335euoutp02bc84aeef7fe3f712d080f42c42f4ece6~7OFFS4KAt2082520825euoutp02H X-AuditID: cbfec7f2-ef1ff7000001ef66-0d-5e68b9cf5816 Message-ID: <1583921614.4472.14.camel@samsung.com> Subject: Re: zsh parameter expansion replacement pattern parses string differently if its input is a variable instead of inlined From: Peter Stephenson To: Date: Wed, 11 Mar 2020 10:13:34 +0000 In-Reply-To: X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsWy7djPc7rnd2bEGex9pmyx4+RKRgdGj1UH PzAFMEZx2aSk5mSWpRbp2yVwZaw79o69oIO34lrLAeYGxg3cXYwcHBICJhLvLop2MXJyCAms YJT4f12+i5ELyO5hklj1fx8ThNPNJNG4dgkjSBVIw4vD91kgEssZJc5fvcgIV7Xq+So2COcM o8Shs9uh+i8wSrQ1rWUH6ecVMJKYOfMgWIuwQBOjxIKGWWCD2QQMJaZumg1miwiISzyb+Y0F xGYRUJXYdPwNWJxTIFBi6fVP7BCHaEhsuHmMCWKooMTJmU/A6pkF5CWat85mBlkgIXCfTWJK 71Koy10kXlzqZoKwhSVeHd8CNUhG4vTkHhaIhnZGiTWTXrNDOD2MEpuO3oHqtpbouw3yKgfQ Ck2J9bv0IcKOEvd23GWDhCWfxI23ghBH8ElM2jadGSLMK9HRJgRRrSaxo2krI0RYRuLpGoUJ jEqzkHwwC8kHsxBWLWBkXsUonlpanJueWmyYl1quV5yYW1yal66XnJ+7iRGYDE7/O/5pB+PX S0mHGAU4GJV4eF/UpccJsSaWFVfmHmKU4GBWEuGNlwcK8aYkVlalFuXHF5XmpBYfYpTmYFES 5zVe9DJWSCA9sSQ1OzW1ILUIJsvEwSnVwLhzZW/orOK8S/mRjasn2zCXp+QtlFhgvPrWw8g1 lXof5i5yceXrbX8k/W3PvoLuTRbSvF4b2cVdVCc9YW1eqb3wX2LqP9tG321/lsmyyfydz7Tg 3to7XCkKgju/OZtsc8qwuP5AtylD+NfHvbqfP/Pr2fN2ioctql7tmZQlnrr5rMOabZcmuSmx FGckGmoxFxUnAgBMAubTAgMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeLIzCtJLcpLzFFi42I5/e/4Pd3zOzPiDF53C1nsOLmS0YHRY9XB D0wBjFF6NkX5pSWpChn5xSW2StGGFkZ6hpYWekYmlnqGxuaxVkamSvp2NimpOZllqUX6dgl6 GeuOvWMv6OCtuNZygLmBcQN3FyMnh4SAicSLw/dZuhi5OIQEljJKXDqzhQUiISPx6cpHdghb WOLPtS42iKJOJon535qhOs4wSry70sAI4VxglFg+5z0bSAuvgJHEzJkHwRLCAk2MEgsaZjGC JNgEDCWmbpoNZosIiEs8m/kNbB+LgKrEpuNvwOKcAoESS69/Yoc76mD3dLAEs4CmROv231BH aUhsuHmMCWKboMTJmU9YIGrkJZq3zmaewCg0C0nLLCRls5CULWBkXsUoklpanJueW2yoV5yY W1yal66XnJ+7iREYA9uO/dy8g/HSxuBDjAIcjEo8vC/q0uOEWBPLiitzDzFKcDArifDGywOF eFMSK6tSi/Lji0pzUosPMZoCfTSRWUo0OR8Yn3kl8YamhuYWlobmxubGZhZK4rwdAgdjhATS E0tSs1NTC1KLYPqYODilGhgF609ElPHF1v/snCNmZ6MoKpi480A43xqXJ0x39atOPtqy1kdp 8UKJM5cmbxX9zVvE4zttZ2KO367F+szSO5WuPK/a/Wsnq77mlsmvlWsNEtmSjrXvCOfmqdCs n8i7wfm1y+olJXuPPuB3dDRf9ObN1MSl67rL1Z9Pvviy9druOpOYuoPPz7ArsRRnJBpqMRcV JwIAYrOFzpcCAAA= X-CMS-MailID: 20200311101335eucas1p12acb84cc03b3e4b3b308dc8c9a3a42f2 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200310200552eucas1p283e8a92d686e34198f78b647370f5a24 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200310200552eucas1p283e8a92d686e34198f78b647370f5a24 References: On Tue, 2020-03-10 at 16:04 -0400, Ross Goldberg wrote: > How can I inline the curl call yet still filter out the 3 values? >  > #!/usr/bin/env zsh >  > setopt EXTENDED_GLOB >  > # variable: 3 values are correctly filtered out > versions=$(curl '--silent' '--location' ' > https://protect2.fireeye.com/url?k=1c92524f-415c53fb-1c93d900-000babdfecba-907de8ae2883278c&u=https://api.sdkman.io/2/candidates/groovy/darwin/versions/list?current=2.5.8&installed=2.5.8 > ') > printf -- '%s\n' ${${(Z+n+)versions//[*+>][ *+>]# [[:graph:]]##}} >  > # inlined: 3 values are not filtered out > printf -- '%s\n' ${${(Z+n+)$(curl '--silent' '--location' ' > https://protect2.fireeye.com/url?k=7fed1228-2223139c-7fec9967-000babdfecba-dd90873f5cc32e48&u=https://api.sdkman.io/2/candidates/groovy/darwin/versions/list?current=2.5.8&installed=2.5.8')//[*+>][ > *+>]# [[:graph:]]##}} If I'm following correctly (a simpler example would probably help if I'm missing the point, though I think what I've done gives what you want), you need to put double quotes around the "$(curl ...)" part. printf -- '%s\n' ${${(Z+n+)"$(curl '--silent' '--location' 'https://protect2.fireeye.com/url?k=7fed1228-2223139c-7fec9967-000babdfecba-dd90873f5cc32e48&u=https://api.sdkman.io/2/candidates/groovy/darwin/versions/list?current=2.5.8&installed=2.5.8')"//[*+>][ *+>]# [[:graph:]]##}} The big difference is that the assignment in the other version is already turning the value into a single word, whereas in the second case you will get the output split into a set of words; the substitution then operates on those words separately, which isn't what you want. pws