Only add trailing carriage return to messages if output is a raw tty.

If output is being written to a terminal in "raw" mode, we need to
add a carriage return after the newline to avoid "stair-step" output.
However, we should not write the carriage return if the terminal
is in "cooked" mode, output to a pipe, or output redirected to a file.
Bug #1042.
This commit is contained in:
Todd C. Miller
2022-10-20 08:55:26 -06:00
parent d744271a63
commit 803998d2bd
5 changed files with 43 additions and 9 deletions

View File

@@ -239,7 +239,7 @@ warning(const char *errstr, const char *fmt, va_list ap)
fputs(": ", stderr);
fputs(errstr, stderr);
}
if (isatty(fileno(stderr)))
if (sudo_term_is_raw(fileno(stderr)))
putc('\r', stderr);
putc('\n', stderr);
}