This is what I’ve found works best for me, taking inspiration from the other answers:
if [ -z "${varname-}" ]; then
...
varname=$(...)
fi
This is what I’ve found works best for me, taking inspiration from the other answers:
if [ -z "${varname-}" ]; then
...
varname=$(...)
fi