JianyuWang0623 opened a new pull request, #3184:
URL: https://github.com/apache/nuttx-apps/pull/3184

   ## Summary
   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.
   - Comparison with Bash
   ```bash
   $ bash -c "set -e; mkdir /tmp/test; echo $?"
   mkdir: cannot create directory ‘/tmp/test’: File exists
   $ bash -c "set +e; mkdir /tmp/test; echo $?"
   mkdir: cannot create directory ‘/tmp/test’: File exists
   1
   $ rmdir /tmp/test
   $ bash -c "set +e; mkdir /tmp/test; echo $?"
   0
   
   $ bash --version
   GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
   Copyright (C) 2020 Free Software Foundation, Inc.
   License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
   
   This is free software; you are free to change and redistribute it.
   There is NO WARRANTY, to the extent permitted by law.
   ```
   ## Impact
   nshlib/nsh_parse
   
   ## Testing
   
   - Without this patch:
     ```bash
     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:
     ```bash
     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
     ```


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