diff options
-rw-r--r-- | build2/install/rule.cxx | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx index d43ef14..ebab282 100644 --- a/build2/install/rule.cxx +++ b/build2/install/rule.cxx @@ -685,10 +685,13 @@ namespace build2 else #endif { - const char* args[] = {base.sudo->c_str (), - "rmdir", - reld.string ().c_str (), - nullptr}; + const char* args_a[] = { + base.sudo != nullptr ? base.sudo->c_str () : nullptr, + "rmdir", + reld.string ().c_str (), + nullptr}; + + const char** args (&args_a[base.sudo == nullptr ? 1 : 0]); if (verb >= 2) print_process (args); @@ -780,11 +783,14 @@ namespace build2 else #endif { - const char* args[] = {base.sudo->c_str (), - "rm", - "-f", - relf.string ().c_str (), - nullptr}; + const char* args_a[] = { + base.sudo != nullptr ? base.sudo->c_str () : nullptr, + "rm", + "-f", + relf.string ().c_str (), + nullptr}; + + const char** args (&args_a[base.sudo == nullptr ? 1 : 0]); if (verb >= 2) print_process (args); |