From 2a8b91209627608fe61c21ec96de31b7fffcea94 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sun, 10 Feb 2008 21:31:53 -0500 Subject: Instead of io.popen():read(), a file descriptor is kept and close()'d afterward. --- modules/textadept/snippets.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'modules/textadept/snippets.lua') diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua index 45b8cb39..82e41f26 100644 --- a/modules/textadept/snippets.lua +++ b/modules/textadept/snippets.lua @@ -110,7 +110,9 @@ function insert(snippet_arg) -- Execute any shell code. s_text = s_text:gsub('`(.-)`', function(code) - local out = io.popen(code):read('*all') + local p = io.popen(code) + local out = p:read('*all') + p:close() if out:sub(-1) == '\n' then return out:sub(1, -2) end end) @@ -212,8 +214,9 @@ next_snippet_item = function() script = script:gsub('replacement', replacement) _DEBUG('script:\n'..script) - local out = io.popen("ruby 2>&1 <<'_EOF'\n".. - script..'\n_EOF'):read('*all') + local p = io.popen("ruby 2>&1 <<'_EOF'\n"..script..'\n_EOF') + local out = p:read('*all') + p:close() _DEBUG('regex out:\n'..out) if out:sub(-1) == '\n' then out = out:sub(1, -2) end -- chomp return out -- cgit v1.2.3