Skip to content

Commit

Permalink
Optionally read the password from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim van der Molen committed Jul 28, 2024
1 parent ee214bb commit 1eaa71b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ func passwordFromFile(passfile getopt.Arg) ([]byte, error) {
return nil, nil
}

f, err := os.Open(passfile.String())
if err != nil {
return nil, err
f := os.Stdin
if passfile.String() != "-" {
var err error
if f, err = os.Open(passfile.String()); err != nil {
return nil, err
}
defer f.Close()
}
defer f.Close()

s := bufio.NewScanner(f)
if s.Scan() == false {
Expand Down

0 comments on commit 1eaa71b

Please sign in to comment.