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



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