sys/shell: cancel current line on CTRL-C.#11004
Conversation
e8ac6a8 to
968c720
Compare
|
Doesn't work on native ;-) |
It works if you do Ctrl-V Ctrl-C, which is what the test script does. Otherwise the native port catches it as a SIGINT and the process exits. That can be changed if it makes sense. |
|
Nope, when I try it in |
kaspar030
left a comment
There was a problem hiding this comment.
Apart from conditionally changing "RIOT_TERMINAL", please split out both the miniterm and dict-to-tuple commits. They should be very fast to review.
I didn't test this yet but it sounds like you're thinking this should terminate a running process with ^C (that's what #10715 is about) which would be lovely too, but this PR is instead about clearing the command you're typing to get a fresh/empty prompt to replace one that has some partial or wrong command typed in. It's a little thing but it's a very nice thing because the shells we're all accustomed to using on *nix behave this way so it improves our shell UX considerably. In practice it looks like this: |
|
I'm realising now that this is not the best way to implement this feature (it is now wrong either.) The right thing to do here would be to implement a sort of "line discipline" in
Of course, By the way, the line discipline is the place to put stuff like ethos/slip (this is what's done in unix) though ideally in a separate module and not patched with #ifdefs. |
Yepp, I misunderstood the purpose of this PR. Sorry for the noise! |
For test scripts, a terminal that does not modify the input and output streams, configured without local echo, is preferred as it ensures the test setup is introducing as little noise as possible.
CTRL-C cancels the current line, similar to how getty works. This is useful if one is using a dumb terminal to communicate with a node, as it saves having to repeatedly type backspace to discard the current line. It also helps when connecting to an already running node, as one does not know what is on the line buffer, the safest thing to do is to begin by sending a ctrl-C. This is a suggestion of @benemorius.
Python dictionaries are not guaranteed to be ordered until version 3.7. In 3.6 they are ordered too, but that is an implementation detail. riotdocker seems to be using 3.5. As it stands now, it would not be a problem if the test commands are run in a random order, except that: - It would result in non-reproduceable tests. - It hinders testing other functionality, such as exiting the shell.
968c720 to
21a4cec
Compare
|
Now that socat is available as a RIOT_TERMINAL it rebased and used it in the test. |
21a4cec to
2946f4b
Compare
Send garbage, cancel it and issue a valid command. No errors should ocurr.
kaspar030
left a comment
There was a problem hiding this comment.
Tested on a nucleo-072rb, works like a charm.
native is more troublesome, but that's expected.
ACK.
|
This breaks on boards that cannot run when configured with |
|
If it expects a clean terminal output, it will, I think, also fail on all boards using |
Contribution description
Just like in a regular UNIX terminal, control-C now cancels the current line. This is a suggestion of @benemorius.
This is useful if one is using a dumb terminal to communicate with a node, as it saves having to repeatedly type backspace to discard the current line. It also helps when connecting to an already running node,
as one does not know what is on the line buffer, the safest thing to do is to begin by sending a ctrl-C.
Other changes
To be able to test this I had to do a couple of modifications to
tests/shell.Fix the use of python dictionaries: Python dictionaries are not guaranteed to be ordered until version
3.7. In 3.6 they are ordered too, but that is an implementation detail. riotdocker seems to be using 3.5. The commands in this test were stored in a dict.
Use miniterm instead of pyterm: pyterm messes up control characters, so the test was changed to use
miniterm.py instead.
Testing procedure
I have included a test. It should work both on a board or in native:
If testing by hand:
Issues/PRs references
Depends on
#11003for testing.Part of #10994 .
Split from #10788 .