[njs] Shell: fixed file error message on CLI without interactive mode.

Dmitry Volyntsev xeioex at nginx.com
Thu Sep 7 01:03:42 UTC 2023


details:   https://hg.nginx.org/njs/rev/1f0adb4b81da
branches:  
changeset: 2192:1f0adb4b81da
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Sep 06 18:02:50 2023 -0700
description:
Shell: fixed file error message on CLI without interactive mode.

This closes #669 issue on Github.

diffstat:

 external/njs_shell.c |  16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diffs (26 lines):

diff -r 0f1e76ab9d45 -r 1f0adb4b81da external/njs_shell.c
--- a/external/njs_shell.c	Tue Sep 05 18:15:14 2023 -0700
+++ b/external/njs_shell.c	Wed Sep 06 18:02:50 2023 -0700
@@ -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;


More information about the nginx-devel mailing list