From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18496 invoked by alias); 12 Dec 2015 05:29:15 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21082 Received: (qmail 21713 invoked from network); 12 Dec 2015 05:29:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=cgBH+xwSYmHRReipnSfNwqEBoNLACAeqp44+YhmTaho=; b=a3O44oXu2vJ4wmQDcPQiYYhXqTMTa4BcbJM0tjdgb2QOphsLVv5JKPiUJXZ1svCTMx cT52eosAyek43+IE/1KpHlka8tho4NR20KKAjdXydHwGlgChavd5qUK8e0592LfXxgZ/ mZoaIdu/2Mq7LYOW7HDqAspLl8PujyDKDxpMZjTKlC4zwWOn25uro7+A952gvY5p2Znu QAQDCgVJjJUp4dLuLOSn2kdNHlRrWylK6LTv5nAn0C8b5yD8AwCPBod21ZTC6TPWTYbh 7WGUiDuWCXGjjTiAjOfW9rxFJAFrJIjrYlnnUp87mNan+lLkOQ+sZzKTf0V48pVsy5/e mMeg== X-Gm-Message-State: ALoCoQlgM0ijruPhlqTYFdli4zo1BZEjhIoGs43T2/DQokdG9sO65zlESa8yT7Oo2IN7jtGdF2rA6SpisRn2zUFoZiVmYGHtaw== X-Received: by 10.66.102.70 with SMTP id fm6mr30401456pab.80.1449898151135; Fri, 11 Dec 2015 21:29:11 -0800 (PST) From: Bart Schaefer Message-Id: <151211212928.ZM4290@torch.brasslantern.com> Date: Fri, 11 Dec 2015 21:29:28 -0800 In-Reply-To: <20151211112229.GB8386@zira.vinc17.org> Comments: In reply to Vincent Lefevre "Re: possible 'is-at-least' bug?" (Dec 11, 12:22pm) References: <20151207102525.GA12995@cventin.lip.ens-lyon.fr> <151209160157.ZM28612@torch.brasslantern.com> <20151211112229.GB8386@zira.vinc17.org> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: possible 'is-at-least' bug? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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