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

s3-about
Nick Craig-Wood 2018-06-28 11:54:15 +01:00
parent 6b42421374
commit 947e10eb2b
1 changed files with 5 additions and 1 deletions

View File

@ -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)