-Martin

On Tue, 5 Aug 2025 at 02:17, Stan Marsh <gaze...@xmission.com> wrote:

> (I am talking about things like ${var:-default value})
>
> I have long wished there was a substitution for "substitute a string if
> var is unset
> else substitute nothing".


I've wondered about that myself at times.

I like the idea, but I'm currently undecided whether I would support “*” as
the indicator symbol. In any case, I think that it's important that the
chosen symbol not be valid as the first character of a numeric expression,
including reasonable future enhancements.


> In fact, even better would be a generalized if-then-else, so you could do
> something
> like:
>
>     echo ${var*var is set to $var*var is not set}
>

That extra level doesn't seem compelling, since we could just write:
  ${foo+Foo is set}${foo*Foo is unset}

I assume you would also want both colon and non-colon versions?
 ${foo*Foo is unset}
 ${foo:*Foo is empty or unset}

-Martin

Reply via email to