-
Notifications
You must be signed in to change notification settings - Fork 682
nsh: input redirects #2469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nsh: input redirects #2469
Conversation
279bea4 to
4fb8665
Compare
4fb8665 to
551dcba
Compare
551dcba to
d4bfdbb
Compare
This adds support for `<` to redirect input on nsh commands.
This allows programs such as `cat` to read from the console (that could be redirected).
Now, if we run cat without arguments, it will just read from stdin. It can be used with redirect like `cat < infile > outfile`.
d4bfdbb to
52c4b76
Compare
|
@xiaoxiang781216 any idea why is ARM failing? |
The cod size is bigger than flash capacity(208B) of lm3s6965-ek/qemu-protected: |
|
Added the support for fileapps, which was missing. |
68529af to
44ac8b6
Compare
|
I will merge and fix the lm3s6965-ek/qemu-protected into nuttx mainline |
|
Please, @acassis @xiaoxiang781216 and @casaroli, check #2474 ASAP. Due to the urgency of this issue, I recommend reverting the commits from this PR to let @casaroli properly evaluate and fix the problem. |
|
@tmedicci the issue is with the lm3s6965-ek qemu-protected, it enabled more features than necessary, invested of reverting I suggest just doing it: -CONFIG_SYSTEM_NTPC=y |
This config is not even enabled in the defconfigs I found the issue, @acassis |
BTW, the issue happens in all Espressif's defconfig and in the simulator ( |
The PR apache#2469 broke handling of environment variables because an error in the if/else if control flow. This fixes it.
The PR #2469 broke handling of environment variables because an error in the if/else if control flow. This fixes it.
|
@casaroli Thank you. it`s very helpful. |
Board/Config/Command sim:nsh cat < /etc/init.d/rc.sysinit Problem The NSH hangs after exec the test command. `nsh_redirect()` needs to save three fd but array length is only two, stack buffer overflowed! Related: apache#2469 Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Board/Config/Command sim:nsh cat < /etc/init.d/rc.sysinit Problem The NSH hangs after exec the test command. `nsh_redirect()` needs to save three fd but array length is only two, stack buffer overflowed! Related: #2469 Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Summary
This is an attempt to refactor nsh to allow commands to have input redirects (
<). It allows<to change the stdin descriptor when starting a nuttx task or to set the save/restore strucutures on the nsh handling.I am not sure if this is the correct way to achieve this, so I open this PR to get feedback from the community. Please let me know if there is a better way or if I am misunderstanding or missing something.
I also plan to support
<<style heredoc and pipes|. But those are not implemented yet.If I get positive feedback, I could implement those in a future PR.
Partially fixes #2454
Impact
Now we can stdin and stdout redirection:
Testing
Manual testing. Still need to test how it works in telnet, usb console or altconsole.