mirror of
https://github.com/NixOS/nix.git
synced 2025-11-21 09:49:36 +01:00
Fix resetting the terminal with '-L'
Using '-L' caused another call to setLogFormat(), which caused another ProgressBar to be created. But the ProgressBar should be a singleton. To do: remove LogFormat::barWithLogs. '-L' should be a setting of the ProgressBar, not a different log format.
This commit is contained in:
parent
29ada5105b
commit
99bb7aaf80
2 changed files with 13 additions and 12 deletions
|
|
@ -143,7 +143,7 @@ private:
|
|||
bool helpShown = false;
|
||||
};
|
||||
|
||||
bool isTTY;
|
||||
const bool isTTY;
|
||||
|
||||
Sync<State> state_;
|
||||
|
||||
|
|
@ -173,14 +173,9 @@ public:
|
|||
draw(*state);
|
||||
state.wait_for(quitCV, std::chrono::milliseconds(50));
|
||||
}
|
||||
|
||||
if (savedTermAttrs) {
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &*savedTermAttrs);
|
||||
savedTermAttrs.reset();
|
||||
}
|
||||
});
|
||||
|
||||
if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO) && isatty(STDERR_FILENO)) {
|
||||
if (isTTY) {
|
||||
|
||||
struct termios term;
|
||||
if (tcgetattr(STDIN_FILENO, &term))
|
||||
|
|
@ -291,6 +286,11 @@ public:
|
|||
state->active = false;
|
||||
updateCV.notify_one();
|
||||
quitCV.notify_one();
|
||||
|
||||
if (savedTermAttrs) {
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &*savedTermAttrs);
|
||||
savedTermAttrs.reset();
|
||||
}
|
||||
}
|
||||
|
||||
updateThread.join();
|
||||
|
|
|
|||
|
|
@ -88,11 +88,12 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
|
|||
}},
|
||||
});
|
||||
|
||||
// FIXME: make this a setting, remove LogFormat::barWithLogs.
|
||||
addFlag({
|
||||
.longName = "print-build-logs",
|
||||
.shortName = 'L',
|
||||
.description = "print full build logs on stderr",
|
||||
.handler = {[&]() {setLogFormat(LogFormat::barWithLogs); }},
|
||||
.handler = {[&]() { printBuildLogs = true; }},
|
||||
});
|
||||
|
||||
addFlag({
|
||||
|
|
@ -254,10 +255,6 @@ void mainWrapped(int argc, char * * argv)
|
|||
settings.verboseBuild = false;
|
||||
evalSettings.pureEval = true;
|
||||
|
||||
setLogFormat("bar");
|
||||
|
||||
Finally f([] { logger->stop(); });
|
||||
|
||||
NixArgs args;
|
||||
|
||||
if (argc == 2 && std::string(argv[1]) == "__dump-args") {
|
||||
|
|
@ -301,6 +298,10 @@ void mainWrapped(int argc, char * * argv)
|
|||
|
||||
if (completions) return;
|
||||
|
||||
setLogFormat(args.printBuildLogs ? LogFormat::bar : LogFormat::barWithLogs);
|
||||
|
||||
Finally f([] { logger->stop(); });
|
||||
|
||||
initPlugins();
|
||||
|
||||
if (!args.command) args.showHelpAndExit();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue