On Wed, Jun 25, 2025 at 17:47:31 +0000, Wartik, Steven P "Steve" via Bug 
reports for the GNU Bourne Again SHell wrote:
> After many years of staring at the Bash Reference Manual, I just noticed a 
> typo in Section 3.5.3 (Shell Parameter Expansion):
> 
> [cid:image003.jpg@01DBE5D7.B1DBC120]
> 
> The parameter in the echo command is missing a colon. It should be:
> 
> $ echo ${v:-unset}

Both of those are valid syntax, and they have *slightly* different
meanings.

${v-unset} expands to the value of "v" if it has any value assigned,
otherwise the literal string "unset".

${v:-unset} expands to the value of "v" if it has any value assigned
other than the empty string, otherwise the literal string "unset".

When performing a test of whether a variable is defined or undefined,
you want the no-colon form ${var-x}.  Presumably that's what the
example is doing, so the example is correct.

Reply via email to