nshlib: Add support for disabling echoback

If CONFIG_NSH_DISABLE_ECHOBACK is selected,
the NSH disables echoback prompt.

Signed-off-by: Takumi Ando <t-ando@advaly.co.jp>
This commit is contained in:
Takumi Ando 2023-05-15 17:44:46 +09:00 committed by Xiang Xiao
parent c356fe92bc
commit baf5509b59
2 changed files with 22 additions and 0 deletions

View File

@ -70,6 +70,12 @@ config NSH_PROMPT_STRING
---help---
Provide the shell prompt string, default is "nsh> ".
config NSH_DISABLE_ECHOBACK
bool "Disable echoback"
default n
---help---
If this option is selected, the NSH disables echoback.
choice
prompt "Command Line Editor"
default NSH_READLINE if DEFAULT_SMALL

View File

@ -28,6 +28,7 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <termios.h>
#ifdef CONFIG_NSH_CLE
# include "system/cle.h"
@ -169,6 +170,21 @@ int nsh_session(FAR struct console_stdio_s *pstate,
}
}
#ifdef CONFIG_NSH_DISABLE_ECHOBACK
/* Disable echoback */
if (isatty(INFD(pstate)))
{
struct termios cfg;
if (tcgetattr(INFD(pstate), &cfg) == 0)
{
cfg.c_lflag &= ~ECHO;
tcsetattr(INFD(pstate), TCSANOW, &cfg);
}
}
#endif
/* Then enter the command line parsing loop */
for (; ; )