Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix #219

That's not the best patch ever, but that'll fix 'uname -s' when some env variables contain hyphens (which seems to be valid with bash but not with sh).

Unix.open_process_in is hard-coding '/bin/sh', so switch to the more neutral Unix.create_process
  • Loading branch information...
commit 255d49f29a5b9821ed64cdbd3bb0749f8ffb91c4 1 parent 64192f6
@samoht samoht authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/opamGlobals.ml.in
View
11 src/opamGlobals.ml.in
@@ -85,9 +85,18 @@ type os =
| Unix
| Other of string
+let uname_s () =
+ let stdout_in, stdout = Unix.pipe () in
+ let _, stderr = Unix.pipe () in
+ let stdin, _ = Unix.pipe () in
+ let _ = Unix.create_process "uname" [|"-s"|] stdin stdout stderr in
+ let buf = String.create 128 in
+ let r = Unix.read stdout_in buf 0 128 in
+ String.sub buf 0 r
+
let os = match Sys.os_type with
| "Unix" -> begin
- match input_line (Unix.open_process_in "uname -s") with
+ match uname_s () with
| "Darwin" -> Darwin
| "Linux" -> Linux
| "FreeBSD" -> FreeBSD
Please sign in to comment.
Something went wrong with that request. Please try again.