From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17583 invoked from network); 10 Aug 2000 16:49:18 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 10 Aug 2000 16:49:17 -0000 Received: (qmail 21504 invoked by alias); 10 Aug 2000 16:48:57 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12582 Received: (qmail 21496 invoked from network); 10 Aug 2000 16:48:56 -0000 Date: Thu, 10 Aug 2000 17:48:15 +0100 From: Peter Stephenson Subject: PATCH: is-at-least To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Message-id: <0FZ300DRS5CF3H@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT 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 Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070