From d70e1894a471248031a1103c1268454cb194abcf Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Sun, 17 Jun 2018 23:01:21 +0100 Subject: [PATCH] command args: trim leading/trailing whitespace When certain commands in tasksh (such as 'review N') contain whitespace, such as: review '1 ' The whitespace would tokenise into the command arg vector, effectively treating the whitespace as a literal component. In the case of the 'review' command, this is undesirable. Therefore, strip out all leading/trailing whitespace from the command args vector. Fixes GH issue #43 --- src/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index afba727..8ee67dd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -113,7 +113,13 @@ static int commandLoop (bool autoClear) } else if (command != "") { - auto args = split (command, ' '); + std::vector args; + std::string n; + for (const auto& s : split (command, ' ')) + { + if ((n = trim(s)) != "") + args.push_back(n); + } // Dispatch command. if (args[0] == "") status = -1;