Hello. Is it possible to prefix and join an array: % list=(a.tld b.tld c.tld) % tmp=(DNS:${^list}) % print ${(j., .)tmp} DNS:a.tld, DNS:b.tld, DNS:c.tld but directly, without tmp, something like: % print ${(j., .)(DNS:${^list})} -- sergio.
On Tue, Apr 28, 2020 at 7:15 PM sergio <sergio@outerface.net> wrote:
>
> Is it possible to prefix and join an array:
>
> % list=(a.tld b.tld c.tld)
> % print ${(j., .)(DNS:${^list})}
You almost had it:
% print ${(j., .)${:-DNS:${^list}}}
> % print ${(j., .)${:-DNS:${^list}}}
Haa, the secret was in ${name:-word}!
Thank you, Bart (:
--
sergio.
[-- Attachment #1: Type: text/plain, Size: 193 bytes --] >> % print ${(j., .)${:-DNS:${^list}}} > Haa, the secret was in ${name:-word}! > Thank you, Bart (: I think you can simplify it further to print ${(j., .):-DNS:${^list}} right?
2020-04-29 04:22:20 +0000, Eric Nielsen:
>
> >> % print ${(j., .)${:-DNS:${^list}}}
>
> > Haa, the secret was in ${name:-word}!
>
> > Thank you, Bart (:
>
> I think you can simplify it further to
> print ${(j., .):-DNS:${^list}}
> right?
See also the bash-style ${array/#/prefix} (well you'd also need
a [@] in bash):
print -r -- ${(j[, ]list/#/DNS:}
(also remember "print" like "echo" doesn't do what you want by
default, you need -r with print and -E with echo, misdesigns
inherited from ksh/PWB. And -- or - to mark the end of options).
--
Stephane