From 222d38955ed7d24d388123d7b6e7ef4c21dd65b1 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Sun, 2 Nov 2014 11:02:56 -0500 Subject: [PATCH] toolcontext: nit_dir tries another heuristic on PATH if procfs is not available MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit procfs (/proc/) does not exists on some system (macosx). Therefore the heuristic used to find nit_dir will fail on those system when the command is invoked from the PATH. The solution is to add another heuristic, where the program_name is manually searched inside the directories of PATH in order to find the original directory. Reported-by: Alexandre Blondin Massé Signed-off-by: Jean Privat --- src/toolcontext.nit | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/toolcontext.nit b/src/toolcontext.nit index e174145..a443b0a 100644 --- a/src/toolcontext.nit +++ b/src/toolcontext.nit @@ -422,6 +422,13 @@ The Nit language documentation and the source code of its tools and libraries ma if res.file_exists and "{res}/src/nit.nit".file_exists then return res.simplify_path end + # search in the PATH + var ps = "PATH".environ.split(":") + for p in ps do + res = p/".." + if res.file_exists and "{res}/src/nit.nit".file_exists then return res.simplify_path + end + return null end end -- 1.7.9.5