1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

61 Commits

Author SHA1 Message Date
Martine S. Lenders
2c1a2863ce shell: make shell_run run shell forever
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
2019-09-19 10:26:31 +02:00
Juan Carrano
fa9337d73c sys/shell: cancel current line on CTRL-C.
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.
2019-08-15 17:13:42 +02:00
Benjamin Valentin
0c98b79e2f sys/shell: reduce scope of variable 'entry' 2019-08-06 19:43:54 +02:00
Benjamin Valentin
e8dc1119b8 sys: make use of ARRAY_SIZE macro 2019-08-06 19:43:54 +02:00
Juan Carrano
b34dc3a565 sys/shell: ensure character is flushed when echoing.
When using a serial terminal without local echo, the current line
would not get updated as the user typed because the shell module's
readline() was not flushing each character.

This commit fixes that behavior. For additional clarity, fflush is
turned into a macro (flush_if_needed) which expands to either a call
to fflush() or empty, according to the standard library used.

This also fixes the erase/line editing behavior (the delete characters
were not being flushed either.)
2018-12-19 12:08:54 +01:00
Lucas Jenss
62cecc9496 Do not try to continue reading shell commands if input source is closed
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
2018-10-30 19:06:42 +01:00
Vincent Dupont
669a6922f3 sys/shell: fix build when SHELL_NO_ECHO is defined
When SHELL_NO_ECHO was defined and not SHELL_NO_PROMPT build was broken
because _putchar was not defined.
This define _putchar when one of SHELL_NO_PROMPT or SHELL_NO_ECHO is not
defined.
2017-05-04 15:49:22 +02:00
0c4b760f11 sys/shell: fix build issue when deactivating shell echo (iotlab) 2016-05-29 14:21:11 +02:00
fdf12d01b3 sys/shell: adding definition for deactiving prompt and/or echo in shell 2016-05-26 09:36:23 +02:00
d7b9053e23 sys: shell: work around inlined putchar 2015-09-04 19:38:16 +02:00
13995e878f sys: shell: get rid of some parameters 2015-09-03 13:33:18 +02:00
Cenk Gündoğan
4deb0213b9 sys/shell/shell.c: command not found in one line 2015-08-12 13:16:37 +02:00
adabd8c930 shell: let readline return an error on empty line so prompt gets print again 2015-07-06 11:33:44 +02:00
2d7642b8c1 shell: flush stdout after printing prompt 2015-07-06 09:53:29 +02:00
Hauke Petersen
1eec484a30 sys/shell: changed signature of put_char pointer
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.
2015-06-14 17:02:57 +02:00
Hauke Petersen
2323c08d32 sys/shell: fixed and unified doxygen headers
- changed doxygen group name to sys_shell
- added some missing fields
- unified the doxygen header format
2015-03-03 18:10:06 +01:00
René Kijewski
5f262be568 Merge pull request #1653 from medicalwei/shell_backspace
Add backspace functionality in shell
2014-09-29 21:21:41 +02:00
Yao Wei
b5d3c65672 Add 0x7f as backspace key in shell 2014-09-24 15:40:21 +08:00
Yao Wei
208f889a4a add backspace functionality in shell 2014-09-11 21:27:20 +08:00
Ludwig Ortmann
3ca4f18479 doc: use lgplv2.1-short license header instead of lgpl-short-riot 2014-07-31 22:57:20 +02:00
Ludwig Ortmann
b6846e31fc doc: fix most occurences of FU as an author
.. but only if there are other authors as well
2014-07-29 17:23:11 +02:00
Oleg Hahm
36b9f7e7d7 Merge pull request #1257 from Kijewski/shell-fix-newline
shell: fix newlines
2014-06-22 23:56:36 +02:00
René Kijewski
94bb326fc0 shell: fix newlines 2014-05-30 21:10:05 +02:00
René Kijewski
638666c34a shell: print command if not found 2014-05-12 22:07:35 +02:00
René Kijewski
97593e9f05 shell: add myself to authors 2014-03-10 18:17:05 +01:00
René Kijewski
a1df6a86bb shell: don't ignore IO errors 2014-03-10 13:48:00 +01:00
René Kijewski
3f289760bf shell: accept UTF8 input 2014-03-10 13:47:33 +01:00
René Kijewski
03e174ed96 Allow escaped characters in shell
Per #708.

This patch allows escaped characters in the shell, and makes the
apostrophe a quotation mark. The escape character is backslash.

The term "escape character" is used liberally in here: if a backslash is
encountered in the command line, the next character will be taken
verbatim. No escape sequences are understood, i.e. `"\n"` is just the
letter `n`, not a new line.
2014-02-26 18:09:46 +01:00
René Kijewski
28c4ef45f7 Do not skip over the null terminator 2014-02-26 13:21:25 +01:00
René Kijewski
829966ee32 Print error message on any quoting error 2014-02-25 17:54:17 +01:00
René Kijewski
c507632e50 Use argc and argv in shell handlers
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`.
2014-02-25 17:54:17 +01:00
Martin Lenders
df83221983 Hotfix for error introduced in #678 2014-02-18 22:44:00 +01:00
Christian Mehlis
33239487bf shell: remove useless copying of input string 2014-02-10 15:41:04 +01:00
René Kijewski
891245cf60 Allow Mac linebreaks in shell
QEMU uses Mac style newlines in its UART implementation.
This change allows Unix ("\n"), DOS ("\r\n") and Mac ("\r") style
linebreaks.
2014-01-27 19:25:03 +01:00
Martin Lenders
68f7b9090e Make shell buffer size a shell property 2013-12-20 11:10:50 +01:00
Oleg Hahm
903ec54a43 making include directives consistent 2013-12-19 15:31:37 +01:00
LudwigOrtmann
1442170d41 Merge pull request #300 from kaspar030/shell_refactor
shell: refactor default shell command handling
2013-12-03 04:44:59 -08:00
6634c56830 shell: fix compile warning and add some comments 2013-12-02 17:36:58 +01:00
Ludwig Ortmann
d6c213fb47 fix grammar in license header 2013-11-23 13:11:56 +01:00
Christian Mehlis
84e73ae324 clean up shell 2013-11-14 10:45:24 +01:00
Christian Mehlis
bb85cb33d9 shell: dont't use malloc on each line 2013-11-14 10:45:24 +01:00
3be2a3227a shell: refactor default shell command handling
before, we actually duplicated code for handling of shell commands
supplied to shell_init and those hardcoded by MODULE_SHELL_COMMANDS.

This patch refactors shell.c find_handler and print_help so there's
no duplicated code.
2013-11-04 17:06:50 +01:00
Oliver Hahm
c8bee9e554 fixed coding style (space after most keywords) 2013-06-24 22:37:35 +02:00
Oliver Hahm
5c52e1ce2e coding conventions for most of system libraries 2013-06-22 05:11:53 +02:00
Ludwig Ortmann
dfeae74661 lose > before output, prompt when ready for input 2013-03-18 15:37:32 +01:00
Oleg Hahm
2277b366b2 * removed outdated occurrences of (u|µ)kleos and FeuerWare 2013-03-07 20:51:26 +01:00
Oliver Hahm
551d684155 Merge branch 'master' of ssh://ukleos.org:2222/home/git/ukleos 2012-02-24 14:49:58 +01:00
Oliver Hahm
0d6d3e2c43 [board msba2-common] [sys chardev_thread] [sys shell] [driver cc110x_ng] [core msg]
* some cosmetics and cleanups
2012-02-16 21:33:41 +01:00
Oliver Hahm
961b4df179 [core cib] [projects default] [sys shell]
* fixed some minor issues found by splint
2012-02-14 14:49:45 +01:00
Oliver Hahm
1eec8e170e * introduced flashrom driver for msb430
* restructured some files concerning flashrom access
* added some ifdefs to shell commands
2010-12-03 22:22:58 +01:00