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:
authorClement Farabet <clement.farabet@gmail.com>2012-10-03 21:49:03 +0400
committerClement Farabet <clement.farabet@gmail.com>2012-10-03 21:49:03 +0400
commite89bc1873aaa85f0c60d1fce65d63d374b0e2b46 (patch)
treeef2b5495cb88c10b71a1712a49f5bf1d6994577c
parent74d3f2326c269302cfdf64ad73cc5711d3ed2399 (diff)
...
-rw-r--r--init.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/init.lua b/init.lua
index 40dc0a5..ab6d820 100644
--- a/init.lua
+++ b/init.lua
@@ -78,14 +78,21 @@ execute = function(cmd, readwhat)
local file = _G.assert(io.open(tmpfile))
local s = file:read('*all')
file:close()
- s:gsub('\n$','')
+ s = s:gsub('^%s*',''):gsub('%s*$','')
os.execute('rm ' .. tmpfile)
- --local f = io.popen(cmd, 'r')
- --local s = f:read(readwhat or '*all')
- --s = s:gsub('^%s*',''):gsub('%s*$','')
return s
end
+-- TODO: use the following code, which would avoid the side effect.
+-- For now it doesnt work though, and I can't explain why.
+-- execute = function(cmd)
+-- local f = io.popen(cmd, 'r')
+-- local s = f:read('*all')
+-- f:close()
+-- s = s:gsub('^%s*',''):gsub('%s*$','')
+-- return s
+-- end
+
--------------------------------------------------------------------------------
-- returns the name of the OS in use
-- warning, this method is extremely dumb, and should be replaced by something