diff --git a/cmd/restic/global.go b/cmd/restic/global.go index 217d6f732..a60486426 100644 --- a/cmd/restic/global.go +++ b/cmd/restic/global.go @@ -132,6 +132,20 @@ func restoreTerminal() { }) } +// shouldOutputPasswordSuccessful returns true if the password is supplied +// interactively and the stdout is a terminal. +func shouldOutputPasswordSuccessful() bool { + if globalOptions.PasswordFile != "" { + return false + } + + if os.Getenv("RESTIC_PASSWORD") != "" { + return false + } + + return stdoutIsTerminal() +} + // ClearLine creates a platform dependent string to clear the current // line, so it can be overwritten. ANSI sequences are not supported on // current windows cmd shell. @@ -326,6 +340,10 @@ func OpenRepository(opts GlobalOptions) (*repository.Repository, error) { return nil, err } + if shouldOutputPasswordSuccessful() { + Verbosef("password is correct\n") + } + if opts.NoCache { return s, nil }