comby-tools/comby

Version 1.7.0 adds a new line after a rewrite

mattvaughan opened this issue · 1 comments

Describe the bug
A newline is inserted after a rewrite occurs in version 1.7.0

Reproducing
Previous behavior

# Command
echo "[HttpPOST]\n[HttpPOST]" | docker run -i comby/comby:1.6.0 '[Http:[method]]' 'Method :[method]Thisisthesameline' -rule 'where rewrite :[method] { "POST" -> "Post" }' -stdin -newline-separated -stdout -matcher .cs

# Output
Method PostThisisthesameline
Method PostThisisthesameline

New behavior

# Command
echo "[HttpPOST]\n[HttpPOST]" | docker run -i comby/comby:1.7.0 '[Http:[method]]' 'Method :[method]Whyisthisanewline' -rule 'where rewrite :[method] { "POST" -> "Post" }' -stdin -newline-separated -stdout -matcher .cs

# Output
Method Post
Whyisthisanewline
Method Post
Whyisthisanewline

Expected behavior
Newlines don't get inserted unless they were specified in the rewrite template or rule.

Additional context
Was working until version 1.7.0... maybe related to this changelog entry:

fixes behavior so that -newline-separated works with rewrite {...} rules

Hey--thanks for the report. Yeah this looks like an unintentional breaking change. The reason why the changelog states that this is "fixed" is because there's a desirable behavior here is if you had, e.g., multiple matches of POST in a single match, and wanted each of those separated by a new line:

echo "ab.ac.ad." | comby -stdin ':[x]' '>:[x]<' -rule 'where rewrite :[x] { a:[t]. -> :[t] }' -newline-separated

That idea conflicts with the previous behavior and your use case :-) The thing about the expectation of "Newlines don't get inserted unless specified" is kind of contrary to the intent of the option -newline-separated (which inserts newlines for each rewrite output at the top level). I say "kind of" because, like we see here, there's a difference between inserting newlines after the top level rewrite template (the original example and behavior before 1.7.0) and inserting newlines after each rewrite operation (current behavior, which are affected by rules). I think the solution here is to basically just let you specify an arbitrary separator for rewrite outputs, without the CLI option deciding what the separator is or where/when it applies.

I'll see if I can restore the previous behavior in a patch version, so that this isn't breaking, and then add the option I talk about above.