summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2024-09-29 12:14:19 +0000
committerDavid Kalnischkies <david@kalnischkies.de>2024-09-29 12:14:19 +0000
commitc4de80035d4164d86ec5f15a7568598993b504b6 (patch)
treed06471262a0e7713e21645aa4457b357ac8cf923
parenta44bd300f006b74c09a74aff419b43912e114e0c (diff)
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.
-rw-r--r--apt-private/private-output.cc3
1 files changed, 2 insertions, 1 deletions
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;