From: Jean Privat Date: Sun, 2 Nov 2014 16:02:56 +0000 (-0500) Subject: toolcontext: nit_dir tries another heuristic on PATH if procfs is not available X-Git-Tag: v0.6.11~61^2~2 X-Git-Url: http://nitlanguage.org?ds=sidebyside toolcontext: nit_dir tries another heuristic on PATH if procfs is not available 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 --- 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