From: Stephane Chazelas <stephane@chazelas.org>
To: Eric Nielsen <eric@amalgamar.com.br>
Cc: "zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: prefix and join an array
Date: Thu, 30 Apr 2020 17:45:37 +0100 [thread overview]
Message-ID: <20200430164537.cdex2atmba5fdmnp@chazelas.org> (raw)
In-Reply-To: <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
next parent reply other threads:[~2020-04-30 16:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <SC1P152MB1758B1DA12D7C4E477BB5C53EFAD0__34252.3257875413$1588134220$gmane$org@SC1P152MB1758.LAMP152.PROD.OUTLOOK.COM>
2020-04-30 16:45 ` Stephane Chazelas [this message]
2020-04-29 4:22 Eric Nielsen
-- strict thread matches above, loose matches on Subject: below --
2020-04-29 2:14 sergio
2020-04-29 3:51 ` Bart Schaefer
2020-04-29 4:09 ` sergio
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=20200430164537.cdex2atmba5fdmnp@chazelas.org \
--to=stephane@chazelas.org \
--cc=eric@amalgamar.com.br \
--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).