Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: possible 'is-at-least' bug?
- X-seq: zsh-users 21082
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: possible 'is-at-least' bug?
- Date: Fri, 11 Dec 2015 21:29:28 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=cgBH+xwSYmHRReipnSfNwqEBoNLACAeqp44+YhmTaho=; b=QzFHGzTWqxC2g/iEDjysA0QDpSA420B9QHa5pO5Y6kWxtT78OTaDhYfVZ0Mdv0lcK3 q0M0mbRiM+7rFSC2/IrAcB0CyPXFEsjovdjbViPkq78N72YonHbkPQ6VXhkd0zX6iBco NOu1MGf+hbxE2v/baCuw2lzbErYLHEVOAl89V/z1THXEx/is6dxTA+soF1pmzL3TwL+B iogLeTBrfMhtaj/oX67pH0Cyz+KM/QmM1G0+abo2nNWMp5XcbOY/qkV4hJVpQm9Po++2 yMDpUZajNYznBL01LFrw7Apy6goneufFKP4t3S/H/0w0QcGg2bnxywEwrOMidMRo+IM6 nEBQ==
- In-reply-to: <20151211112229.GB8386@zira.vinc17.org>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADjGqHue=fEzyoayraCEZtqzuExyJiGuMjUDHKYtEOu47w6bew@mail.gmail.com> <CAB2RFrTcUWZZRbWqCT+7mZxUp+A5eb=psc46oDXSqrCcPXGVOQ@mail.gmail.com> <20151207102525.GA12995@cventin.lip.ens-lyon.fr> <151209160157.ZM28612@torch.brasslantern.com> <20151211112229.GB8386@zira.vinc17.org>
On Dec 11, 12:22pm, Vincent Lefevre wrote:
}
} > } On 2015-12-05 01:29:46 -0500, Benjamin R. Haskell wrote:
} > } > `is-at-least` isn't intended to be that general.
} > } >
} > } > To do so would require a great deal more complexity.
} >
} > To also split "1a1" and "1b2" etc. on the non-space between the numbers
} > and the letters, would require quite a bit more effort.
}
} I meant that two such words could be compared without having to
} split them, thanks to numeric sorting.
Hmm. Yes, that could be done. 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.)
Incidentally, is-at-least completely ignores segments that have no
digits in them at all, so zsh-5.2-dev-1 and zsh-5.2-test-1 will be
considered the same.
The following is what Vincent suggested but does not address dev / test.
diff --git a/Functions/Misc/is-at-least b/Functions/Misc/is-at-least
index d4b0e2f..d1073ff 100644
--- a/Functions/Misc/is-at-least
+++ b/Functions/Misc/is-at-least
@@ -16,7 +16,7 @@
emulate -L zsh
-local IFS=".-" min_cnt=0 ver_cnt=0 part min_ver version
+local IFS=".-" min_cnt=0 ver_cnt=0 part min_ver version order
min_ver=(${=1})
version=(${=2:-$ZSH_VERSION} 0)
@@ -24,6 +24,12 @@ version=(${=2:-$ZSH_VERSION} 0)
while (( $min_cnt <= ${#min_ver} )); do
while [[ "$part" != <-> ]]; do
(( ++ver_cnt > ${#version} )) && return 0
+ if [[ ${version[ver_cnt]} = *[0-9][^0-9]* ]]; then
+ # A leading number and then some text. Not a zsh version string,
+ # so compare by sorting with numeric order.
+ order=( ${version[ver_cnt]} ${min_ver[ver_cnt]} )
+ [[ $order != ${${(On)order}} ]] && return 1
+ fi
part=${version[ver_cnt]##*[^0-9]}
done
Messages sorted by:
Reverse Date,
Date,
Thread,
Author