]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
tty: do not print extra newline after empty messages
authorPetr Špaček <petr.spacek@nic.cz>
Mon, 26 Oct 2020 17:38:29 +0000 (18:38 +0100)
committerPetr Špaček <petr.spacek@nic.cz>
Mon, 2 Nov 2020 09:28:55 +0000 (10:28 +0100)
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
utils/client/kresc.c

index 5d2c7727acc778c9251e928e3e9ac2d905840b53..ff732c5de38bb6bd5289ba8b77adac02a24edb7a 100644 (file)
@@ -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);
                }
index cbc63e5fe647eeacc18a72e1324d3dc3b0af1d61..5ca9638354ce4b27d15d7b2dd08f2b949f8936f6 100644 (file)
@@ -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) {