From 8f1ca8fabedf369251bbb60d7feaf96409e1e4f9 Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Sat, 27 May 2023 08:52:37 +0200 Subject: [PATCH] cmd: Don't check for errno == 0 Maybe term.Restore's predecessor could return this, but the current implementation never does. --- cmd/restic/global.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/cmd/restic/global.go b/cmd/restic/global.go index 93cd4afc3..adff1141a 100644 --- a/cmd/restic/global.go +++ b/cmd/restic/global.go @@ -10,7 +10,6 @@ import ( "runtime" "strconv" "strings" - "syscall" "time" "github.com/restic/restic/internal/backend" @@ -146,21 +145,6 @@ func init() { restoreTerminal() } -// checkErrno returns nil when err is set to syscall.Errno(0), since this is no -// error condition. -func checkErrno(err error) error { - e, ok := err.(syscall.Errno) - if !ok { - return err - } - - if e == 0 { - return nil - } - - return err -} - func stdinIsTerminal() bool { return term.IsTerminal(int(os.Stdin.Fd())) } @@ -209,7 +193,7 @@ func restoreTerminal() { if !isReadingPassword { return code, nil } - err := checkErrno(term.Restore(fd, state)) + err := term.Restore(fd, state) if err != nil { fmt.Fprintf(os.Stderr, "unable to restore terminal state: %v\n", err) }