Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

config: fix error reading password from piped input - fixes #1308

Nick Craig-Wood947e10eb2bb3
diff --git a/fs/config/config_read_password.go b/fs/config/config_read_password.go
index 26f4d11ac..9baf3793a 100644
--- a/fs/config/config_read_password.go
+++ b/fs/config/config_read_password.go
@@ -16,7 +16,11 @@ import (
// ReadPassword reads a password without echoing it to the terminal.
func ReadPassword() string {
- line, err := terminal.ReadPassword(int(os.Stdin.Fd()))
+ stdin := int(os.Stdin.Fd())
+ if !terminal.IsTerminal(stdin) {
+ return ReadLine()
+ }
+ line, err := terminal.ReadPassword(stdin)
_, _ = fmt.Fprintln(os.Stderr)
if err != nil {
log.Fatalf("Failed to read password: %v", err)