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
On Fri, Feb 3, 2023 at 6:01 PM sergio <sergio@xxxxxxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author