diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2022-08-17 14:21:55 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2022-08-17 16:36:56 +0300 |
commit | 5fb9f8b808b9d235d3e30db33f8a9630edac525f (patch) | |
tree | 4e0d2e29aaebe4e1432717738e49841ddcc5921c | |
parent | fe94baf3fe7b7d6d4f97c9e6841c0d9b2915d810 (diff) |
Allow matching empty output with here-document regex without ':' modifier
-rw-r--r-- | libbuild2/script/run.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libbuild2/script/run.cxx b/libbuild2/script/run.cxx index 8b609f1..5b45afd 100644 --- a/libbuild2/script/run.cxx +++ b/libbuild2/script/run.cxx @@ -759,6 +759,31 @@ namespace build2 output_info (d, op); } + // Note that a here-document regex without ':' modifier can never + // match an empty output since it always contains the trailing empty + // line-char. This can be confusing, as for example while testing a + // program which can print some line or nothing with the following + // test: + // + // $* >>~%EOO% + // %( + // Hello, World! + // %)? + // EOO + // + // Note that the above line-regex contains 4 line-chars and will never + // match empty output. + // + // Thus, let's complete an empty output with an empty line-char for + // such a regex, so it may potentially match. + // + if (ls.empty () && + rd.type == redirect_type::here_doc_regex && + rd.modifiers ().find (':') == string::npos) + { + ls += line_char (string (), regex.pool); + } + // Match the output with the regex. // // Note that we don't distinguish between the line_regex and |