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 11:46:43 +0100

Le mar. 19 déc. 2023 à 11:38, lacsaP Patatetom <patatetom@gmail.com> a
écrit :

> hi,
>
> this form `${param+x}` is not documented (man) but is accepted by bash and
> differs from `${param:+x}` :
> `unset p; echo -n ${param+x} && echo -n ${param:+y}` return nothing,
> `p=''; echo -n ${param+x} && echo -n ${param:+y}` return `x` and
> `p='test'; echo -n ${param+x} && echo -n ${param:+y}` return `xy`
>
> is it possible to get an explanation ?
>
> it is found in a script in this test :
> [ -z ${param+x} ]
>
> what's the point of this test, which will always be true ?
>
> regards, lacsaP.
>

last-minute formatting is never good ;-)
`p` is `param`
`unset param; echo -n ${param+x} && echo -n ${param:+y}` return nothing,
`param=''; echo -n ${param+x} && echo -n ${param:+y}` return `x` and
`param='test'; echo -n ${param+x} && echo -n ${param:+y}` return `xy`
sorry


reply via email to

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