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

Re: Numeric version of ZSH_VERSION?



In the last episode (Aug 30), Rocky Bernstein said:
> It'd be nice to have a numeric version of ZSH_VERSION which is just a
> monotonically increasing number. It would make testing for features in
> (possibly open-ended) ranges easy.

The Misc/is-at-least function should do what you need:

OTHER FUNCTIONS
 Descriptions
  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.   If
    the  present string is not provided, $ZSH_VERSION is used.  Seg-
    ments are paired left-to-right in the two strings  with  leading
    non-number parts ignored.  If one string has fewer segments than
    the other, the missing segments are considered zero.

    This is useful in startup files to set options and  other  state
    that are not available in all versions of zsh.

      is-at-least 3.1.6-15 && setopt NO_GLOBAL_RCS
      is-at-least 3.1.0 && setopt HIST_REDUCE_BLANKS
      is-at-least 2.6-17 || print "You can't use is-at-least here."


-- 
	Dan Nelson
	dnelson@xxxxxxxxxxxxxxx



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