From 1eaa71b83bbcbced6cfb94e6a480d294f3943f25 Mon Sep 17 00:00:00 2001 From: Tim van der Molen Date: Sun, 28 Jul 2024 17:16:34 +0200 Subject: [PATCH] Optionally read the password from stdin --- main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index b378bb7..f71ca2a 100644 --- a/main.go +++ b/main.go @@ -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 {