Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trailing newlines from output #265

Merged
merged 1 commit into from
Aug 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions userspace/engine/lua/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions userspace/engine/lua/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
4 changes: 4 additions & 0 deletions userspace/engine/lua/rule_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down