From 768fe58f9488cd88af6c77ad880830b0c9da9dad Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20=C5=A0pa=C4=8Dek?= Date: Mon, 26 Oct 2020 18:38:29 +0100 Subject: [PATCH] tty: do not print extra newline after empty messages In case nothing (not even nil) is returned then do not print newline after the zero-length message. This avoids unambiguous empty line in output (is it an empty string which got printed?). --- daemon/io.c | 2 +- utils/client/kresc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/io.c b/daemon/io.c index 5d2c7727a..ff732c5de 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -704,7 +704,7 @@ void io_tty_process_input(uv_stream_t *stream, ssize_t nread, const uv_buf_t *bu FILE *fp_out = ret ? stderr : stdout; if (message) fprintf(fp_out, "%s", message); - if (message || !args->quiet) + if (message && !args->quiet) fprintf(fp_out, "\n"); fprintf(fp_out, "%s", delim); } diff --git a/utils/client/kresc.c b/utils/client/kresc.c index cbc63e5fe..5ca963835 100644 --- a/utils/client/kresc.c +++ b/utils/client/kresc.c @@ -421,7 +421,7 @@ static int interact() return 1; } printf("%s", msg); - if (msg_len == 0 || msg[msg_len - 1] != '\n') { + if (msg_len > 0 && msg[msg_len - 1] != '\n') { printf("\n"); } if (hist_file) { -- 2.47.2