From dd6c163a94cf9acc6b16d6ff6feda0e7705f68d8 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Wed, 15 Aug 2012 16:09:52 +0200 Subject: [PATCH] Remove buggy get_first_val(), rewrite only place it was used Signed-off-by: Tobias Ulmer --- generic/e2lib.lua | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/generic/e2lib.lua b/generic/e2lib.lua index b664ef8..cd005a6 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -837,11 +837,13 @@ end -- @return bool -- @return error string on error function e2lib.read_global_config(e2_config_file) - e2lib.log(4, "read_global_config()") - local cf = e2lib.get_first_val({ - e2lib.globals.cmdline["e2-config"], -- command line - e2lib.globals.osenv["E2_CONFIG"], -- environment - }) + local cf + if type(e2lib.globals.cmdline["e2-config"]) == "string" then + cf = e2lib.globals.cmdline["e2-config"] + elseif type(e2lib.globals.osenv["E2_CONFIG"]) == "string" then + cf = e2lib.globals.osenv["E2_CONFIG"] + end + local cf_path if cf then cf_path = { cf } @@ -1984,18 +1986,6 @@ function e2lib.format_replace(s, t) return s end ---- take a table of values, with integer keys and return the first string --- value --- @param a table of values -function e2lib.get_first_val(t) - for k, v in pairs(t) do - if type(v) == "string" then - return v - end - end - return nil -end - --- change directory -- @param path -- @return bool -- 2.39.5