diff --git a/src/CLI2.cpp b/src/CLI2.cpp index b3e470b1c..a756a1b67 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -393,6 +393,37 @@ void CLI2::lexArguments () context.debug (dump ("CLI2::analyze lexArguments")); } +//////////////////////////////////////////////////////////////////////////////// +void CLI2::handleTerminator () +{ + bool changes = false; + bool terminated = false; + std::vector reconstructed; + for (auto& a : _args) + { + if (a._lextype == Lexer::Type::separator) + { + terminated = true; + changes = true; + } + else + { + if (terminated) + a._lextype = Lexer::Type::word; + + reconstructed.push_back (a); + } + } + + if (changes) + { + _args = reconstructed; + + if (context.config.getInteger ("debug.parser") >= 3) + context.debug (dump ("CLI2::analyze handleTerminator")); + } +} + //////////////////////////////////////////////////////////////////////////////// // Intended to be called after ::add() to perform the final analysis. void CLI2::analyze () @@ -407,6 +438,7 @@ void CLI2::analyze () _args.clear (); handleArg0 (); lexArguments (); + handleTerminator (); // Process _args. aliasExpansion (); diff --git a/src/CLI2.h b/src/CLI2.h index 1f244c8e7..85e11528e 100644 --- a/src/CLI2.h +++ b/src/CLI2.h @@ -110,6 +110,7 @@ private: */ void handleArg0 (); void lexArguments (); + void handleTerminator (); void aliasExpansion (); void findOverrides (); void findCommand ();