Changeset 503 in code for trunk/cmd/sojuctl


Ignore:
Timestamp:
Apr 19, 2021, 12:11:25 PM (4 years ago)
Author:
contact
Message:

sojuctl: don't use log.Fatalf in readPassword

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cmd/sojuctl/main.go

    r432 r503  
    55        "flag"
    66        "fmt"
     7        "io"
    78        "log"
    89        "os"
     
    126127        } else {
    127128                fmt.Fprintf(os.Stderr, "Warning: Reading password from stdin.\n")
     129                // TODO: the buffering messes up repeated calls to readPassword
    128130                scanner := bufio.NewScanner(os.Stdin)
    129131                if !scanner.Scan() {
    130132                        if err := scanner.Err(); err != nil {
    131                                 log.Fatalf("failed to read password from stdin: %v", err)
     133                                return nil, err
    132134                        }
    133                         log.Fatalf("failed to read password from stdin: stdin is empty")
     135                        return nil, io.ErrUnexpectedEOF
    134136                }
    135137                password = scanner.Bytes()
Note: See TracChangeset for help on using the changeset viewer.