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

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



On 5/28/23, Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
> 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

This requires more changes to be useful:
% is-at-least 1.9 ''; echo $?
1
% is-at-least 0.9 ''; echo $?
0

-- 
Mikael Magnusson




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