diff --git a/userspace/engine/lua/compiler.lua b/userspace/engine/lua/compiler.lua index 6fadb8d1..0feed84e 100644 --- a/userspace/engine/lua/compiler.lua +++ b/userspace/engine/lua/compiler.lua @@ -20,6 +20,7 @@ local compiler = {} compiler.verbose = false compiler.all_events = false +compiler.trim = parser.trim function compiler.set_verbose(verbose) compiler.verbose = verbose diff --git a/userspace/engine/lua/parser.lua b/userspace/engine/lua/parser.lua index 7fb5a317..b240635d 100644 --- a/userspace/engine/lua/parser.lua +++ b/userspace/engine/lua/parser.lua @@ -127,6 +127,7 @@ function trim(s) if (type(s) ~= "string") then return s end return (s:gsub("^%s*(.-)%s*$", "%1")) end +parser.trim = trim local function terminal (tag) -- Rather than trim the whitespace in this way, it would be nicer to exclude it from the capture... diff --git a/userspace/engine/lua/rule_loader.lua b/userspace/engine/lua/rule_loader.lua index 0f4d828e..335474e9 100644 --- a/userspace/engine/lua/rule_loader.lua +++ b/userspace/engine/lua/rule_loader.lua @@ -243,6 +243,10 @@ function load_rules(rules_content, rules_mgr, verbose, all_events, extra, replac state.ordered_rule_names[#state.ordered_rule_names+1] = v['rule'] end + -- The output field might be a folded-style, which adds a + -- newline to the end. Remove any trailing newlines. + v['output'] = compiler.trim(v['output']) + state.rules_by_name[v['rule']] = v else