From feff6e6ffd7e2eb2c1ccabd06a7fa1b275d673f5 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Thu, 18 Oct 2018 20:56:15 +0100 Subject: [PATCH] dinitctl: correct logic for checking missing arguments. Enable/disable commands can set 'to_service' without setting 'service'; check for this. --- src/dinitctl.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dinitctl.cc b/src/dinitctl.cc index a3f40d8..60ad79c 100644 --- a/src/dinitctl.cc +++ b/src/dinitctl.cc @@ -218,11 +218,14 @@ int main(int argc, char **argv) bool no_service_cmd = (command == command_t::LIST_SERVICES || command == command_t::SHUTDOWN); - if (service_name != nullptr && no_service_cmd) { + if (command == command_t::ENABLE_SERVICE || command == command_t::DISABLE_SERVICE) { + show_help |= (to_service_name == nullptr); + } + else if ((service_name == nullptr && ! no_service_cmd) || command == command_t::NONE) { show_help = true; } - - if ((service_name == nullptr && ! no_service_cmd) || command == command_t::NONE) { + + if (service_name != nullptr && no_service_cmd) { show_help = true; } -- 2.25.1