Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]Strange bug when using fmt.Scanln after upgrade to v0.2.6 #252

Open
bin3377 opened this issue Mar 1, 2022 · 1 comment
Open

[Bug]Strange bug when using fmt.Scanln after upgrade to v0.2.6 #252

bin3377 opened this issue Mar 1, 2022 · 1 comment
Labels

Comments

@bin3377
Copy link

bin3377 commented Mar 1, 2022

Bug reports

A very strange bug. After upgrade to v0.2.6, seems using go-prompt in code will change some status of my shell (I'm using zsh on MacOSX) and breaking the function of fmt.Scanln() after that. The symptom is "Return" key will be recognized as "^M" so it will block on the input.

The code to repro:

var pr *prompt.Prompt

func main() {
	user := ""
	fmt.Printf("user: ")
	fmt.Scanln(&user)
	fmt.Printf("got %s\n", user)
	pr = prompt.New(
		func(_ string) {
			os.Exit(0)
		},
		func(d prompt.Document) []prompt.Suggest {
			return nil
		},
	)
	pr.Run()
}

And in the shell, 1st time it works as expected:

$ go run ./main.go
user: test
got test
>

But run it again, the input following user: will be broken:

$ go run ./main.go
user: test^M^M^M^M^M

go version go1.16.2 darwin/amd64

Downgrade to v0.2.5 and it works as expected

Expected Behavior

Should always run as the 1st time

Current Behavior and Steps to Reproduce

What is the current behavior? Please provide detailed steps for reproducing the issue.
A picture or gif animation tells a thousand words

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Operating System: Mac OSX 10.15.7
  • Terminal Emulator: (i.e. iTerm2) iTerm2/zsh
  • tag of go-prompt or commit revision: v0.2.6
@bin3377 bin3377 added the bug label Mar 1, 2022
@jsun-m
Copy link

jsun-m commented Mar 23, 2023

any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants