This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new bc7377914 nshlib/nsh_parse: Fix "e" flag not take effect
bc7377914 is described below

commit bc7377914453cf914295d78b124acabb1ec0a54a
Author: wangjianyu3 <wangjian...@xiaomi.com>
AuthorDate: Wed Sep 17 16:55:24 2025 +0800

    nshlib/nsh_parse: Fix "e" flag not take effect
    
    The NSH exits when a command exits with a non-zero status, even if the "e" 
flag is not set.
    This error does not exist in NSH scripts.
    
    Without this patch:
    
      nsh> sh -c "set -e; mkdir /test; echo $?"
      nsh: /test: mkdir failed: 17
      nsh> sh -c "set +e; mkdir /test; echo $?"
      nsh: /test: mkdir failed: 17
      nsh> rm /test
      nsh> sh -c "set +e; mkdir /test; echo $?"
      0
    
    With this patch:
    
      nsh> sh -c "set -e; mkdir /test; echo $?"
      nsh: /test: mkdir failed: 17
      nsh> sh -c "set +e; mkdir /test; echo $?"
      nsh: /test: mkdir failed: 17
      1
      nsh> rm /test
      nsh> sh -c "set +e; mkdir /test; echo $?"
      0
    
    Signed-off-by: wangjianyu3 <wangjian...@xiaomi.com>
---
 nshlib/nsh_parse.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/nshlib/nsh_parse.c b/nshlib/nsh_parse.c
index ab5d39050..9b7b371af 100644
--- a/nshlib/nsh_parse.c
+++ b/nshlib/nsh_parse.c
@@ -2936,7 +2936,11 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, FAR char 
*cmdline)
           /* Parse this command */
 
           ret = nsh_parse_command(vtbl, start);
-          if (ret != OK)
+          if (ret != OK
+#ifndef CONFIG_NSH_DISABLESCRIPT
+              && !(vtbl->np.np_flags & NSH_PFLAG_IGNORE)
+#endif
+             )
             {
               /* nsh_parse_command may return (1) -1 (ERROR) meaning that the
                * command failed or we failed to start the command application

Reply via email to