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:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user