diff --git a/src/command/help/help.c b/src/command/help/help.c index 5979dcd84..bf73cccb9 100644 --- a/src/command/help/help.c +++ b/src/command/help/help.c @@ -289,7 +289,7 @@ helpRender(const Buffer *const helpData) const String *more = NULL; // Display general help - if (cfgCommand() == cfgCmdHelp || cfgCommand() == cfgCmdNone) + if (cfgCommand() == cfgCmdNone) { strCatZ( result, diff --git a/src/config/parse.c b/src/config/parse.c index a78ca57e7..e0443cbc8 100644 --- a/src/config/parse.c +++ b/src/config/parse.c @@ -1766,8 +1766,11 @@ cfgParse(const Storage *const storage, const unsigned int argListSize, const cha if (!(parseRuleCommand[config->command].commandRoleValid & ((unsigned int)1 << config->commandRole))) THROW_FMT(CommandInvalidError, "invalid command/role combination '%s'", arg); - if (config->command == cfgCmdHelp) + if (config->command == cfgCmdHelp && !config->help) + { + config->command = cfgCmdNone; config->help = true; + } else commandSet = true; } diff --git a/test/src/module/config/loadTest.c b/test/src/module/config/loadTest.c index d60b05710..e2014cc39 100644 --- a/test/src/module/config/loadTest.c +++ b/test/src/module/config/loadTest.c @@ -886,6 +886,17 @@ testRun(void) TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "help command for backup"); TEST_RESULT_UINT(ioBufferSize(), 1048576, "buffer size set to option default"); + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("help command for help"); + + argList = strLstNew(); + strLstAddZ(argList, PROJECT_BIN); + strLstAddZ(argList, "help"); + strLstAddZ(argList, "help"); + + TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "load config"); + TEST_RESULT_UINT(ioBufferSize(), 1048576, "buffer size set to option default"); + // ------------------------------------------------------------------------------------------------------------------------- TEST_TITLE("command takes lock and opens log file and uses custom tcp settings"); diff --git a/test/src/module/config/parseTest.c b/test/src/module/config/parseTest.c index e1e215e1d..ae0e8aa63 100644 --- a/test/src/module/config/parseTest.c +++ b/test/src/module/config/parseTest.c @@ -1529,8 +1529,7 @@ testRun(void) TEST_RESULT_VOID(cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "help command"); TEST_RESULT_BOOL(cfgCommandHelp(), true, "help is set"); - TEST_RESULT_INT(cfgCommand(), cfgCmdHelp, "command is help"); - TEST_RESULT_Z(cfgCommandName(), "help", "command name is help"); + TEST_RESULT_INT(cfgCommand(), cfgCmdNone, "command is help"); argList = strLstNew(); strLstAddZ(argList, TEST_BACKREST_EXE); @@ -1541,6 +1540,17 @@ testRun(void) cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "help for version command"); TEST_RESULT_BOOL(cfgCommandHelp(), true, "help is set"); TEST_RESULT_INT(cfgCommand(), cfgCmdVersion, "command is version"); + TEST_RESULT_Z(cfgCommandName(), "version", "command name is version"); + + argList = strLstNew(); + strLstAddZ(argList, TEST_BACKREST_EXE); + strLstAddZ(argList, "help"); + strLstAddZ(argList, "help"); + + TEST_RESULT_VOID( + cfgParseP(storageTest, strLstSize(argList), strLstPtr(argList), .noResetLogLevel = true), "load config"); + TEST_RESULT_BOOL(cfgCommandHelp(), true, "help is set"); + TEST_RESULT_INT(cfgCommand(), cfgCmdHelp, "command is help"); // ------------------------------------------------------------------------------------------------------------------------- TEST_TITLE("help option");