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

PATCH: is-at-least



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@xxxxxxx>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070



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