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