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