Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

join a string with a parameter value if it's not empy



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