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 helpShown = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool isTTY;
|
const bool isTTY;
|
||||||
|
|
||||||
Sync<State> state_;
|
Sync<State> state_;
|
||||||
|
|
||||||
|
|
@ -173,14 +173,9 @@ public:
|
||||||
draw(*state);
|
draw(*state);
|
||||||
state.wait_for(quitCV, std::chrono::milliseconds(50));
|
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;
|
struct termios term;
|
||||||
if (tcgetattr(STDIN_FILENO, &term))
|
if (tcgetattr(STDIN_FILENO, &term))
|
||||||
|
|
@ -291,6 +286,11 @@ public:
|
||||||
state->active = false;
|
state->active = false;
|
||||||
updateCV.notify_one();
|
updateCV.notify_one();
|
||||||
quitCV.notify_one();
|
quitCV.notify_one();
|
||||||
|
|
||||||
|
if (savedTermAttrs) {
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &*savedTermAttrs);
|
||||||
|
savedTermAttrs.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateThread.join();
|
updateThread.join();
|
||||||
|
|
|
||||||
|
|
@ -88,11 +88,12 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
|
||||||
}},
|
}},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// FIXME: make this a setting, remove LogFormat::barWithLogs.
|
||||||
addFlag({
|
addFlag({
|
||||||
.longName = "print-build-logs",
|
.longName = "print-build-logs",
|
||||||
.shortName = 'L',
|
.shortName = 'L',
|
||||||
.description = "print full build logs on stderr",
|
.description = "print full build logs on stderr",
|
||||||
.handler = {[&]() {setLogFormat(LogFormat::barWithLogs); }},
|
.handler = {[&]() { printBuildLogs = true; }},
|
||||||
});
|
});
|
||||||
|
|
||||||
addFlag({
|
addFlag({
|
||||||
|
|
@ -254,10 +255,6 @@ void mainWrapped(int argc, char * * argv)
|
||||||
settings.verboseBuild = false;
|
settings.verboseBuild = false;
|
||||||
evalSettings.pureEval = true;
|
evalSettings.pureEval = true;
|
||||||
|
|
||||||
setLogFormat("bar");
|
|
||||||
|
|
||||||
Finally f([] { logger->stop(); });
|
|
||||||
|
|
||||||
NixArgs args;
|
NixArgs args;
|
||||||
|
|
||||||
if (argc == 2 && std::string(argv[1]) == "__dump-args") {
|
if (argc == 2 && std::string(argv[1]) == "__dump-args") {
|
||||||
|
|
@ -301,6 +298,10 @@ void mainWrapped(int argc, char * * argv)
|
||||||
|
|
||||||
if (completions) return;
|
if (completions) return;
|
||||||
|
|
||||||
|
setLogFormat(args.printBuildLogs ? LogFormat::bar : LogFormat::barWithLogs);
|
||||||
|
|
||||||
|
Finally f([] { logger->stop(); });
|
||||||
|
|
||||||
initPlugins();
|
initPlugins();
|
||||||
|
|
||||||
if (!args.command) args.showHelpAndExit();
|
if (!args.command) args.showHelpAndExit();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue