wangchdo commented on code in PR #3168:
URL: https://github.com/apache/nuttx-apps/pull/3168#discussion_r2312232749
##########
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:
Done
##########
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:
Done
--
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]