Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6 from serpent-os/no-color-if-no-tty
Browse files Browse the repository at this point in the history
Don't color output if stdin is no TTY
  • Loading branch information
ermo authored Apr 11, 2023
2 parents 54c98b6 + d82087a commit c423724
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions container/container/container/container/source/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import core.stdc.stdlib : _Exit;
import core.sys.linux.sched;
import core.sys.posix.sys.stat : umask;
import core.sys.posix.sys.wait;
import core.sys.posix.unistd : fork, geteuid;
import core.sys.posix.unistd : fork, geteuid, isatty;
import moss.container;
import moss.container.context;
import moss.core.mounts;
Expand Down Expand Up @@ -94,7 +94,14 @@ public struct ContainerCLI
@CommandEntry() int run(ref string[] args)
{
/// FIXME: make configurable (-d is currently used for destination)
configureLogger(ColorLoggerFlags.Color | ColorLoggerFlags.Timestamps);
if (isatty(0) && isatty(1))
{
configureLogger(ColorLoggerFlags.Color | ColorLoggerFlags.Timestamps);
}
else
{
configureLogger(ColorLoggerFlags.Timestamps);
}
globalLogLevel = LogLevel.trace;

umask(octal!22);
Expand Down

0 comments on commit c423724

Please sign in to comment.