Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: join a string with a parameter value if it's not empy
- X-seq: zsh-users 28902
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: join a string with a parameter value if it's not empy
- Date: Sat, 4 Feb 2023 08:39:18 +0000
- Archived-at: <https://zsh.org/users/28902>
- In-reply-to: <CAH+w=7ZdYR6qJz_VY28VjV6ZJY5Cfw5qBjTGpsvqS2zr_teTJA@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, zsh-users@xxxxxxx
- References: <6e1b26963200efd1c6e7ed9a0dd976ded1ab72c9@hey.com> <f7dce72b-274e-b754-8e1c-7bc92e822479@outerface.net> <CAH+w=7ZdYR6qJz_VY28VjV6ZJY5Cfw5qBjTGpsvqS2zr_teTJA@mail.gmail.com>
2023-02-03 20:03:16 -0800, Bart Schaefer:
[...]
> 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.
Or use an anonymous function:
(){ print -r -- ${(j[#])@}; } 'some string' $'whatever\nelse'
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author