From baf5509b59619051601f7d5271a95c5edb149dde Mon Sep 17 00:00:00 2001 From: Takumi Ando Date: Mon, 15 May 2023 17:44:46 +0900 Subject: [PATCH] nshlib: Add support for disabling echoback If CONFIG_NSH_DISABLE_ECHOBACK is selected, the NSH disables echoback prompt. Signed-off-by: Takumi Ando --- nshlib/Kconfig | 6 ++++++ nshlib/nsh_session.c | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/nshlib/Kconfig b/nshlib/Kconfig index 196af77a1..2ecefc6d7 100644 --- a/nshlib/Kconfig +++ b/nshlib/Kconfig @@ -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 diff --git a/nshlib/nsh_session.c b/nshlib/nsh_session.c index 4e5621552..4c254ddde 100644 --- a/nshlib/nsh_session.c +++ b/nshlib/nsh_session.c @@ -28,6 +28,7 @@ #include #include #include +#include #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 (; ; )