src: add support for NO_COLOR environment variable

This commit is contained in:
Markus F.X.J. Oberhumer 2023-08-31 12:31:31 +02:00
parent cfa8107ab9
commit d54315392e
2 changed files with 7 additions and 1 deletions

1
NEWS
View File

@ -4,6 +4,7 @@ User visible changes for UPX
Changes in 4.2.0 (XX XXX 2023):
* bug fixes - see https://github.com/upx/upx/milestone/13
* add support for NO_COLOR env var; see https://no-color.org/
Changes in 4.1.0 (08 Aug 2023):
* ELF: handle shared libraries with more than 2 PT_LOAD segments

View File

@ -53,6 +53,7 @@ void Options::reset() noexcept {
o->preserve_mode = true;
o->preserve_ownership = true;
o->preserve_timestamp = true;
o->verbose = 2;
o->console = CON_FILE;
#if (ACC_OS_DOS32) && defined(__DJGPP__)
@ -62,7 +63,11 @@ void Options::reset() noexcept {
#elif 1 && defined(__linux__)
o->console = CON_INIT;
#endif
o->verbose = 2;
// support NO_COLOR, see https://no-color.org/
// "... when present and not an empty string (regardless of its value)"
const char *e = getenv("NO_COLOR");
if (e && e[0])
o->console = CON_FILE;
o->o_unix.osabi0 = 3; // 3 == ELFOSABI_LINUX