summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/bbackupquery/CommandCompletion.cpp6
-rw-r--r--test/bbackupd/testbbackupd.cpp8
2 files changed, 12 insertions, 2 deletions
diff --git a/bin/bbackupquery/CommandCompletion.cpp b/bin/bbackupquery/CommandCompletion.cpp
index 93c4d3fd..3bc79f3a 100644
--- a/bin/bbackupquery/CommandCompletion.cpp
+++ b/bin/bbackupquery/CommandCompletion.cpp
@@ -510,8 +510,10 @@ BackupQueries::ParsedCommand::ParsedCommand(const std::string& Command,
{
inQuoted = true;
}
- // Start of options?
- else if(currentArg.empty() && *c == '-')
+ // Start of options? You can't have options if there's no
+ // command before them, so treat the options as a command (which
+ // doesn't exist, so it will fail to parse) in that case.
+ else if(currentArg.empty() && *c == '-' && !mCmdElements.empty())
{
mInOptions = true;
}
diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp
index 6cd8f27d..681b51cb 100644
--- a/test/bbackupd/testbbackupd.cpp
+++ b/test/bbackupd/testbbackupd.cpp
@@ -3953,6 +3953,14 @@ int test_bbackupd()
int test(int argc, const char *argv[])
{
{
+ // This is not a complete command, it should not parse!
+ BackupQueries::ParsedCommand cmd("-od", true);
+ TEST_THAT(cmd.mFailed);
+ TEST_EQUAL(NULL, cmd.pSpec);
+ TEST_EQUAL(0, cmd.mCompleteArgCount);
+ }
+
+ {
BackupDaemon daemon;
TEST_EQUAL(1234, daemon.ParseSyncAllowScriptOutput("test", "1234"));