BUG/MEDIUM: cli: fix once for all the problem of missing trailing LFs

Some commands are still missing their trailing LF, and very few were even
already spotted in the past emitting more than one. The risk of missing
this LF is particularly high, especially when tests are run in non-
interactive mode where the output looks good at first glance. The problem
is that once run in interactive mode, the missing empty line makes the
command not being complete, and scripts can wait forever.

Let's tackle the problem at its root: messages emitted at the end must
always end with an LF and we know some miss it. Thus, in cli_output_msg()
we now start by removing the trailing LFs from the string, and we always
add exactly one. This way the trailing LF added by correct functions are
silently ignored and all functions are now correct.

This would need to be progressively backported to all supported versions
in order to address them all at once, though the risk of breaking a legacy
script relying on the wrong output is never zero. At first it should at
least go as far as the lastest LTS (2.8), and maybe another one depending
on user demands. Note that it also requires previous patch ("BUG/MINOR:
vars/cli: fix missing LF after "get var" output") because it fixes a test
for a bogus output for "get var" in a VTC.

(cherry picked from commit 6219a58d285060b1eaa33c4c56f89a37a33230a4)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 13dc860e2a1f2cad9dba956a851beb84a5bba1fe)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 0239f32c3052a4e63e32c9a469ba572344d76c65)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit cc80d9d1ff81a53437510ea08216ce7a544a5e4f)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 7156740285745e73a52982b8b01ce8975f3fd633)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
1 file changed