1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-15 05:21:03 +01:00

Merge pull request #14587 from NixOS/fix-mingw

treewide: Fix MinGW build
This commit is contained in:
John Ericson 2025-11-18 02:17:38 +00:00 committed by GitHub
commit 16f0279d4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 44 additions and 25 deletions

View file

@ -4,7 +4,15 @@
#include <limits>
#include <string>
#include "nix/util/file-descriptor.hh"
namespace nix {
/**
* Determine whether \param fd is a terminal.
*/
bool isTTY(Descriptor fd);
/**
* Determine whether ANSI escape sequences are appropriate for the
* present output.

View file

@ -64,6 +64,16 @@ inline std::pair<int, size_t> charWidthUTF8Helper(std::string_view s)
namespace nix {
bool isTTY(Descriptor fd)
{
#ifndef _WIN32
return isatty(fd);
#else
DWORD mode;
return GetConsoleMode(fd, &mode);
#endif
}
bool isTTY()
{
static const bool tty = isatty(STDERR_FILENO) && getEnv("TERM").value_or("dumb") != "dumb"