Skip to content

Commit

Permalink
Fix double quoting of pkg-config when package contains a space
Browse files Browse the repository at this point in the history
Example: Pkg_config.query p ~package:"gtk+-3.0 >= 3.10"

Fixes ocaml#1833

Signed-off-by: Christophe Troestler <Christophe.Troestler@umons.ac.be>
  • Loading branch information
Chris00 committed Feb 13, 2019
1 parent 7eee29d commit 6944111
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/configurator/v1.ml
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ module Process = struct
let command_line prog args =
String.concat ~sep:" " (List.map (prog :: args) ~f:quote_if_needed)

(* [cmd] which cannot be quoted (such as [t.c_compiler] which contains
some flags) followed by additional arguments. *)
(* [cmd] which cannot be quoted (such as [t.c_compiler] which contains
some flags) followed by additional arguments. *)
let command_args cmd args =
String.concat ~sep:" " (cmd :: List.map args ~f:quote_if_needed)

Expand Down Expand Up @@ -510,8 +510,6 @@ module Pkg_config = struct
}

let query t ~package =
let package = quote_if_needed package in
let pkg_config = quote_if_needed t.pkg_config in
let c = t.configurator in
let dir = c.dest_dir in
let env =
Expand All @@ -529,10 +527,10 @@ module Pkg_config = struct
end
| _ -> []
in
if Process.run_ok c ~dir ~env pkg_config [package] then
if Process.run_ok c ~dir ~env t.pkg_config [package] then
let run what =
match String.trim
(Process.run_capture_exn c ~dir ~env pkg_config [what; package])
match String.trim (Process.run_capture_exn c ~dir ~env
t.pkg_config [what; package])
with
| "" -> []
| s -> String.split s ~on:' '
Expand Down

0 comments on commit 6944111

Please sign in to comment.