From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27467 invoked by alias); 5 Dec 2015 06:30:13 -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: 21047 Received: (qmail 28906 invoked from network); 5 Dec 2015 06:30:10 -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,HTML_MESSAGE, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=benizi-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=xjtGUFVqKmBsLBTdEajmznPE+GbrkxuNMuVMkj/gyoA=; b=LZR3JHEaJ4T6X9TYi4GxJrVHcEVfPeidOBe5DUA+pnT3scJf7/jQ4v1qle1fUaETpk 9tuBOl6R2eJlm0vTb5n4R/FmVCsREexzNyh7d5e97DT0gCou4xVqXScomMDGJQi+Xm7/ nYE1DqfBzYI21AMd44QlJMnLmigKZr91tk+Zf1NWxqan/EZenV9GqxhUhrZ7BLexPmr/ WsMF1KpKb2jpXwrZ5FBLp4XoezVBHzXgW9XbcvUMcqGxoXEv+4NmcigYvIjmSdSqlQZJ bRw2adlJfR3R2MHKVsjiMAVdPEm1YJGBzZjOXhYIJ0lGjlFmjxJ+989iQzGC8Dbghhbm 4miA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-type; bh=xjtGUFVqKmBsLBTdEajmznPE+GbrkxuNMuVMkj/gyoA=; b=KZKH8FZHLfs6UhKC0aYo/G07qXNUL55GRLq84Tg5q8fiEKLfobFeXUgvnNYvr1fljh FrjstjnJ6hlcpzcG3NZuXBpIksrDLdL4Ob+HH5UXglaSJ103xG3EtxRqu+LU3ZCDZz9w O+JCom4PmLppJklRHOFn3snQ9JHx4Tj1jpXq3agcEj/LjVYBf+j1c5ortC/JquHe770E J0+oDdAVCXnBd9K71TXXeUyClRf9HqA3pO4g7FI7V4ACorr7buT99iPOiJK7QtXwzbBV BqY/0Nrw6Q5etLRN3jGYT3P1nnonV28ya0txtjfSRFCKHv0zGiBG0L6n5OQrh3o5ov/K mbKQ== X-Gm-Message-State: ALoCoQleV/cNA3K+ulml9zLOMfkuepxq4kdSjv+au1IDPQLGZAMh8gZ6LlUpKo64laDNyi1V0xD9 X-Received: by 10.129.132.136 with SMTP id u130mr13771727ywf.208.1449297006813; Fri, 04 Dec 2015 22:30:06 -0800 (PST) MIME-Version: 1.0 Sender: benizi@benizi.com In-Reply-To: References: From: "Benjamin R. Haskell" Date: Sat, 5 Dec 2015 01:29:46 -0500 X-Google-Sender-Auth: j38fQV7hdPSYyX5FqL3khYXMUTA Message-ID: Subject: Re: possible 'is-at-least' bug? To: TJ Luoma Cc: Zsh-Users List Content-Type: multipart/alternative; boundary=001a114eed624422ca052620c168 --001a114eed624422ca052620c168 Content-Type: text/plain; charset=UTF-8 On Fri, Dec 4, 2015 at 6:45 PM, TJ Luoma wrote: > Thanks to a recent tip from the list, I've started using 'is-at-least' to > compare version numbers. > > However, I seem to have found a situation/edge case where it does not seem > to work. > > I am trying to compare version numbers of software, in this case ImageOptim > for the Mac. > `is-at-least` isn't intended to be that general. From `man zshall`: is-at-least needed [ present ] Perform a greater-than-or-equal-to comparison of two strings having the format of a zsh version number; that is, a string of numbers and text with segments separated by dots or dashes. To do so would require a great deal more complexity. It'd probably be a better check for a package manager (where the version strings can be limited to a specific format). The version I have installed is '1.6.1a1' where the 'a' is for 'alpha' > > There is a newer version '1.6.1b2' where the 'b' is for 'beta' > > ## > > LATEST_VERSION='1.6.1b2' > > INSTALLED_VERSION='1.6.1a1' > > autoload is-at-least > > is-at-least "$LATEST_VERSION" "$INSTALLED_VERSION" > For this specific case, the following seems reasonable: LATEST_VERSION=1.6.1b2 INSTALLED_VERSION=1.6.1a1 alpha='(#b)([A-Za-z]##)' is-at-least ${LATEST_VERSION//$~alpha/.$match[1].} ${INSTALLED_VERSION//$~alpha/.$match[1].} '(#b)' in a pattern activates back references '##' is the equivalent of '+' in most regular expression libraries I think both of those require 'EXTENDED_GLOB' The `~` in $~alpha means treat the contents of $alpha as a pattern, not just a string to match The $match[1] is the parenthesized group in the match (so, a string of alphabetic characters). -- Best, Ben --001a114eed624422ca052620c168--