Break the input loop on error or EOF
This commit is contained in:
parent
dfd4227e7a
commit
8680394167
|
@ -170,8 +170,8 @@ void app_main(void)
|
||||||
* The line is returned when ENTER is pressed.
|
* The line is returned when ENTER is pressed.
|
||||||
*/
|
*/
|
||||||
char* line = linenoise(prompt);
|
char* line = linenoise(prompt);
|
||||||
if (line == NULL) { /* Ignore empty lines */
|
if (line == NULL) { /* Break on EOF or error */
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
/* Add the command to the history */
|
/* Add the command to the history */
|
||||||
linenoiseHistoryAdd(line);
|
linenoiseHistoryAdd(line);
|
||||||
|
@ -195,4 +195,8 @@ void app_main(void)
|
||||||
/* linenoise allocates line buffer on the heap, so need to free it */
|
/* linenoise allocates line buffer on the heap, so need to free it */
|
||||||
linenoiseFree(line);
|
linenoiseFree(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ESP_LOGE(TAG, "Error or end-of-input, terminating console");
|
||||||
|
esp_console_deinit();
|
||||||
|
vTaskDelete(NULL); /* terminate app_main */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue