Skip to content

Fix "missing method Fd" crash on Windows#6200

Merged
mislav merged 4 commits intotrunkfrom
windows-stdout-crash
Sep 6, 2022
Merged

Fix "missing method Fd" crash on Windows#6200
mislav merged 4 commits intotrunkfrom
windows-stdout-crash

Conversation

@mislav
Copy link
Contributor

@mislav mislav commented Sep 5, 2022

This ensures that IOStreams.Out always keeps the original Fd() value even if it's wrapped as a Colorable stream for Windows in cases when enabling virtual terminal processing has failed.

Fixes #6147

This ensures that `IOStreams.Out` always keeps the original `Fd()` value even if it's wrapped as a Colorable stream for Windows in cases when enabling virtual terminal processing has failed.
@mislav mislav requested a review from a team as a code owner September 5, 2022 16:48
@mislav mislav requested review from vilmibm and removed request for a team September 5, 2022 16:48
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this 🙇

Comment on lines +284 to +285
var bodyWriter io.Writer = opts.IO.Out
var headersWriter io.Writer = opts.IO.Out
Copy link
Contributor

@samcoe samcoe Sep 6, 2022

Choose a reason for hiding this comment

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

Is this necessary because the Go compiler does not recognize that the fileWriter interface implements the io.Writer interface?

Copy link
Contributor Author

@mislav mislav Sep 6, 2022

Choose a reason for hiding this comment

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

No, it's because without an explicit type, bodyWriter would become the exact same type as IOStreams.Out, which is fileWriter. Then, later in this function I want to reassign bodyWriter to another Writer which doesn't necessarily have the Fd() method, which isn't needed anyway.

Basically, I'm just narrowing down the interface for the purpose of the rest of the code in this function.

}
return false
func isCygwinTerminal(fd uintptr) bool {
return isatty.IsCygwinTerminal(fd)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like that you made this and terminalSize simpler.

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.

gh failure in pwsh, git shell, cmd

2 participants