How to append a string in bash only when the variable is defined and not null?
<p>I want to obtain the following behaviour in <code>bash</code> and I have the impression that this is possible in one line but I don't know the exact syntax (and was not able to find it in the doc).</p>

<pre><code>FOO=somename
BAR=123
</code></pre>

<p>If BAR is not defined or empty the final result should be just <code>somename</code>.
If BAR has a value the final result should be <code>somename-123</code></p>

<p>Current example is adding a dash even when BAR is not defined and that's not what I want.</p>

<p>echo "${FOO}-${BAR}"</p>