* PATCH: is-at-least
@ 2000-08-10 16:48 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2000-08-10 16:48 UTC (permalink / raw)
To: Zsh hackers list
Minor tinkering with is-at-least so that the first argument can be in the
same format as the second (i.e. you can do `is-at-least 3.1.9-dev-4'
instead of `3.1.9-4'). I also made the syntax more standard (I think).
Index: Functions/Misc/is-at-least
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Misc/is-at-least,v
retrieving revision 1.3
diff -u -r1.3 is-at-least
--- Functions/Misc/is-at-least 2000/05/16 16:21:34 1.3
+++ Functions/Misc/is-at-least 2000/08/10 16:45:34
@@ -12,6 +12,7 @@
# is-at-least 3.1.6-15 && setopt NO_GLOBAL_RCS
# is-at-least 3.1.0 && setopt HIST_REDUCE_BLANKS
# is-at-least 586 $MACHTYPE && echo 'You could be running Mandrake!'
+# is-at-least $ZSH_VERSION || print 'Something fishy here.'
function is-at-least()
{
@@ -19,14 +20,17 @@
local IFS=".-" min_cnt=0 ver_cnt=0 part min_ver version
min_ver=(${=1})
version=(${=2:-$ZSH_VERSION} 0)
- while (( $min_cnt <= ${#min_ver} )) {
- while [[ "$part" != <-> ]] {
- [[ $[++ver_cnt] > ${#version} ]] && return 0
+ while (( $min_cnt <= ${#min_ver} )); do
+ while [[ "$part" != <-> ]]; do
+ (( ++ver_cnt > ${#version} )) && return 0
part=${version[ver_cnt]##*[^0-9]}
- }
- [[ $[++min_cnt] > ${#min_ver} ]] && return 0
+ done
+ while true; do
+ (( ++min_cnt > ${#min_ver} )) && return 0
+ [[ ${min_ver[min_cnt]} = <-> ]] && break
+ done
(( part > min_ver[min_cnt] )) && return 0
(( part < min_ver[min_cnt] )) && return 1
part=''
- }
+ done
}
--
Peter Stephenson <pws@csr.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-08-10 16:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-10 16:48 PATCH: is-at-least Peter Stephenson
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).