help-bash
[Top][All Lists]
Advanced

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

Re: >= and <= for string comparison


From: Ruiyang Peng
Subject: Re: >= and <= for string comparison
Date: Wed, 18 Jan 2023 16:41:24 +0800
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Thunderbird/109.0

在 2023/1/18 16:36, Koichi Murase 写道:
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

We thought about going together, but I was worried that this would make

the change too big?

--

Ruiyang Peng


reply via email to

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