brbzull0 commented on code in PR #12598:
URL: https://github.com/apache/trafficserver/pull/12598#discussion_r2452162217


##########
src/tscore/ArgParser.cc:
##########
@@ -504,26 +504,25 @@ bool
 ArgParser::Command::parse(Arguments &ret, AP_StrVec &args)
 {
   bool command_called = false;
-  // iterate through all arguments
-  for (unsigned i = 0; i < args.size(); i++) {
-    if (_name == args[i]) {
-      command_called = true;
-      // handle the option
-      append_option_data(ret, args, i);
-      // handle the action
-      if (_f) {
-        ret._action = _f;
-      }
-      std::string err = handle_args(ret, args, _key, _arg_num, i);
-      if (!err.empty()) {
-        help_message(err);
-      }
-      // set ENV var
-      if (!_envvar.empty()) {
-        const char *const env = getenv(_envvar.c_str());
-        ret.set_env(_key, nullptr != env ? env : "");
-      }
-      break;
+  // Only check the first remaining argument for command name to avoid
+  // treating arguments as commands (e.g., "metric match host" where "host" is 
an arg, not a command)
+  if (!args.empty() && _name == args[0]) {
+    command_called = true;
+    unsigned index{0};
+    // handle the option
+    append_option_data(ret, args, index);
+    // handle the action
+    if (_f) {
+      ret._action = _f;
+    }
+    const std::string err = handle_args(ret, args, _key, _arg_num, index);

Review Comment:
   Added a comment to consider this, there should be no side effect here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to