commit fac95f737d3c967a1b49c95882174f65f6bd1b34
parent d7a7c7730603fb1efc323f500ff19da7c4df5f11
Author: Sean Enck <sean@ttypty.com>
Date: Wed, 6 Oct 2021 18:12:20 -0400
fixing up the confirm path because it really doesn't need to be re-used
Diffstat:
3 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/internal/encdec.go b/internal/encdec.go
@@ -90,7 +90,7 @@ func getKey(keyMode, name string) ([]byte, error) {
go func() {
defer stdin.Close()
termEcho(false)
- input, err := readPassword()
+ input, err := Stdin(true)
if err != nil {
stdinErr = err
return
diff --git a/internal/socket.go b/internal/socket.go
@@ -146,7 +146,9 @@ func SocketHandler(isHost bool) error {
return err
}
if data == respCommand {
- input, err := readPassword()
+ termEcho(false)
+ input, err := Stdin(true)
+ termEcho(true)
if err != nil {
return err
}
diff --git a/internal/utils.go b/internal/utils.go
@@ -102,30 +102,17 @@ func termEcho(on bool) {
}
}
-func readPassword() (string, error) {
- return readInput(true)
-}
-
// ConfirmInput will get 2 inputs and confirm they are the same.
func ConfirmInput() (string, error) {
- return readInput(false)
-}
-
-func readInput(onlyOne bool) (string, error) {
- if !onlyOne {
- termEcho(false)
- defer func() {
- termEcho(true)
- }()
- fmt.Printf("please enter password: ")
- }
+ termEcho(false)
+ defer func() {
+ termEcho(true)
+ }()
+ fmt.Printf("please enter password: ")
first, err := Stdin(true)
if err != nil {
return "", err
}
- if onlyOne {
- return first, nil
- }
fmt.Printf("\nplease re-enter password: ")
second, err := Stdin(true)
if err != nil {