Skip to content

Commit

Permalink
fixup! sys/shell: native: stop RIOT when the shell reads EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Jun 23, 2020
1 parent d9faa71 commit f85627c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions sys/include/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ extern "C" {
/**
* @brief On native, stop RIOT on EOF
*/
#ifndef CONFIG_SHELL_SHUTDOWN_ON_EOF
#ifndef CONFIG_SHELL_SHUTDOWN_ON_EXIT
# ifdef CPU_NATIVE
# define CONFIG_SHELL_SHUTDOWN_ON_EOF 1
# define CONFIG_SHELL_SHUTDOWN_ON_EXIT 1
# endif
#endif

Expand Down Expand Up @@ -85,6 +85,9 @@ void shell_run_once(const shell_command_t *commands, char *line_buf, int len);
/**
* @brief Start a shell and restart it if it exits
*
* If `CONFIG_SHELL_SHUTDOWN_ON_EXIT` is set (e.g. on native)
* the shell will instead shut down RIOT once EOF is reached.
*
* @param[in] commands ptr to array of command structs
* @param[in] line_buf Buffer that will be used for reading a line
* @param[in] len nr of bytes that fit in line_buf
Expand All @@ -94,6 +97,10 @@ static inline void shell_run_forever(const shell_command_t *commands,
{
while (1) {
shell_run_once(commands, line_buf, len);

if (IS_ACTIVE(CONFIG_SHELL_SHUTDOWN_ON_EXIT)) {
pm_off();
}
}
}

Expand All @@ -107,12 +114,7 @@ static inline void shell_run_forever(const shell_command_t *commands,
static inline void shell_run(const shell_command_t *commands,
char *line_buf, int len)
{
if (IS_ACTIVE(CONFIG_SHELL_SHUTDOWN_ON_EOF)) {
shell_run_once(commands, line_buf, len);
pm_off();
} else {
shell_run_forever(commands, line_buf, len);
}
shell_run_forever(commands, line_buf, len);
}

#ifdef __cplusplus
Expand Down

0 comments on commit f85627c

Please sign in to comment.