~emersion/soju

c994ce70926fd3be515947eb0b8e3a9485870050 — Simon Ser 6 months ago 0d6d297
sojuctl: don't use log.Fatalf in readPassword
1 files changed, 4 insertions(+), 2 deletions(-)

M cmd/sojuctl/main.go
M cmd/sojuctl/main.go => cmd/sojuctl/main.go +4 -2
@@ 4,6 4,7 @@ import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"log"
	"os"



@@ 125,12 126,13 @@ func readPassword() ([]byte, error) {
		fmt.Printf("\n")
	} else {
		fmt.Fprintf(os.Stderr, "Warning: Reading password from stdin.\n")
		// TODO: the buffering messes up repeated calls to readPassword
		scanner := bufio.NewScanner(os.Stdin)
		if !scanner.Scan() {
			if err := scanner.Err(); err != nil {
				log.Fatalf("failed to read password from stdin: %v", err)
				return nil, err
			}
			log.Fatalf("failed to read password from stdin: stdin is empty")
			return nil, io.ErrUnexpectedEOF
		}
		password = scanner.Bytes()