Permalink
Browse files

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
  • Loading branch information...
ThomasAdam committed Jun 17, 2018
1 parent 68d8a9a commit d70e1894a471248031a1103c1268454cb194abcf
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/main.cpp
@@ -113,7 +113,13 @@ static int commandLoop (bool autoClear)
}
else if (command != "")
{
auto args = split (command, ' ');
std::vector<std::string> args;
std::string n;
for (const auto& s : split (command, ' '))
{
if ((n = trim(s)) != "")
args.push_back(n);
}

// Dispatch command.
if (args[0] == "<EOF>") status = -1;

0 comments on commit d70e189

Please sign in to comment.