Skip to content

Commit b928e3f

Browse files
authored
fix: performance warning should not output ANSI codes if stderr redirected (apple#1059)
1 parent 744e7f7 commit b928e3f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎Sources/ContainerCommands/Application.swift‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ public struct Application: AsyncParsableCommand {
9191

9292
#if DEBUG
9393
let warning = "Running debug build. Performance may be degraded."
94-
let formattedWarning = "\u{001B}[33mWarning!\u{001B}[0m \(warning)\n"
94+
let formattedWarning: String
95+
if isatty(FileHandle.standardError.fileDescriptor) == 1 {
96+
formattedWarning = "\u{001B}[33mWarning!\u{001B}[0m \(warning)\n"
97+
} else {
98+
formattedWarning = "Warning! \(warning)\n"
99+
}
95100
let warningData = Data(formattedWarning.utf8)
96101
FileHandle.standardError.write(warningData)
97102
#endif

0 commit comments

Comments
 (0)