help-bash
[Top][All Lists]
Advanced

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

Re: ${param+x} ?


From: Andreas Kähäri
Subject: Re: ${param+x} ?
Date: Tue, 19 Dec 2023 12:16:46 +0100

On Tue, Dec 19, 2023 at 12:12:46PM +0100, lacsaP Patatetom wrote:
> Le mar. 19 déc. 2023 à 12:03, Davide Brini <dave_br@gmx.com> a écrit :
> 
> > On Tue, 19 Dec 2023 11:38:50 +0100, lacsaP Patatetom <patatetom@gmail.com>
> > wrote:
> >
> > > this form `${param+x}` is not documented (man) but is accepted by bash
> > and
> > > differs from `${param:+x}` :
> >
> > It IS documented:
> >
> > When not  performing  substring  expansion,  using the forms documented
> > below (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 unset.
> >
> > --
> > D.
> >
> >
> "Omitting the colon results in a test only for a parameter that is unset."
> oh yes, I missed it ! :-(
> 
> so, what's the point of this test `[ -z ${param+x} ]`, which will always be
> true ?

The test is not true if the variable is set to the empty string.

-- 
Andreas (Kusalananda) Kähäri
Uppsala, Sweden

.



reply via email to

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