casaroli opened a new pull request, #3873: URL: https://github.com/apache/nuttx-apps/pull/3873
## Summary The NSH `exit` command took no argument and always exited with 0. `exit 3` failed with "too many arguments", so a script or `sh -c` could not report a failure with `exit`. This PR lets `exit` take an optional exit status from 0 to 255, as POSIX does. A status that is not a number, or is out of range, gives an error. Without an argument, `exit` still uses 0. ## Impact `exit <status>` works. `exit` without an argument does not change. apache/nuttx#NNNN documents the argument. ## Testing `qemu-armv8a:knsh` (QEMU 11 with HVF on an Apple M4): a test program runs `sh -c` with these commands: | `sh -c` command | master | this PR | |---|---|---| | `exit 3` | 255 | 3 | | `exit 0` | 255 | 0 | | `exit` | 0 | 0 | | `exit abc` | 255 | 255 (error) | | `exit 256` | 255 | 255 (error) | `ostest` on `qemu-armv8a:knsh` and `qemu-armv8a:nsh` ends with `ostest_main: Exiting with status 0`. `tools/checkpatch.sh -c -u -m -g` passes. -- 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]
