From 9b06b508f957ba1cc5b970d291bb5cc3277db237 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 17 May 2020 15:44:09 -0600 Subject: [PATCH] This critical behavior was broken by this commit: commit 9a28ccf836c1b9f0eb5e1163964042eddc207697 Author: chao.an Date: Fri Feb 21 09:54:47 2020 +0800 nsh/parse: try the builtin configuration first In the case of enable the BUILTIN_APPS/FILE_APPS at the same time, try the builtin list first to ensure that the relevant configuration (stacksize, priority) can be set normally. This commit breaks the feature because it changes the order to that the built-in application is tried first. Hence, the version on the file system will never replace the built-in version. That commit must be reverted in order to restore the correct functionality. Revert "nsh/parse: try the builtin configuration first" This reverts commit 9a28ccf836c1b9f0eb5e1163964042eddc207697. --- nshlib/nsh_parse.c | 88 +++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/nshlib/nsh_parse.c b/nshlib/nsh_parse.c index e35ee4ee2..bfe9eb719 100644 --- a/nshlib/nsh_parse.c +++ b/nshlib/nsh_parse.c @@ -503,18 +503,55 @@ static int nsh_execute(FAR struct nsh_vtbl_s *vtbl, #endif int ret; - /* Does this command correspond to a built-in command? - * nsh_builtin() returns: + /* Does this command correspond to an application filename? + * nsh_fileapp() returns: * - * -1 (ERROR) if the application task corresponding to 'argv[0]' could - * not be started (possibly because it doesn not exist). + * -1 (ERROR) if the application task corresponding to 'argv[0]' could not + * be started (possibly because it does not exist). * 0 (OK) if the application task corresponding to 'argv[0]' was * and successfully started. If CONFIG_SCHED_WAITPID is * defined, this return value also indicates that the * application returned successful status (EXIT_SUCCESS) * 1 If CONFIG_SCHED_WAITPID is defined, then this return value - * indicates that the application task was spawned - * successfully but returned failure exit status. + * indicates that the application task was spawned successfully + * but returned failure exit status. + * + * Note the priority is not effected by nice-ness. + */ + +#ifdef CONFIG_NSH_FILE_APPS + ret = nsh_fileapp(vtbl, argv[0], argv, redirfile, oflags); + if (ret >= 0) + { + /* nsh_fileapp() returned 0 or 1. This means that the built-in + * command was successfully started (although it may not have ran + * successfully). So certainly it is not an NSH command. + */ + + /* Save the result: success if 0; failure if 1 */ + + return nsh_saveresult(vtbl, ret != OK); + } + + /* No, not a file name command (or, at least, we were unable to start a + * program of that name). Maybe it is a built-in application or an NSH + * command. + */ + +#endif + + /* Does this command correspond to a built-in command? + * nsh_builtin() returns: + * + * -1 (ERROR) if the application task corresponding to 'argv[0]' could not + * be started (possibly because it doesn not exist). + * 0 (OK) if the application task corresponding to 'argv[0]' was + * and successfully started. If CONFIG_SCHED_WAITPID is + * defined, this return value also indicates that the + * application returned successful status (EXIT_SUCCESS) + * 1 If CONFIG_SCHED_WAITPID is defined, then this return value + * indicates that the application task was spawned successfully + * but returned failure exit status. * * Note the priority if not effected by nice-ness. */ @@ -538,44 +575,7 @@ static int nsh_execute(FAR struct nsh_vtbl_s *vtbl, } /* No, not a built in command (or, at least, we were unable to start a - * built-in command of that name). Maybe it is a built-in application - * or an NSH command. - */ - -#endif - - /* Does this command correspond to an application filename? - * nsh_fileapp() returns: - * - * -1 (ERROR) if the application task corresponding to 'argv[0]' could - * not be started (possibly because it does not exist). - * 0 (OK) if the application task corresponding to 'argv[0]' was - * and successfully started. If CONFIG_SCHED_WAITPID is - * defined, this return value also indicates that the - * application returned successful status (EXIT_SUCCESS) - * 1 If CONFIG_SCHED_WAITPID is defined, then this return value - * indicates that the application task was spawned - * successfully but returned failure exit status. - * - * Note the priority is not effected by nice-ness. - */ - -#ifdef CONFIG_NSH_FILE_APPS - ret = nsh_fileapp(vtbl, argv[0], argv, redirfile, oflags); - if (ret >= 0) - { - /* nsh_fileapp() returned 0 or 1. This means that the built-in - * command was successfully started (although it may not have ran - * successfully). So certainly it is not an NSH command. - */ - - /* Save the result: success if 0; failure if 1 */ - - return nsh_saveresult(vtbl, ret != OK); - } - - /* No, not a file name command (or, at least, we were unable to start a - * program of that name). Treat it like an NSH command. + * built-in command of that name). Treat it like an NSH command. */ #endif