Martin wrote: >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. True. I just gave * as an example - it was the first unused symbol that popped into my head. As you say, it would have to be carefully thought out to make sure whatever character is chosen doesn't interfere with anything else. >> 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} Yes, if we had the proposed "*" syntax, then you don't need the if-then-else (for this specific case/need), but the point is that we don't currently *have* that new syntax, and also that many of the existing "var:X" syntaxes are special cases of a generalized if-then-else. Not that I am suggesting that the existing syntaxes be removed, of course. But I've always felt when reading the man-page descriptions of these syntaxes that "These are all just special cases of a generalized if-then-else, but the specific thing that I want right now is missing, so it'd be nice to have the generalized version." >I assume you would also want both colon and non-colon versions? > ${foo*Foo is unset} > ${foo:*Foo is empty or unset} Yes. ================================================================================= Please do not send me replies to my posts on the list. I always read the replies via the web archive, so CC'ing to me is unnecessary. When responding to my posts, please try to refrain from giving bureaucratic answers. If you have nothing useful to say, then just click Next and go on.