Make 'which' gracefully handle the case where $PATH is not set
(it will raise Executable_not_found, but that is the expected thing to
do).
Related to RHBZ#1367839.
---
mllib/common_utils.ml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index fdca713..9210cf8 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -319,7 +319,9 @@ let protect ~f ~finally =
match r with Either ret -> ret | Or exn -> raise exn
let which executable =
- let paths = String.nsplit ":" (Sys.getenv "PATH") in
+ let paths =
+ try String.nsplit ":" (Sys.getenv "PATH")
+ with Not_found -> [] in
let paths = filter_map (
fun p ->
let path = p // executable in
--
2.7.4