From: Ross Goldberg <ross.goldberg@gmail.com>
To: zsh-users@zsh.org
Subject: zsh parameter expansion replacement pattern parses string differently if its input is a variable instead of inlined
Date: Tue, 10 Mar 2020 16:04:09 -0400 [thread overview]
Message-ID: <CAAEcvMp4D3zna84wGR5AhQWY5Q-XDA1cWEP4982qQ=qY2i7qbw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1061 bytes --]
A zsh parameter expansion replacement pattern parses string differently if
its input is a variable instead of inlined.
I assume that it has something to do with character escaping, but am not
sure how to work around it.
In the code below, >, * & 2.5.8 should be filtered out of the printf
output, which correctly occurs in the first parameter expansion using the
variable named versions.
But when the curl call is inlined, then the above 3 values are not filtered
out.
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://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://api.sdkman.io/2/candidates/groovy/darwin/versions/list?current=2.5.8&installed=2.5.8')//[*+>][
*+>]# [[:graph:]]##}}
next reply other threads:[~2020-03-10 20:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200310200552eucas1p283e8a92d686e34198f78b647370f5a24@eucas1p2.samsung.com>
2020-03-10 20:04 ` Ross Goldberg [this message]
2020-03-11 10:13 ` Peter Stephenson
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='CAAEcvMp4D3zna84wGR5AhQWY5Q-XDA1cWEP4982qQ=qY2i7qbw@mail.gmail.com' \
--to=ross.goldberg@gmail.com \
--cc=zsh-users@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).