On Fri, Jan 31, 2025 at 01:42:38 +0100, Alfred Agrell wrote: > Hello > > https://git.savannah.gnu.org/cgit/bash.git/tree/doc/bash.info#n1842 > > '${PARAMETER:-WORD}' > If PARAMETER is unset or null, the expansion of WORD is > substituted. Otherwise, the value of PARAMETER is substituted. > > $ v=123 > $ echo ${v-unset} > 123 > > The heading says :-, but the example just says -. Which one is intended? Or > is it supposed to say that both are equivalent?
They both exist, and mean slightly different things. Right above the list of examples, there's this paragraph: When not performing substring expansion, using the forms documented be‐ low (e.g., :-), bash tests for a parameter that is unset or null. Omitting the colon results in a test only for a parameter that is un‐ set. Everyone overlooks this. Even POSIX finally caved in and added examples showing both syntaxes, not expecting the reader to extrapolate from multiple sources.