From d2f593734419759b368aeea894def07f0364ac76 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 12 Jul 2015 23:32:26 -0400 Subject: [PATCH] CLI2: Fixed bug that allowed numbers to be interpreted as IDs - For a WRITECMD with no FILTER args, if a Lexer::Type::number exists as a MODIFICATION, and that number is an unsigned integer, then promote it to an ID. Added eceptions for the 'add' and 'log' command. This feature allows for the continued use of 'task done 1', which should be deprecated. --- src/CLI2.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/CLI2.cpp b/src/CLI2.cpp index bd5872dbc..76e094b25 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -1263,11 +1263,14 @@ void CLI2::desugarFilterPatterns () void CLI2::findIDs () { bool previousArgWasAnOperator = false; + int filterCount = 0; for (auto& a : _args) { if (a.hasTag ("FILTER")) { + ++filterCount; + if (a._lextype == Lexer::Type::number) { // Skip any number that was preceded by an operator. @@ -1301,9 +1304,14 @@ void CLI2::findIDs () } } - // If no IDs were found, look for number/set listed as a MODIFICATION for a - // WRITECMD. - if (! _id_ranges.size ()) + // If no IDs were found, and no filter was specified, look for number/set + // listed as a MODIFICATION for a WRITECMD. + std::string command = getCommand (); + + if (! _id_ranges.size () && + filterCount == 0 && + command != "add" && + command != "log") { for (auto& a : _args) {