* Numeric version of ZSH_VERSION? @ 2008-08-31 2:54 Rocky Bernstein 2008-08-31 3:16 ` Dan Nelson 0 siblings, 1 reply; 7+ messages in thread From: Rocky Bernstein @ 2008-08-31 2:54 UTC (permalink / raw) To: Zsh hackers list 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. Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Numeric version of ZSH_VERSION? 2008-08-31 2:54 Numeric version of ZSH_VERSION? Rocky Bernstein @ 2008-08-31 3:16 ` Dan Nelson 2008-08-31 13:21 ` Rocky Bernstein 2008-09-01 12:38 ` Richard Hartmann 0 siblings, 2 replies; 7+ messages in thread From: Dan Nelson @ 2008-08-31 3:16 UTC (permalink / raw) To: Rocky Bernstein; +Cc: Zsh hackers list 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@allantgroup.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Numeric version of ZSH_VERSION? 2008-08-31 3:16 ` Dan Nelson @ 2008-08-31 13:21 ` Rocky Bernstein 2008-09-01 12:38 ` Richard Hartmann 1 sibling, 0 replies; 7+ messages in thread From: Rocky Bernstein @ 2008-08-31 13:21 UTC (permalink / raw) To: Dan Nelson; +Cc: Zsh hackers list Ok - Great. I'll use this. By the way the -z option listed as an option under autoload is not documented there. However this is written: Equivalent to "functions -u", with the exception of -X/+X and -w. which is a bit compressed in meaning. I gather it means two different things. First that it does the same thing as "functions -u" and therefore second that it takes the same options as that, except those mentioned. So third, you should look at "functions" to find out the meaning of the unmentioned options. Ok. So we then go to "functions" to try to figure out what "-z" does. And along the way we've now picked up another option "-u" that we need to understand. Both "-z" and "-u" are listed again but not documented in "functions" either. However we get Equivalent to "typeset -f" with the exception ... Okay so now we have to chase down a 3rd reference and have picked up yet a third option to now understand: "-f". typeset has a grab bag of options that have nothing to do with either "functions -u" or "autoload". In fact the "-u" means something different when combined with "-f" than it does when that's not there. On Sat, Aug 30, 2008 at 11:16 PM, Dan Nelson <dnelson@allantgroup.com> wrote: > 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@allantgroup.com > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Numeric version of ZSH_VERSION? 2008-08-31 3:16 ` Dan Nelson 2008-08-31 13:21 ` Rocky Bernstein @ 2008-09-01 12:38 ` Richard Hartmann 2008-09-01 12:43 ` Mikael Magnusson 2008-09-01 13:06 ` Rocky Bernstein 1 sibling, 2 replies; 7+ messages in thread From: Richard Hartmann @ 2008-09-01 12:38 UTC (permalink / raw) To: Dan Nelson; +Cc: Rocky Bernstein, Zsh hackers list On Sun, Aug 31, 2008 at 05:16, Dan Nelson <dnelson@allantgroup.com> wrote: > The Misc/is-at-least function should do what you need: It lacks a is-at-max sibling _if_ you need to actually check on ranges. Why not just use revision numbers for this (unless ZSH falls into the git trap, at some point :p)? Richard ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Numeric version of ZSH_VERSION? 2008-09-01 12:38 ` Richard Hartmann @ 2008-09-01 12:43 ` Mikael Magnusson 2008-09-01 13:06 ` Rocky Bernstein 1 sibling, 0 replies; 7+ messages in thread From: Mikael Magnusson @ 2008-09-01 12:43 UTC (permalink / raw) To: Richard Hartmann; +Cc: Dan Nelson, Rocky Bernstein, Zsh hackers list 2008/9/1 Richard Hartmann <richih.mailinglist@gmail.com>: > On Sun, Aug 31, 2008 at 05:16, Dan Nelson <dnelson@allantgroup.com> wrote: > >> The Misc/is-at-least function should do what you need: > > It lacks a is-at-max sibling _if_ you need to actually check on ranges. > Why not just use revision numbers for this (unless ZSH falls into the > git trap, at some point :p)? function is-at-max() { return is-at-least $2 $1 } maybe? I am a bit too lazy to think it through though. -- Mikael Magnusson ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Numeric version of ZSH_VERSION? 2008-09-01 12:38 ` Richard Hartmann 2008-09-01 12:43 ` Mikael Magnusson @ 2008-09-01 13:06 ` Rocky Bernstein 2008-09-01 13:14 ` Rocky Bernstein 1 sibling, 1 reply; 7+ messages in thread From: Rocky Bernstein @ 2008-09-01 13:06 UTC (permalink / raw) To: Richard Hartmann; +Cc: Dan Nelson, Zsh hackers list Yeah, I thought of that too. One can use ! is-at-least and booleans for ranges. Or one can add as you say all of this into the is-at-least package. This kind of awkwardness would be more glaring in languages that support numeric ranges (e.g. Perl, Python, Ruby). My personal view is that is-at-least is a more complicated solution to a problem which is more easily and naturally solved by adding a numeric variable which just keeps increasing, e.g. 08100101 which might be the first change of Sept 1, '08. (I just tried using 08100101 in an arithmetic expression and the number seems not to be too large.) ksh recently added such a thing to .sh.version, so that in a string context it prints a string while in a numeric context it prints a number: $ echo ${.sh.version} Version M 93t 2008-08-25 $ printf "%d\n" .sh.version 20080825 (From which I gather David Korn and Glenn Fowler don't plan on more than one release a day.) On Mon, Sep 1, 2008 at 8:38 AM, Richard Hartmann <richih.mailinglist@gmail.com> wrote: > On Sun, Aug 31, 2008 at 05:16, Dan Nelson <dnelson@allantgroup.com> wrote: > >> The Misc/is-at-least function should do what you need: > > It lacks a is-at-max sibling _if_ you need to actually check on ranges. > Why not just use revision numbers for this (unless ZSH falls into the > git trap, at some point :p)? > > > Richard > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Numeric version of ZSH_VERSION? 2008-09-01 13:06 ` Rocky Bernstein @ 2008-09-01 13:14 ` Rocky Bernstein 0 siblings, 0 replies; 7+ messages in thread From: Rocky Bernstein @ 2008-09-01 13:14 UTC (permalink / raw) To: Richard Hartmann; +Cc: Dan Nelson, Zsh hackers list Can't count, make that 08090101. Also, I meant to mention that is-at-least is fine for my needs as I hope I indicated in my first reply. Alas, since ZSH_VERSION doesn't change as quickly as I'd like, I still have to test for specific features within 4.3.6-dev-0. But ZSH_VERSION is one of the features tested using is-at-least. On Mon, Sep 1, 2008 at 9:06 AM, Rocky Bernstein <rocky.bernstein@gmail.com> wrote: > Yeah, I thought of that too. One can use ! is-at-least and booleans > for ranges. Or one can add as you say all of this into the is-at-least > package. > > This kind of awkwardness would be more glaring in languages that > support numeric ranges (e.g. Perl, Python, Ruby). > > My personal view is that is-at-least is a more complicated solution > to a problem which is more easily and naturally solved by adding a > numeric variable which just keeps increasing, e.g. 08100101 which > might be the first change of Sept 1, '08. (I just tried > using 08100101 in an arithmetic expression and the number seems not to > be too large.) > > ksh recently added such a thing to .sh.version, so that in a string > context it prints a string while in a numeric context it prints a > number: > > $ echo ${.sh.version} > Version M 93t 2008-08-25 > $ printf "%d\n" .sh.version > 20080825 > > (From which I gather David Korn and Glenn Fowler don't plan on more > than one release a day.) > > > On Mon, Sep 1, 2008 at 8:38 AM, Richard Hartmann > <richih.mailinglist@gmail.com> wrote: >> On Sun, Aug 31, 2008 at 05:16, Dan Nelson <dnelson@allantgroup.com> wrote: >> >>> The Misc/is-at-least function should do what you need: >> >> It lacks a is-at-max sibling _if_ you need to actually check on ranges. >> Why not just use revision numbers for this (unless ZSH falls into the >> git trap, at some point :p)? >> >> >> Richard >> > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-09-01 13:15 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-08-31 2:54 Numeric version of ZSH_VERSION? Rocky Bernstein 2008-08-31 3:16 ` Dan Nelson 2008-08-31 13:21 ` Rocky Bernstein 2008-09-01 12:38 ` Richard Hartmann 2008-09-01 12:43 ` Mikael Magnusson 2008-09-01 13:06 ` Rocky Bernstein 2008-09-01 13:14 ` Rocky Bernstein
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).