From 7765f51c5f6429fcb45a6c195b71929c392b0a31 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 20 May 2020 20:42:45 +0300 Subject: Make build script runner to execute exit-containing expression in dry-run mode --- libbuild2/build/script/runner.cxx | 14 ++++++-------- libbuild2/build/script/runner.hxx | 6 ++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/libbuild2/build/script/runner.cxx b/libbuild2/build/script/runner.cxx index 0be55a5..5535bbb 100644 --- a/libbuild2/build/script/runner.cxx +++ b/libbuild2/build/script/runner.cxx @@ -32,21 +32,19 @@ namespace build2 if (verb >= 3) text << ": " << expr; - // Run the expression if we are not in the dry run mode or if it - // executes the set builtin and print the expression otherwise, unless - // it is already printed or the verbosity level is lower than 2. - // - // @@ Should we also run expressions that execute the exit builtin in - // the dry run mode? + // Run the expression if we are not in the dry-run mode or if it + // executes the set or exit builtin and just print the expression + // otherwise at verbosity level 2 and up. // if (!env.context.dry_run || find_if (expr.begin (), expr.end (), [] (const expr_term& et) { - return et.pipe.back ().program.string () == "set"; + const string& p (et.pipe.back ().program.string ()); + return p == "set" || p == "exit"; }) != expr.end ()) build2::script::run (env, expr, li, ll); - else if (verb == 2) + else if (verb >= 2) text << expr; } diff --git a/libbuild2/build/script/runner.hxx b/libbuild2/build/script/runner.hxx index db211df..431c446 100644 --- a/libbuild2/build/script/runner.hxx +++ b/libbuild2/build/script/runner.hxx @@ -50,6 +50,12 @@ namespace build2 leave (environment&, const location&) = 0; }; + // Run command expressions. + // + // In dry-run mode don't run the expressions unless they are if- + // conditions or execute the set or exit builtins, but prints them at + // verbosity level 2 and up. + // class default_runner: public runner { public: -- cgit v1.1