Malcolm Herbertmherbert@chinwag.org
Sep 21, 2026, 12:29 PMin bash, is there any way to do parameter expansion/replacement such that the output is (eg) "A" when a variable is defined and "B" when it isn't?
there's the "alternate" form: ${foo:+A} which returns "A" when $foo is defined ...
then there's the "defaulting" form: ${foo:-B} which returns "B" when $foo is not defined ... but crucially _does_ return the value of $foo when it is defined
... I can't see any way to combine these so that the value of $foo is not returned in either case, just "A" or "B" without using some explicit test