Fix broken output when asking question and stdin is piped (FS#27909)
When asking question and stdin is piped, the response does not get printed out,
resulting in a missing
and broken output (FS#27909); printing the response
fixes it.
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 2d88bac..876a15b 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1429,6 +1429,13 @@ static int question(short preset, char *fmt, va_list args)
if(len == 0) {
return preset;
}
+
+ /* if stdin is piped, response does not get printed out, and as a result
+ * a
is missing, resulting in broken output (FS#27909) */
+ struct stat sb;
+ if (fstat(STDIN_FILENO, &sb) == 0 && S_ISFIFO(sb.st_mode)) {
+ fprintf(stream, "%s
", response);
+ }