From: Tobias Ulmer Date: Fri, 18 Jan 2013 16:59:16 +0000 (+0100) Subject: remove e2lib.program_output() and inline its only user X-Git-Tag: e2factory-2.3.13rc1~53 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=9df35c8564c4d7eeaed4e7ae4010ccb5ecf9f24a;p=e2factory.git remove e2lib.program_output() and inline its only user Signed-off-by: Tobias Ulmer --- diff --git a/generic/e2lib.lua b/generic/e2lib.lua index 14cbbf6..c20a9fd 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -181,7 +181,13 @@ function e2lib.init() end -- get the host name - e2lib.globals.hostname = e2lib.program_output("hostname") + local hostname = io.popen("hostname") + if not hostname then + e2lib.abort("execution of \"hostname\" failed") + end + + e2lib.globals.hostname = hostname:read("*a") + hostname:close() if not e2lib.globals.hostname then e2lib.abort("hostname ist not set") end @@ -293,19 +299,6 @@ function e2lib.tracer(event, line) end end ---- return the output of a program, abort if the call fails --- @param cmd string: the program to call --- @return string: the program output -function e2lib.program_output(cmd) - local i = io.popen(cmd) - if not i then - e2lib.abort("invocation of program failed: ", cmd) - end - local input = i:read("*a") - i:close() - return input -end - --- print a warning, composed by concatenating all arguments to a string -- @param ... any number of strings -- @return nil