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:
authornagadomi <nagadomi@nurs.or.jp>2016-09-12 14:29:40 +0300
committernagadomi <nagadomi@nurs.or.jp>2016-09-12 14:54:27 +0300
commit7588fbd153136bc4e607ec42a04596b66010e647 (patch)
tree42cec5774febc44c17a3134b7dae193888b08386
parenta0c60edcad88cc65ba88a87757126b3ae0bc3e8d (diff)
fixing sys to not fork
-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