]> git.kaiwu.me - njs.git/commitdiff
Shell: fixed file error message on CLI without interactive mode.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 7 Sep 2023 01:02:50 +0000 (18:02 -0700)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 7 Sep 2023 01:02:50 +0000 (18:02 -0700)
This closes #669 issue on Github.

external/njs_shell.c

index f2eacb6a223bb898aea55359c12daabdd2287cb8..97c92d8ff1027cbad7b5ff1399e7c2bc36d53635 100644 (file)
@@ -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;