Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] fix/simplify is-at-least
> 2026/04/12 22:19, Philippe Altherr <philippe.altherr@xxxxxxxxx> wrote:
>
> - "order" should be added to the list of locals
Thanks!
> - Is it expected that "is-at-least 5.9.33 5.9.x7" returns yes?
Yes, but if it would break any existing scripts, I'm willing to modify it.
In users/21082, Bart wrote:
I think it conflicts with sorting of zsh
version numbers, though, because "zefram2" is supposed to be considered
an older version substring than "pws4". (Although no version of zsh has
had a ZSH_VERSION string that looks like that in more than a decade.)
'git log -p Config/version.mk' doesn't show any such VERSION (since
year 2000).
Moreover, as you have pointed out (I didn't notice this), the current
is-at-least returns true for 'is-at-least 1.pws4 1.zefram2', because
'pws4' is ignored.
And, in the current is-at-least, a leading text is removed only if
a segment (of the 2nd arg) is like 'zefram2', but not like 'a2b'
(text 'b' after digits '2'). This means
'is-at-least 1.2 1.a1' was false, but
'is-at-least 1.2 1.a1b' was true.
With my patch both are true ('2' < 'a').
I _guess_ there is virtually no scripts that depend on
'is-at-least 5.9.33 5.9.x7' being false. But if there would be such
a script, it is easy to retain this behavior.
Either removing the leading text or not, we need to update
Z01is-at-least as blow.
diff --git a/Test/Z01is-at-least.ztst b/Test/Z01is-at-least.ztst
index 039b3e737..5ec0cef3e 100644
--- a/Test/Z01is-at-least.ztst
+++ b/Test/Z01is-at-least.ztst
@@ -16,12 +16,21 @@
done
0:is-at-least smoke test
- is-at-least 5.8.0.2 5.8
-1f:regression test: Two trailing zeroes are filled in
-# TODO: When fixing this, extend the smoke test to cover this.
-
- is-at-least 5.8.0.2 5.8.0.0
-1:regression test: Two trailing zeroes are filled in
-# TODO: Extend the smoke test to cover this.
+# versions in v1 should be equal
+# versions in v2 should be newer than those in v1
+ v1=( 1 1.0 1.0.0 1.0.0.0 )
+ v2=( 1.0.0.1 1.0.1 1.0.1.0 1.0.1.1 )
+ for (( i = 1; i < $#v1; ++i )); do
+ for (( j = 1; j < $#v1; ++j )); do
+ is-at-least $v1[i] $v1[j] || echo "$v1[i] ≰ $v1[j]"
+ done
+ done
+ for (( i = 1; i < $#v1; ++i )); do
+ for (( j = 1; j < $#v2; ++j )); do
+ is-at-least $v1[i] $v2[j] || echo "$v1[i] ≰ $v2[j]"
+ { ! is-at-least $v2[j] $v1[i] } || echo "$v2[j] ≤ $v1[i]"
+ done
+ done
+0:trailing zeroes are filled in
%clean
Messages sorted by:
Reverse Date,
Date,
Thread,
Author