xiaoxiang781216 commented on code in PR #3168:
URL: https://github.com/apache/nuttx-apps/pull/3168#discussion_r2309369264


##########
nshlib/nsh_builtin.c:
##########
@@ -268,5 +268,4 @@ int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char 
*cmd,
 
   return ret;
 }
-
 #endif /* CONFIG_NSH_BUILTIN_APPS */

Review Comment:
   remove too



##########
nshlib/nsh_builtin.c:
##########
@@ -43,7 +43,7 @@
 #include "nsh.h"
 #include "nsh_console.h"
 
-#ifdef CONFIG_NSH_BUILTIN_APPS
+#if defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_NSH_BUILTIN_AS_COMMAND)

Review Comment:
   remove, don't need



##########
nshlib/nsh_command.c:
##########
@@ -1228,6 +1233,31 @@ int nsh_command(FAR struct nsh_vtbl_s *vtbl, int argc, 
FAR char *argv[])
 
   cmd = argv[0];
 
+#ifdef CONFIG_NSH_BUILTIN_AS_COMMAND
+  /* Check if the command is available in the builtin list */
+
+  index = builtin_isavail(cmd);
+
+  if (index > 0)
+    {
+      /* Get the builtin structure by index */
+
+      builtin = builtin_for_index(index);
+      if (builtin != NULL)
+        {
+          is_builtin_cmd = true;
+        }
+    }
+
+  if (is_builtin_cmd)
+    {
+      /* Directly call the builtin main() function to execute the command */
+
+      ret = (builtin->main)(argc, (FAR char **)argv);

Review Comment:
   move to line 1248 and return directly



##########
nshlib/nsh_command.c:
##########
@@ -1213,10 +1213,15 @@ static int cmd_expr(FAR struct nsh_vtbl_s *vtbl, int 
argc, FAR char **argv)
 
 int nsh_command(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char *argv[])
 {
-  const struct cmdmap_s *cmdmap;
-  const char            *cmd;
-  nsh_cmd_t              handler = cmd_unrecognized;
-  int                    ret;
+  const struct cmdmap_s  *cmdmap;
+  const char             *cmd;
+  nsh_cmd_t               handler = cmd_unrecognized;
+#ifdef CONFIG_NSH_BUILTIN_AS_COMMAND
+  const struct builtin_s *builtin;
+  bool                    is_builtin_cmd = false;

Review Comment:
   remove, let's set builtin to NULL



-- 
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