1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 10:11:47 +02:00

ProgressBar::ask: Accept EOF as a no

This may occur when stderr is a tty but stdin is empty.
E.g.

    $ nix build </dev/null
    error: unexpected EOF reading a line

These stdio handles are how some non-interactive sandboxes behave,
including the Nix build sandbox and Hercules CI Effects.
This commit is contained in:
Robert Hensing 2024-11-06 15:05:32 +01:00
parent f7b1e535a3
commit 3112e59734
3 changed files with 12 additions and 1 deletions

View file

@ -543,7 +543,7 @@ public:
auto state(state_.lock());
if (!state->active) return {};
std::cerr << fmt("\r\e[K%s ", msg);
auto s = trim(readLine(STDIN_FILENO));
auto s = trim(readLine(STDIN_FILENO, true));
if (s.size() != 1) return {};
draw(*state);
return s[0];