os.outputof () raise error on invalid streams argument value

This commit is contained in:
Renaud Guillard 2021-03-07 16:24:19 +01:00
parent 7f67a3ba67
commit 8e75e1084b

View File

@ -466,11 +466,16 @@
function os.outputof(cmd, streams)
cmd = path.normalize(cmd)
local redirection = " 2>&1"
if streams == "output" then
streams = streams or "both"
local redirection
if streams == "both" then
redirection = " 2>&1"
elseif streams == "output" then
redirection = " 2>/dev/null"
elseif streams == "error" then
redirection = " 2>&1 1>/dev/null"
else
error ('Invalid stream(s) selection. "output", "error", or "both" expected.')
end
local pipe = io.popen(cmd .. redirection)