From 6b04c7b565cd1efae05f31cce058348f7079946a Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Sat, 29 Jun 2024 08:53:11 -0700 Subject: [PATCH] Don't print error found in grep regex twice. Unless switched off, the re2 library logs a regex parse error. --- bant/frontend/parsed-project.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bant/frontend/parsed-project.cc b/bant/frontend/parsed-project.cc index 4d974ff..134d514 100644 --- a/bant/frontend/parsed-project.cc +++ b/bant/frontend/parsed-project.cc @@ -242,8 +242,9 @@ void PrintProject(Session &session, const BazelPattern &pattern, std::unique_ptr regex; if (!flags.grep_regex.empty()) { - // TODO: pass options to not log error - regex = std::make_unique(flags.grep_regex); + RE2::Options options; + options.set_log_errors(false); // We print them ourselves + regex = std::make_unique(flags.grep_regex, options); if (!regex->ok()) { // This really needs the session passed in so that we can reach the // correct error stream.