From ba5fe2cbdb4f6201e54958ed0e26a6d82b0a529a Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Wed, 6 Sep 2023 18:02:50 -0700 Subject: [PATCH] Shell: fixed file error message on CLI without interactive mode. This closes #669 issue on Github. --- external/njs_shell.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/external/njs_shell.c b/external/njs_shell.c index f2eacb6a..97c92d8f 100644 --- a/external/njs_shell.c +++ b/external/njs_shell.c @@ -311,8 +311,20 @@ main(int argc, char **argv) njs_vm_opt_init(&vm_options); if (opts.file == NULL) { - opts.file = (opts.command == NULL) ? (char *) "shell" - : (char *) "string"; + if (opts.command != NULL) { + opts.file = (char *) "string"; + } + +#ifdef NJS_HAVE_READLINE + else if (opts.interactive) { + opts.file = (char *) "shell"; + } +#endif + + if (opts.file == NULL) { + njs_stderror("file name is required in non-interactive mode\n"); + goto done; + } } vm_options.file.start = (u_char *) opts.file; -- 2.47.3