From: Petr Špaček Date: Mon, 26 Oct 2020 17:38:29 +0000 (+0100) Subject: tty: do not print extra newline after empty messages X-Git-Tag: v5.2.0~4^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=768fe58f9488cd88af6c77ad880830b0c9da9dad;p=thirdparty%2Fknot-resolver.git 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?). --- 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) {