From: Dmitry Volyntsev Date: Thu, 7 Sep 2023 01:02:50 +0000 (-0700) Subject: Shell: fixed file error message on CLI without interactive mode. X-Git-Tag: 0.8.1~8 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=ba5fe2cbdb4f6201e54958ed0e26a6d82b0a529a;p=njs.git Shell: fixed file error message on CLI without interactive mode. This closes #669 issue on Github. --- 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;