We do not need to add an array of pointers to the shell commands, just
an array of shell commands is sufficient. This reduced the overhead of
XFA by `sizeof(void *)` per command.
This command does the same as `help`, but provides a machine readable
JSON rather than a human readable table. It is only provided when the
(pseudo-)module `shell_builtin_cmd_help_json` is used.
Introduce optional user shell_post_readline_hook, shell_pre_command_hook, shell_post_command_hook.
Enable with USEMODULE=shell_hooks.
Calls user implemented *_hook functions if defined.
If implementation does not exist, nothing happens.
The intent is to make profiling of the shell command timings easier.
Test provided in tests/shell with USEMODULE=shell_hooks.
Currently when the shell receives EOF on `native`, sending EOF
(ctrl + D) closes the stdin file descriptor, leading to all
consecutive reads to also return EOF.
The result is that `shell_run_forever()` will re-start the shell
forever in a loop, filling up the terminal with
> > > > > > > > > > > > > > > > > > > > > > …
until the user hits ctrl + C.
This is annoying.
Instead, cleanly shutdown RIOT when receiving EOF on native, which
should match the expected behaviour of most users.
This change is in preparation to [PR 10788]. PR 10788 will make the
shell exitable which may lead to unexpected behavior in comparison to
previous usage of the shell.
To prevent this, this PR introduces two "new" functions to the shell's
API: `shell_run_once()` and `shell_run_forever()`.
`shell_run_once()` basically has the same behavior as `shell_run()` in
current master: Start a shell and continue reading lines until EOF is
reached.
`shell_run_forever()` wraps around `shell_run_once()` and restarts the
shell if it exits.
`shell_run()` is re-introduced as a back-porting alias for
`shell_run_forever()`.
As a consequence all current calls to `shell_run()` won't exit even
with [PR 10788] merged (which would add EOT as additional exit
condition for `shell_run_once()`).
[PR 10788]: https://github.com/RIOT-OS/RIOT/pull/10788
In RIOT native, sending CTRL+D to a shell started using shell_run would resulted in and
endless prompt loop. I've been unable to trigger such a behaviour
on actual hardware using a UART connection, but calling `pm_off` seemed
like a better alternative than having an `#ifdef BOARD_NATIVE`.
Fixes#9946
changed from void(*put_char)(int) to int(*putchar)(int).
This is beneficial, as now the std-libs putchar can be given as
an argument to shell_init() directly.
Compare #708.
Now the tokenization of an input line is done by the shell itself. You
may quote arguments with `"..."`. Empty arguments, supplied by `""` are
preserved. Spaces in between arguments are squasheds; spaces inside
quotes are preserved.
You cannot partially quote an argument. You must not use
- `cmd "abc`,
- `cmd abc"def"`, or
- `cmd "abc"def`.