Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
join a string with a parameter value if it's not empy
- X-seq: zsh-users 28894
- From: sergio <sergio@xxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: join a string with a parameter value if it's not empy
- Date: Sat, 4 Feb 2023 03:43:26 +0400
- Archived-at: <https://zsh.org/users/28894>
- List-id: <zsh-users.zsh.org>
Hello.
I'd like to prepend a string with a parameter's value + separator.
p='value' -> result: 'value_string'
p='' -> result: 'string'
I found two solutions:
${p:+${p}_}string
${(j:_:)${=${:-$p string}}}
but both looks too complicated for my feel.
Is there something simpler and prettier?
--
sergio.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author