help-bash
[Top][All Lists]
Advanced

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

Re: ${param+x} ?


From: lacsaP Patatetom
Subject: Re: ${param+x} ?
Date: Tue, 19 Dec 2023 13:52:19 +0100

Le mar. 19 déc. 2023 à 13:19, Greg Wooledge <greg@wooledge.org> a écrit :

> On Tue, Dec 19, 2023 at 12:12:46PM +0100, lacsaP Patatetom wrote:
> > so, what's the point of this test `[ -z ${param+x} ]`, which will always
> be
> > true ?
>
> That expansion is incorrect.  What you *want* is [ -n "${param+x}" ]
> or simply [ "${param+x}" ].
>
> If 'param' is unset, "${param+x}" expands to the empty string, and
> you get [ -n "" ] which is false.
>
> If 'param' is set to any value, including the empty string, "${param+x}"
> expands to x, and you get [ -n x ] which is true.
>
> See also <https://mywiki.wooledge.org/BashFAQ/083>.
>
>
thanks everyone.
regards, lacsaP.


reply via email to

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