bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Docs typo, :- vs -


From: Greg Wooledge
Subject: Re: Docs typo, :- vs -
Date: Thu, 30 Jan 2025 21:12:57 -0500
User-agent: Mutt/1.10.1 (2018-07-13)

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]