From: Stephane Chazelas <stephane@chazelas.org>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCHv2] is-at-least compares zsh's version if $2 is provided but empty
Date: Thu, 1 Jun 2023 19:23:24 +0100 [thread overview]
Message-ID: <20230601182324.6m4fab26brkyxvcq@chazelas.org> (raw)
In-Reply-To: <CAHYJk3Q7ckoifHQXkAXbyAfuO3GDNsXOF=uVRD+gMjLS6jTTXg@mail.gmail.com>
2023-05-28 17:51:49 +0200, Mikael Magnusson:
[...]
> This requires more changes to be useful:
> % is-at-least 1.9 ''; echo $?
> 1
> % is-at-least 0.9 ''; echo $?
> 0
[...]
Well spotted. I can't say I completely follow the logic in the
function, but those corner cases are probably better
special-cased.
diff --git a/Functions/Misc/is-at-least b/Functions/Misc/is-at-least
index d4ff3552a..5985684be 100644
--- a/Functions/Misc/is-at-least
+++ b/Functions/Misc/is-at-least
@@ -24,8 +24,14 @@ emulate -L zsh
local IFS=".-" min_cnt=0 ver_cnt=0 part min_ver version order
+: ${2=$ZSH_VERSION}
+
+# sort out the easy corner cases first
+[[ $1 = $2 ]] && return 0 # same version
+[[ -n $2 ]] || return 1 # no version
+
min_ver=(${=1})
-version=(${=2:-$ZSH_VERSION} 0)
+version=(${=2} 0)
while (( $min_cnt <= ${#min_ver} )); do
while [[ "$part" != <-> ]]; do
prev parent reply other threads:[~2023-06-01 18:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-28 11:39 [PATCH] " Stephane Chazelas
2023-05-28 15:51 ` Mikael Magnusson
2023-06-01 18:23 ` Stephane Chazelas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230601182324.6m4fab26brkyxvcq@chazelas.org \
--to=stephane@chazelas.org \
--cc=mikachu@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).