zsh-users
 help / color / mirror / code / Atom feed
* RE: prefix and join an array
@ 2020-04-29  4:22 Eric Nielsen
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Nielsen @ 2020-04-29  4:22 UTC (permalink / raw)
  To: zsh-users

[-- 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?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: prefix and join an array
       [not found] <SC1P152MB1758B1DA12D7C4E477BB5C53EFAD0__34252.3257875413$1588134220$gmane$org@SC1P152MB1758.LAMP152.PROD.OUTLOOK.COM>
@ 2020-04-30 16:45 ` Stephane Chazelas
  0 siblings, 0 replies; 5+ messages in thread
From: Stephane Chazelas @ 2020-04-30 16:45 UTC (permalink / raw)
  To: Eric Nielsen; +Cc: zsh-users

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: prefix and join an array
  2020-04-29  3:51 ` Bart Schaefer
@ 2020-04-29  4:09   ` sergio
  0 siblings, 0 replies; 5+ messages in thread
From: sergio @ 2020-04-29  4:09 UTC (permalink / raw)
  To: zsh-users


> % print ${(j., .)${:-DNS:${^list}}}

Haa, the secret was in ${name:-word}!

Thank you, Bart (:

-- 
sergio.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: prefix and join an array
  2020-04-29  2:14 sergio
@ 2020-04-29  3:51 ` Bart Schaefer
  2020-04-29  4:09   ` sergio
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2020-04-29  3:51 UTC (permalink / raw)
  To: sergio; +Cc: Zsh Users

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}}}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* prefix and join an array
@ 2020-04-29  2:14 sergio
  2020-04-29  3:51 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: sergio @ 2020-04-29  2:14 UTC (permalink / raw)
  To: zsh-users

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-30 16:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29  4:22 prefix and join an array Eric Nielsen
     [not found] <SC1P152MB1758B1DA12D7C4E477BB5C53EFAD0__34252.3257875413$1588134220$gmane$org@SC1P152MB1758.LAMP152.PROD.OUTLOOK.COM>
2020-04-30 16:45 ` Stephane Chazelas
  -- 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

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).