From b48f579530be5de1de08773a9ba27d241fcc9c1f Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 6 Dec 2020 16:56:00 +0100 Subject: [PATCH] termstatus: Fix canUpdateStatus detection for redirected output The canUpdateStatus check was simplified in #2608, but it accidentally flipped the condition. The correct check is as follows: If the output is a pipe then restic probably runs in mintty/cygwin. In that case it's possible to update the output status. In all other cases it isn't. This commit inverts to condition again to offer the previous and correct behavior. --- changelog/unreleased/issue-3111 | 9 +++++++++ internal/ui/termstatus/terminal_windows.go | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/issue-3111 diff --git a/changelog/unreleased/issue-3111 b/changelog/unreleased/issue-3111 new file mode 100644 index 000000000..8eeabae36 --- /dev/null +++ b/changelog/unreleased/issue-3111 @@ -0,0 +1,9 @@ +Bugfix: Correctly detect output redirection for `backup` command on Windows + +On Windows, since restic 0.10.0 the `backup` command did not properly detect +when the output was redirected to a file. This caused restic to output +terminal control characters. This has been fixed by correcting the terminal +detection. + +https://github.com/restic/restic/issues/3111 +https://github.com/restic/restic/pull/3150 diff --git a/internal/ui/termstatus/terminal_windows.go b/internal/ui/termstatus/terminal_windows.go index 3788c1451..723aebdff 100644 --- a/internal/ui/termstatus/terminal_windows.go +++ b/internal/ui/termstatus/terminal_windows.go @@ -88,8 +88,8 @@ func canUpdateStatus(fd uintptr) bool { return true } - // check if the output file type is a pipe (0x0003) - if isPipe(fd) { + // check that the output file type is a pipe (0x0003) + if !isPipe(fd) { return false }