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)