Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/sys.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua20
1 files changed, 19 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index bb5faf9..6196fe8 100644
--- a/init.lua
+++ b/init.lua
@@ -93,7 +93,25 @@ sys.lla = function(d) d = d or ' ' return execute('ls -la '..d) end
--------------------------------------------------------------------------------
-- prefix
--------------------------------------------------------------------------------
-sys.prefix = execute('which lua'):gsub('//','/'):gsub('/bin/lua\n','')
+local function find_prefix()
+ if arg then
+ for i, v in pairs(arg) do
+ if i <= 0 then
+ local lua_path = paths.basename(v)
+ if lua_path == "luajit" or lua_path == "lua" then
+ local bin_dir = paths.dirname(v)
+ if paths.basename(bin_dir) == "bin" then
+ return paths.dirname(bin_dir)
+ else
+ return bin_dir
+ end
+ end
+ end
+ end
+ end
+ return ""
+end
+sys.prefix = find_prefix()
--------------------------------------------------------------------------------
-- always returns the path of the file running