Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: prefix and join an array
- X-seq: zsh-users 24816
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Eric Nielsen <eric@xxxxxxxxxxxxxxxx>
- Subject: Re: prefix and join an array
- Date: Thu, 30 Apr 2020 17:45:37 +0100
- Cc: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- In-reply-to: <SC1P152MB1758B1DA12D7C4E477BB5C53EFAD0__34252.3257875413$1588134220$gmane$org@SC1P152MB1758.LAMP152.PROD.OUTLOOK.COM>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mail-followup-to: Eric Nielsen <eric@xxxxxxxxxxxxxxxx>, "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <SC1P152MB1758B1DA12D7C4E477BB5C53EFAD0__34252.3257875413$1588134220$gmane$org@SC1P152MB1758.LAMP152.PROD.OUTLOOK.COM>
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