Initial prototype for Lua plugins

This commit is contained in:
David Peter committed 2022-05-29 20:40:05 +02:00
1 parent 3339eee2dc
commit 3811615606
8 files changed
+119 -6

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
function tempdir()
local stream = assert(io.popen('mktemp --directory'))
local output = stream:read('*all')
stream:close()
return string.gsub(output, "\n", "")
end
function preprocess(path)
prefix = string.match(path, '^(.*)%.gz$')
if prefix then
local temp_directory = tempdir()
local new_path = temp_directory .. "/" .. prefix
-- TODO: how to prevent shell injection bugs?
os.execute("gunzip < '" .. path .. "' > '" .. new_path .. "'")
return new_path
else
return path
end
end