Fix the use of Path.reach for program names

This commit is contained in:
Jeremie Dimino 2017-03-03 13:53:34 +00:00
parent 65f06e7454
commit 87fa4c080a
3 changed files with 17 additions and 1 deletions

View File

@ -160,7 +160,7 @@ module Mini_shexp = struct
in
let env = Context.extend_env ~vars:env_extra ~env in
Future.run Strict ~dir:(Path.to_string dir) ~env ~stdout_to
(Path.reach ~from:dir prog) args
(Path.reach_for_running ~from:dir prog) args
let rec exec t ~dir ~env ~env_extra ~stdout_to ~tail =
match t with

View File

@ -261,6 +261,21 @@ let reach t ~from =
]
| true, true -> Local.reach t ~from
let reach_for_running t ~from =
match is_local t, is_local from with
| false, _ -> t
| true, false ->
Sexp.code_error "Path.reach_for_running called with invalid combination"
[ "t" , sexp_of_t t
; "from", sexp_of_t from
]
| true, true ->
let s = Local.reach t ~from in
if String.is_prefix s ~prefix:"../" then
s
else
"./" ^ s
let descendant t ~of_ =
if is_local t && is_local of_ then
Local.descendant t ~of_

View File

@ -49,6 +49,7 @@ val relative : t -> string -> t
val absolute : string -> t
val reach : t -> from:t -> string
val reach_for_running : t -> from:t -> string
val descendant : t -> of_:t -> t option