casaroli opened a new pull request, #3915: URL: https://github.com/apache/nuttx-apps/pull/3915
## Summary `nsh_execute()` redirects the output of an NSH command, runs it, and then restores the output if one of the `np_redir_*` flags is set. `source` and `.` parse each line of the script with the same vtbl, and `nsh_parse_command()` clears these flags for each line. So after `source script > /dev/null` NSH did not call `nsh_undirect()`. The console kept the closed redirection descriptor as its output: the prompt and all later output were lost, and NSH looked hung. This PR keeps the redirection state in a local variable and restores the output when it is set. ## Impact Only NSH commands that parse more lines with the same vtbl (`source`, `.`) and have a redirection. Other commands do not change. ## Testing qemu-armv8a:knsh under QEMU with HVF, NSH from this branch, a script `e4.sh` with one line `echo E4-INNER`: | Command | master | this PR | |---|---|---| | `source e4.sh` | prints E4-INNER | prints E4-INNER | | `source e4.sh > /dev/null`, then `echo E4-AFTER1` | no prompt, no output any more | prompt, E4-AFTER1 | | `source e4.sh > e4.out`, then `cat e4.out` | (not reached) | E4-INNER | | `. e4.sh 2> /dev/null`, then `echo E4-AFTER2` | (not reached) | E4-INNER, E4-AFTER2 | ostest exits with status 0 on qemu-armv8a:knsh and qemu-armv8a:nsh (NSH from this branch). Build with NuttX master, each OK: qemu-armv8a:nsh (flat, arm64), qemu-armv8a:knsh (kernel, arm64), rv-virt:nsh64 (flat, rv64), rv-virt:pnsh64 (protected, rv64). `tools/checkpatch.sh -c -u -m -g` passes. No documentation change. -- 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]
