I know there's Sys.os_type but it lumps OSX, Linux, etc. all under the same category. I'd like to detect the OS and most importantly distinguish between OSX and Linux.
-
1It sounds more like a compile time switch than runtime thing. Have you considered that at all?nlucaroni– nlucaroni2014-04-11 13:33:02 +00:00Commented Apr 11, 2014 at 13:33
-
1I have. Either approach could work but I'm not using optcomp or any other pre processor currently so I'd prefer not to introduce that unless absolutely necessary.rgrinberg– rgrinberg2014-04-11 13:57:09 +00:00Commented Apr 11, 2014 at 13:57
Add a comment
|
1 Answer
You could try something like this:
# let ic = Unix.open_process_in "uname" in
let uname = input_line ic in
let () = close_in ic in
uname;;
- : string = "Darwin"
In OSX it returns "Darwin". In Linux it returns "Linux" (at least that's what I saw just now when I tried).
I don't know the behavior on Windows. But at least it will be different :-)