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

registry login: suppress bug report message on EOF #754

Merged
merged 2 commits into from
Dec 6, 2021

Conversation

lrewega
Copy link
Member

@lrewega lrewega commented Dec 2, 2021

A user entering EOF (^D) when prompted does not warrant filing a bug
report.

A user entering EOF (^D) when prompted does not warrant filing a bug
report.
return "", NewInternalError(err)
}
value = string(data)
} else {
scanner := bufio.NewScanner(container.Stdin())
if !scanner.Scan() {
return "", NewInternalError(scanner.Err())
// scanner.Err() returns nil on EOF.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it only return nil on io.EOF?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question!

Yes, I believe nil is only possible on io.EOF or if the scanner's split func returns bufio.ErrFinalToken, which the default split func (bufio.ScanLines, which we're using here) never returns.

From https://pkg.go.dev/bufio#Scanner.Scan

After Scan returns false, the Err method will return any error that occurred during scanning, except that if it was io.EOF, Err will return nil.

@@ -684,13 +685,20 @@ func promptUser(container app.Container, prompt string, isPassword bool) (string
if isPassword {
data, err := term.ReadPassword(int(file.Fd()))
if err != nil {
if errors.Is(err, io.EOF) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment as to why would be helpful

@lrewega lrewega requested a review from bufdev December 6, 2021 18:54
@lrewega lrewega merged commit 8599fe1 into main Dec 6, 2021
@lrewega lrewega deleted the lrewega/registry-login-eof branch December 6, 2021 23:11
Monirul1 pushed a commit to Monirul1/buf that referenced this pull request Apr 30, 2023
A user entering EOF (^D) when prompted does not warrant filing a bug
report.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants