From 1a42a842639df21d4738bb8ac12f146d829a9d17 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 3 Jul 2013 01:48:10 +0200 Subject: add option to redirect log output to file --- luaotfload-tool.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'luaotfload-tool.lua') diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 45a75ba..392be6e 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -902,6 +902,22 @@ actions.list = function (job) return true, true end +--- stuff to be carried out prior to exit + +local finalizers = { } + +--- returns false if at least one of the actions failed, mainly +--- for closing io channels +local finalize = function () + local success = true + for _, fun in next, finalizers do + if type (fun) == "function" then + if fun () == false then success = false end + end + end + return success +end + --[[-- Command-line processing. mkluatexfontdb.lua relies on the script alt_getopt to process argv and @@ -985,7 +1001,7 @@ local process_cmdline = function ( ) -- unit -> jobspec elseif v == "log" then local str = optarg[n] if str then - logs.set_logout(str) + finalizers = logs.set_logout(str, finalizers) end elseif v == "find" then action_pending["query"] = true @@ -1065,7 +1081,11 @@ local main = function ( ) -- unit -> int if exit then break end end - texiowrite_nl"" + if finalize () == false then + retval = -1 + end + + --texiowrite_nl"" return retval end -- cgit v1.2.3