Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

zsh parameter expansion replacement pattern parses string differently if its input is a variable instead of inlined



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:]]##}}


Messages sorted by: Reverse Date, Date, Thread, Author