zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: join a string with a parameter value if it's not empy
Date: Fri, 3 Feb 2023 20:03:16 -0800	[thread overview]
Message-ID: <CAH+w=7ZdYR6qJz_VY28VjV6ZJY5Cfw5qBjTGpsvqS2zr_teTJA@mail.gmail.com> (raw)
In-Reply-To: <f7dce72b-274e-b754-8e1c-7bc92e822479@outerface.net>

On Fri, Feb 3, 2023 at 6:01 PM sergio <sergio@outerface.net> wrote:
>
> Is it possible to construct an array without a tmp parameter? Without
> splitting.

If you mean an array value to which you can (in the same operation)
apply expansion flags such as joining, not really, no.

If you mean without having to declare a temporary name, you can use
the positional parameters:

set -- $p 'string' whatever else
print -r -- "${(j.#.)@}"

Of course that means knowing $@, $1, $2, etc. aren't being used for
anything else.


  parent reply	other threads:[~2023-02-04  4:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 23:43 sergio
2023-02-04  0:20 ` Eric Nielsen
2023-02-04  2:01   ` sergio
2023-02-04  3:30     ` Eric Nielsen
2023-02-04  4:03     ` Bart Schaefer [this message]
2023-02-04  8:39       ` Stephane Chazelas
2023-02-04  0:23 ` Eric Nielsen

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='CAH+w=7ZdYR6qJz_VY28VjV6ZJY5Cfw5qBjTGpsvqS2zr_teTJA@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --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).