forked from TrueCloudLab/rclone
config: fix error reading password from piped input - fixes #1308
This commit is contained in:
parent
6b42421374
commit
947e10eb2b
1 changed files with 5 additions and 1 deletions
|
@ -16,7 +16,11 @@ import (
|
||||||
|
|
||||||
// ReadPassword reads a password without echoing it to the terminal.
|
// ReadPassword reads a password without echoing it to the terminal.
|
||||||
func ReadPassword() string {
|
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)
|
_, _ = fmt.Fprintln(os.Stderr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to read password: %v", err)
|
log.Fatalf("Failed to read password: %v", err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue