From ca25f1fd201efe1441f19f8343aa7fe37c2c1ffc Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 5 May 2022 17:59:25 +0800 Subject: [PATCH] [ELF] Redefine --color-diagnostics as an alias for --color-diagnostics=auto It was accidentally mapped to --color-diagnostics=always, but it was a bug. For the sake of compatibility with other tools such as clang or lld, it should be defined as an alias for `auto`. --- elf/cmdline.cc | 5 ++--- test/elf/color-diagnostics.sh | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/elf/cmdline.cc b/elf/cmdline.cc index f22c2f62..37dd39c7 100644 --- a/elf/cmdline.cc +++ b/elf/cmdline.cc @@ -618,14 +618,13 @@ std::vector parse_nonpositional_args(Context &ctx) { ctx.arg.directory = arg; } else if (read_arg("chroot")) { ctx.arg.chroot = arg; - } else if (read_flag("color-diagnostics=auto")) { + } else if (read_flag("color-diagnostics") || + read_flag("color-diagnostics=auto")) { ctx.arg.color_diagnostics = isatty(STDERR_FILENO); } else if (read_flag("color-diagnostics=always")) { ctx.arg.color_diagnostics = true; } else if (read_flag("color-diagnostics=never")) { ctx.arg.color_diagnostics = false; - } else if (read_flag("color-diagnostics")) { - ctx.arg.color_diagnostics = true; } else if (read_flag("warn-common")) { ctx.arg.warn_common = true; } else if (read_flag("no-warn-common")) { diff --git a/test/elf/color-diagnostics.sh b/test/elf/color-diagnostics.sh index 04fff238..35d4bf31 100755 --- a/test/elf/color-diagnostics.sh +++ b/test/elf/color-diagnostics.sh @@ -20,7 +20,7 @@ int main() { foo(); } EOF ! "$mold" -o $t/exe $t/a.o --color-diagnostics 2> $t/log -grep -q $'\033' $t/log +! grep -q $'\033' $t/log || false ! "$mold" -o $t/exe $t/a.o --color-diagnostics=always 2> $t/log grep -q $'\033' $t/log