diff --git a/components/console/Kconfig b/components/console/Kconfig new file mode 100644 index 0000000000..a153b490de --- /dev/null +++ b/components/console/Kconfig @@ -0,0 +1,10 @@ +menu "Linenoise" + + config ESP_LINENOISE_RETURN_ZERO_STRING + bool "Return 0 length strings" + default n + help + If enabled linenoise will return 0 length strings if the user presses enter with out typing + a command, if disabled NULL will be returned instead. + +endmenu \ No newline at end of file diff --git a/components/console/linenoise/linenoise.c b/components/console/linenoise/linenoise.c index 3b2e1c18e7..0cf86fc0c2 100644 --- a/components/console/linenoise/linenoise.c +++ b/components/console/linenoise/linenoise.c @@ -116,6 +116,7 @@ #include #include #include "linenoise.h" +#include "sdkconfig.h" #define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100 #define LINENOISE_MAX_LINE 4096 @@ -979,11 +980,14 @@ char *linenoise(const char *prompt) { } else { count = linenoiseDumb(buf, LINENOISE_MAX_LINE, prompt); } +#ifdef CONFIG_ESP_LINENOISE_RETURN_ZERO_STRING if (count >= 0) { +#else + if (count > 0) { +#endif sanitize(buf); count = strlen(buf); - } - if (count < 0) { + } else { free(buf); return NULL; }