Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] is-at-least compares zsh's version if $2 is provided but empty



autoload is-at-least
is-at-least 7.2 "$(gcc -dumpfullversion 2> /dev/null)" ||
  die "need gcc 7.2 or newer"

Will fail to detect gcc not being available or from a
version that didn't support -dumpfullversion when zsh 7.2 is
out, because when the second argument is empty, is-at-least
falls back to comparing zsh's own version instead.

IMO, it should check whether $2 is provided or not rather than
non-empty or not.

diff --git a/Functions/Misc/is-at-least b/Functions/Misc/is-at-least
index d4ff3552a..9546cb2b7 100644
--- a/Functions/Misc/is-at-least
+++ b/Functions/Misc/is-at-least
@@ -25,7 +25,7 @@ emulate -L zsh
 local IFS=".-" min_cnt=0 ver_cnt=0 part min_ver version order
 
 min_ver=(${=1})
-version=(${=2:-$ZSH_VERSION} 0)
+version=(${=2-$ZSH_VERSION} 0)
 
 while (( $min_cnt <= ${#min_ver} )); do
   while [[ "$part" != <-> ]]; do




Messages sorted by: Reverse Date, Date, Thread, Author