]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: vars/cli: fix missing LF after "get var" output
authorWilly Tarreau <w@1wt.eu>
Thu, 8 Feb 2024 17:13:32 +0000 (18:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 8 Feb 2024 17:22:01 +0000 (18:22 +0100)
"get var" on the CLI was also missing an LF, and the vtest as well, so
that fixing only the code breaks the vtest. This must be backported to
2.4 as the issue was brought with commit c35eb38f1d ("MINOR: vars/cli:
add a "get var" CLI command to retrieve global variables").

reg-tests/sample_fetches/vars.vtc
src/vars.c

index 5144e9f4e7a775f2e71284fe52d52d03960421fd..29d474cf2c7cd6fa30d56ee967d3d41528196f77 100644 (file)
@@ -34,7 +34,7 @@ haproxy h1 -conf {
 
 haproxy h1 -cli {
     send "get var proc.int5"
-    expect ~ "^proc.int5: type=sint value=<5>$"
+    expect ~ "^proc.int5: type=sint value=<5>"
 }
 
 client c1 -connect ${h1_fe1_sock} {
@@ -51,7 +51,7 @@ client c1 -connect ${h1_fe1_sock} {
 
 haproxy h1 -cli {
     send "get var proc.int5"
-    expect ~ "^proc.int5: type=sint value=<10>$"
+    expect ~ "^proc.int5: type=sint value=<10>"
 }
 
 client c2 -connect ${h1_fe1_sock} {
@@ -68,7 +68,7 @@ client c2 -connect ${h1_fe1_sock} {
 
 haproxy h1 -cli {
     send "get var proc.int5"
-    expect ~ "^proc.int5: type=sint value=<20>$"
+    expect ~ "^proc.int5: type=sint value=<20>"
 }
 
 haproxy h1 -cli {
index 05e79f44a8d2ed2e57592d1d42ca628c156abdd5..2cddb7749e9a46a90389745f6b7bcf8ef681c990 100644 (file)
@@ -1158,7 +1158,7 @@ static int vars_parse_cli_get_var(char **args, char *payload, struct appctx *app
 
        if (!sample_casts[smp.data.type][SMP_T_STR] ||
            !sample_casts[smp.data.type][SMP_T_STR](&smp)) {
-               chunk_appendf(&trash, "(undisplayable)");
+               chunk_appendf(&trash, "(undisplayable)\n");
        } else {
                /* Display the displayable chars*. */
                b_putchr(&trash, '<');
@@ -1169,6 +1169,7 @@ static int vars_parse_cli_get_var(char **args, char *payload, struct appctx *app
                                b_putchr(&trash, '.');
                }
                b_putchr(&trash, '>');
+               b_putchr(&trash, '\n');
                b_putchr(&trash, 0);
        }
        return cli_msg(appctx, LOG_INFO, trash.area);