Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb5b228

Browse files
authored
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.
1 parent 0bf9dee commit cb5b228

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cli/cliui/prompt.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/bgentry/speakeasy"
1515
"github.com/mattn/go-isatty"
1616
"github.com/spf13/cobra"
17+
"golang.org/x/xerrors"
1718
)
1819

1920
// PromptOptions supply a set of options to the prompt.
@@ -48,7 +49,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
4849
if opts.Secret && valid && isatty.IsTerminal(inFile.Fd()) {
4950
line, err = speakeasy.Ask("")
5051
} else {
51-
if runtime.GOOS == "darwin" && valid {
52+
if !opts.IsConfirm && runtime.GOOS == "darwin" && valid {
5253
var restore func()
5354
restore, err = removeLineLengthLimit(int(inFile.Fd()))
5455
if err != nil {
@@ -99,7 +100,7 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
99100
return "", err
100101
case line := <-lineCh:
101102
if opts.IsConfirm && line != "yes" && line != "y" {
102-
return line, Canceled
103+
return line, xerrors.Errorf("got %q: %w", line, Canceled)
103104
}
104105
if opts.Validate != nil {
105106
err := opts.Validate(line)

0 commit comments

Comments
 (0)