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
sys/shell: Make echoing and prompt runtime-configurable. #12087
Conversation
I think |
I chose ps because of the |
The test for the line cancellation (ctrl-c) functionality was unable to detect error because of the way pexpect matches output. While working on the long line shell bug, a regression was about to be introduced because of this. This commit fixes the test by directly reading from the child process and expects an exact response. To make the test more robust, the newline handling was changed in native, where an extra empty line was being sent with each character.
Add a command to retrieve buffer size and then force an extremely long line. This is failing right now because of a bug in the shell. The terminal was changed to socat, as pyterm messes up the I/O and makes testing impossible.
The numeric value for EOF is (-1). This caused the shell to return the same code when EOF was encountered and when the line lenght was exceeded. Additionally, if the line length is exceeded, the correct behaviour is to consume the remaining characters until the end of the line, to prevent the following line from containing (potentially dangerous) garbage.
6d87457
to
365711c
Compare
I discovered some bugs in #10635 that were introduced during rebasing. I rebased this on top of the fixed branch. |
There was some code added to "prevent putchar from being inlined", which supposedly enlarged the code size. It does not seem to have any effect: both before and after the change the size is the same: $ BOARD=samr21-xpro make -c tests/shell all ...... text data bss dec hex filename 10416 140 2612 13168 3370 /home/jcarrano/source/vanillaRIOT/tests/shell/bin/samr21-xpro/tests_shell.elf It makes sense: the compiler is not _that_ dumb.
ifdefs in the middle of code reduce readability and debugability and should be avoided.
This adds a persistent state to the shell that stores the echo configuration and the prompt character. Both can be changed by the user with special built in commmands - @eon: turn echo on. - @eon: turn echo off. - @ps x: make x the prompt character. "@ps" (without any char) disables the prompt. This is implemented in a way that does not consume any additional RAM- it only adds some bytes to the code. A couple of bytes are stolen from the user supplied buffer to store this new configurations. The default state us given by the same compile time defines as before so this change is backwards compatible.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Contribution description
This adds a persistent state to the shell that stores the echo configuration and the prompt character. Both can be changed by the user with special built in commmands
@eon
: turn echo on.@eoff
: turn echo off.@ps x
: make x the prompt character.@ps
(without any char) disables the prompt.This is implemented in a way that does not consume any additional RAM- it only adds some bytes to the code. A couple of bytes are stolen from the user supplied buffer to store this new configurations.
The default state us given by the same compile time defines as before so this change is backwards compatible.
This will make the shell better suited for automated testing:
Testing procedure
TODO: I should add some test vectors.
Issues/PRs references
Part of #10994 .
Depends on: #10635 .
I made #12085 to fend off accusations that this will increase code size.