what about this?

#lang racket/base
(require racket/system
         racket/port)

(substring (with-output-to-string (lambda () (system "sw_vers
-productVersion"))) 3 5)

I get "10" or "11" respectively, and I believe it will run on older
versions OS X.

s.



On Tue, Feb 23, 2016 at 9:38 PM Jens Axel Søgaard <jensa...@soegaard.net>
wrote:

> The system-type approach looks like this (it ignores the optional third
> version counter):
>
>     (match (regexp-match #px".*Kernel Version ([\\d]+[.][\\d]+).*"
> (system-type 'machine))
>       [(list _ version-str) (string->number version-str)]
>       [_ #f])
>
> The expression returns 15.0 on my machine.
>
> The AppKit approach seems to be less likely to break over time?
>
> /Jens Axel
>
>
>
> 2016-02-23 22:23 GMT+01:00 Matthew Flatt <mfl...@cs.utah.edu>:
>
>> You could parse the result of `(system-type 'machine)`, but you might
>> just as well use a little `ffi/unsafe` binding to get
>> `NSAppKitVersionNumber`:
>>
>>  #lang racket/base
>>  (require ffi/unsafe)
>>
>>  (define appkit
>>    (ffi-lib "/System/Library/Frameworks/AppKit.framework/AppKit"))
>>  (define NSAppKitVersionNumber
>>    (and appkit (get-ffi-obj 'NSAppKitVersionNumber appkit _double)))
>>
>>  (define (version-10.11-or-later?)
>>    (NSAppKitVersionNumber . >= . 1389))
>>
>>
>> At Tue, 23 Feb 2016 21:46:55 +0100, Jens Axel Søgaard wrote:
>> > Hi All,
>> >
>> > The function system-type can be used to detect the system type.
>> > Is there a function that returns the version of the operating system?
>> >
>> > Use case: The paths to LaTeX has changed on El Capitan,
>> > which makes it difficult to choose a default path, that works
>> > for all.
>> >
>> > /Jens Axel
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Racket Users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an
>> > email to racket-users+unsubscr...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> --
> Jens Axel Søgaard
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to