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

Re: prefix and join an array



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



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