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

Print password prompts to stderr

Hraban Luyat66e8c1600ec8
diff --git a/fs/config.go b/fs/config.go
index f3e684962..4caa69482 100644
--- a/fs/config.go
+++ b/fs/config.go
@@ -516,15 +516,15 @@ func checkPassword(password string) (string, error) {
// GetPassword asks the user for a password with the prompt given.
func GetPassword(prompt string) string {
- fmt.Println(prompt)
+ fmt.Fprintln(os.Stderr, prompt)
for {
- fmt.Print("password:")
+ fmt.Fprint(os.Stderr, "password:")
password := ReadPassword()
password, err := checkPassword(password)
if err == nil {
return password
}
- fmt.Printf("Bad password: %v\n", err)
+ fmt.Fprintf(os.Stderr, "Bad password: %v\n", err)
}
}
@@ -553,7 +553,7 @@ func getConfigPassword(q string) {
if err == nil {
return
}
- fmt.Println("Error:", err)
+ fmt.Fprintln(os.Stderr, "Error:", err)
}
}
diff --git a/fs/config_read_password.go b/fs/config_read_password.go
index 19c60cd98..08892cfb3 100644
--- a/fs/config_read_password.go
+++ b/fs/config_read_password.go
@@ -18,7 +18,7 @@ import (
// ReadPassword reads a password without echoing it to the terminal.
func ReadPassword() string {
line, err := terminal.ReadPassword(int(os.Stdin.Fd()))
- fmt.Println("")
+ fmt.Fprintln(os.Stderr)
if err != nil {
log.Fatalf("Failed to read password: %v", err)
}