From: Dmitry Volyntsev Date: Fri, 13 Feb 2026 05:31:23 +0000 (-0800) Subject: Shell: fixed interactive mode detection for piped stdin. X-Git-Tag: 0.9.6~14 X-Git-Url: http://www.kaiwu.me/sitemap.xml?a=commitdiff_plain;h=3b91c6712979f863144979fe0cb2bfb09c8a173e;p=njs.git Shell: fixed interactive mode detection for piped stdin. Previously, libedit callback API (rl_callback_read_char) was used for interactive input processing. Unlike the blocking readline() API, the callback interface does not work correctly when stdin is a pipe: input characters are silently dropped and the line handler is never invoked. The issue was introduced in 4988565c6ea7 (0.8.0). The fix is to check isatty(STDIN_FILENO) and fall back to the file processing mode when stdin is not a terminal. --- diff --git a/external/njs_shell.c b/external/njs_shell.c index 63f502ab..b65b98aa 100644 --- a/external/njs_shell.c +++ b/external/njs_shell.c @@ -479,6 +479,11 @@ main(int argc, char **argv) goto done; } + if (opts.interactive && !isatty(STDIN_FILENO)) { + opts.interactive = 0; + opts.file = (char *) "-"; + } + if (opts.version != 0) { njs_printf("%s\n", NJS_VERSION); ret = NJS_OK;