diff options
author | Clement Farabet <clement.farabet@gmail.com> | 2012-10-03 21:49:03 +0400 |
---|---|---|
committer | Clement Farabet <clement.farabet@gmail.com> | 2012-10-03 21:49:03 +0400 |
commit | e89bc1873aaa85f0c60d1fce65d63d374b0e2b46 (patch) | |
tree | ef2b5495cb88c10b71a1712a49f5bf1d6994577c | |
parent | 74d3f2326c269302cfdf64ad73cc5711d3ed2399 (diff) |
...
-rw-r--r-- | init.lua | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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 |