From cb5b228a21cc96370d9b283df7873594d37a1f34 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 8 Apr 2022 11:25:19 -0500 Subject: [PATCH] fix: Disable raw using confirm prompt on Darwin (#926) This caused cancel errors on prompt, but would have caused incorrect content in parameter values if it surfaced. Fixes #915. --- cli/cliui/prompt.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/cliui/prompt.go b/cli/cliui/prompt.go index 82aa2a07cb..9d78e25626 100644 --- a/cli/cliui/prompt.go +++ b/cli/cliui/prompt.go @@ -14,6 +14,7 @@ import ( "github.com/bgentry/speakeasy" "github.com/mattn/go-isatty" "github.com/spf13/cobra" + "golang.org/x/xerrors" ) // PromptOptions supply a set of options to the prompt. @@ -48,7 +49,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) { if opts.Secret && valid && isatty.IsTerminal(inFile.Fd()) { line, err = speakeasy.Ask("") } else { - if runtime.GOOS == "darwin" && valid { + if !opts.IsConfirm && runtime.GOOS == "darwin" && valid { var restore func() restore, err = removeLineLengthLimit(int(inFile.Fd())) if err != nil { @@ -99,7 +100,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) { return "", err case line := <-lineCh: if opts.IsConfirm && line != "yes" && line != "y" { - return line, Canceled + return line, xerrors.Errorf("got %q: %w", line, Canceled) } if opts.Validate != nil { err := opts.Validate(line)