> p='value' -> result: 'value_string'
> p='' -> result: 'string'

A simpler variation of your first solution:

$p${p:+_}string


--
Sent with HEY