diff --git a/Source/cmStdIoTerminal.cxx b/Source/cmStdIoTerminal.cxx index 5baff5e38b..428f7c7fae 100644 --- a/Source/cmStdIoTerminal.cxx +++ b/Source/cmStdIoTerminal.cxx @@ -141,9 +141,13 @@ void Print(OStream& os, TermAttrSet const& attrs, f(os.IOS()); break; case TermKind::VT100: - SetVT100Attrs(os.IOS(), attrs); - f(os.IOS()); - SetVT100Attrs(os.IOS(), TermAttr::Normal); + if (!attrs.empty()) { + SetVT100Attrs(os.IOS(), attrs); + f(os.IOS()); + SetVT100Attrs(os.IOS(), TermAttr::Normal); + } else { + f(os.IOS()); + } break; #ifdef _WIN32 case TermKind::Console: { diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 9e38384abf..805bdab920 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1923,7 +1923,7 @@ int cmcmd::ExecuteEchoColor(std::vector const& args) bool enabled = true; static cm::StdIo::TermAttrSet const noAttrs; - cm::StdIo::TermAttrSet attrs = cm::StdIo::TermAttr::Normal; + cm::StdIo::TermAttrSet attrs; bool newline = true; std::string progressDir; for (auto const& arg : cmMakeRange(args).advance(2)) { @@ -1959,6 +1959,9 @@ int cmcmd::ExecuteEchoColor(std::vector const& args) } else if (arg == "--white") { attrs = cm::StdIo::TermAttr::ForegroundWhite; } else if (arg == "--bold") { + if (attrs.empty()) { + attrs = cm::StdIo::TermAttr::Normal; + } attrs |= cm::StdIo::TermAttr::ForegroundBold; } else if (arg == "--no-newline") { newline = false;