1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-31 07:33:33 +00:00

log: update windows redirection code to use x/sys/windows and include dup

This modernises the Windows redirect code to use x/sys/windows and to
dup os.Stderr for use in the terminal.
This commit is contained in:
Nick Craig-Wood
2022-10-07 16:10:30 +01:00
parent 16b383e18f
commit 3450d049b5
2 changed files with 34 additions and 17 deletions

View File

@@ -81,8 +81,11 @@ func Start() {
// If output is not a tty then remove escape codes
Out = colorable.NewNonColorable(f)
} else if runtime.GOOS == "windows" && os.Getenv("TERM") != "" {
// If TERM is set just use stdout
Out = os.Stdout
// If TERM is set on Windows then we should just send output
// straight to the terminal for cygwin/git bash environments.
// We don't want to use NewColorable here because it will
// use Windows console calls which cygwin/git bash don't support.
Out = f
} else {
Out = colorable.NewColorable(f)
}