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 Apr 2, 2020
1 parent 0be3f35 commit d33a604
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions sys/shell/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ static void _putchar(int c) {
/* on native, stop RIOT on EOF */
#ifndef SHELL_SHUTDOWN_ON_EOF
# ifdef CPU_NATIVE
# define SHELL_SHUTDOWN_ON_EOF
# define SHELL_SHUTDOWN_ON_EOF (1)
# else
# define SHELL_SHUTDOWN_ON_EOF (0)
# endif
#endif /* SHELL_SHUTDOWN_ON_EOF */

Expand Down Expand Up @@ -347,15 +349,18 @@ static inline void print_prompt(void)
void shell_run_once(const shell_command_t *shell_commands,
char *line_buf, int len)
{
print_prompt();
bool running = true;

while (1) {
while (running) {

print_prompt();
int res = readline(line_buf, len);

switch (res) {

case EOF:
return;
running = false;
break;

case -ENOBUFS:
puts("shell: maximum line length exceeded");
Expand All @@ -365,11 +370,9 @@ void shell_run_once(const shell_command_t *shell_commands,
handle_input_line(shell_commands, line_buf);
break;
}

print_prompt();
}

#if IS_ACTIVE(SHELL_SHUTDOWN_ON_EOF)
#if SHELL_SHUTDOWN_ON_EOF
pm_off();
#endif
}

0 comments on commit d33a604

Please sign in to comment.