Skip to content

Commit

Permalink
Fix ocaml#219
Browse files Browse the repository at this point in the history
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
samoht committed Oct 8, 2012
1 parent 64192f6 commit 255d49f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/opamGlobals.ml.in
Expand Up @@ -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
Expand Down

0 comments on commit 255d49f

Please sign in to comment.