help-bash
[Top][All Lists]
Advanced

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

Re: >= and <= for string comparison


From: Koichi Murase
Subject: Re: >= and <= for string comparison
Date: Wed, 18 Jan 2023 17:36:46 +0900

2023年1月18日(水) 9:59 Ruiyang Peng <rain@ryp.intirain.cc>:
> It seems that bash's lexical is not so easy to change, so how about using
>
> -eq, -gt, -lt etc like arithmetic?  I think this might be a good solution.

As Lawrence has already pointed out, these operators are already used
for the arithmetic comparisons in [[ ... ]], but we could add
lexicographical operators with different names as, e.g., -leq, -lgt,
-llt, -lge, -lle. That would be another possible solution.

If we decide to support `<=' and `>=' for strings, to me, the cleanest
solution seems to be reorganizing the lexical rule inside [[ ... ]] to
accept <= and >= as single tokens though it would introduce
incompatibilities. I'm currently not sure if it's worth it. We need
more real use cases.

--
Koichi



reply via email to

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