[njs] Improved interactive shell.

Vadim Zhestikov v.zhestikov at f5.com
Sat Jul 1 02:51:13 UTC 2023


details:   https://hg.nginx.org/njs/rev/0e97da4147da
branches:  
changeset: 2173:0e97da4147da
user:      Vadim Zhestikov <v.zhestikov at f5.com>
date:      Fri Jun 30 19:49:46 2023 -0700
description:
Improved interactive shell.

diffstat:

 external/njs_shell.c |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (42 lines):

diff -r 2c532e7c29ac -r 0e97da4147da external/njs_shell.c
--- a/external/njs_shell.c	Fri Jun 30 19:49:45 2023 -0700
+++ b/external/njs_shell.c	Fri Jun 30 19:49:46 2023 -0700
@@ -1073,19 +1073,24 @@ njs_cb_line_handler(char *line_in)
     njs_int_t  ret;
     njs_str_t  line;
 
-    if (line_in == NULL || strcmp(line_in, ".exit") == 0) {
+    if (line_in == NULL) {
         njs_running = NJS_DONE;
         return;
     }
 
+    line.start = (u_char *) line_in;
+    line.length = njs_strlen(line.start);
+
+    if (strcmp(line_in, ".exit") == 0) {
+        njs_running = NJS_DONE;
+        goto free_line;
+    }
+
     njs_sigint_count = 0;
 
-    line.start = (u_char *) line_in;
-    line.length = njs_strlen(line.start);
-
     if (line.length == 0) {
         rl_callback_handler_install(">> ", njs_cb_line_handler);
-        return;
+        goto free_line;
     }
 
     add_history((char *) line.start);
@@ -1099,6 +1104,8 @@ njs_cb_line_handler(char *line_in)
         rl_callback_handler_install(">> ", njs_cb_line_handler);
     }
 
+free_line:
+
     free(line.start);
 }
 


More information about the nginx-devel mailing list