From c4de80035d4164d86ec5f15a7568598993b504b6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 29 Sep 2024 12:14:19 +0000 Subject: Show prompt reply if input is from non-terminal In the unlikely case input is not a terminal (but not in some way assumed with command line flags) we should print the string we act on after the prompt so that people can see what is happening rather than having the prompt "mysteriously" hidden on terminals or prepended to the first line of the download progress in logs. --- apt-private/private-output.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index 0c56026a5..3d234727f 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -861,9 +861,10 @@ bool YnPrompt(char const * const Question, bool const Default, bool const ShowGl char response[1024] = ""; std::cin.getline(response, sizeof(response)); - if (!std::cin) return false; + if (isatty(STDIN_FILENO) == 0) + c1o << response << '\n'; if (strlen(response) == 0) return Default; -- cgit v1.2.3-70-g09d2