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

fix(query): windows: explicitly open CONIN/CONOUT when I/O is not a t… #444

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,24 @@
// This function is intended for standalone Lip Gloss use only. If you're using
// Bubble Tea, listen for tea.BackgroundColorMsg in your update function.
func BackgroundColor(in *os.File, out *os.File) (bg color.Color, err error) {
if runtime.GOOS == "windows" {

Check failure on line 35 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

`if runtime.GOOS == "windows"` has complex nested blocks (complexity: 6) (nestif)

Check failure on line 35 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

`if runtime.GOOS == "windows"` has complex nested blocks (complexity: 6) (nestif)

Check failure on line 35 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

`if runtime.GOOS == "windows"` has complex nested blocks (complexity: 6) (nestif)

Check failure on line 35 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

`if runtime.GOOS == "windows"` has complex nested blocks (complexity: 6) (nestif)

Check failure on line 35 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

`if runtime.GOOS == "windows"` has complex nested blocks (complexity: 6) (nestif)

Check failure on line 35 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

`if runtime.GOOS == "windows"` has complex nested blocks (complexity: 6) (nestif)
// On Windows, when the input/output is redirected or piped, we need to
// open the console explicitly.
// See https://learn.microsoft.com/en-us/windows/console/getstdhandle#remarks
if !term.IsTerminal(in.Fd()) {
f, err := os.OpenFile("CONIN$", os.O_RDWR, 0o644)

Check failure on line 40 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

Magic number: 0o644, in <argument> detected (mnd)

Check failure on line 40 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

Magic number: 0o644, in <argument> detected (mnd)

Check failure on line 40 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

Magic number: 0o644, in <argument> detected (mnd)

Check failure on line 40 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

Magic number: 0o644, in <argument> detected (mnd)

Check failure on line 40 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

Magic number: 0o644, in <argument> detected (mnd)

Check failure on line 40 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

Magic number: 0o644, in <argument> detected (mnd)
if err != nil {
return nil, fmt.Errorf("error opening CONIN$: %w", err)
}
in = f
}
if !term.IsTerminal(out.Fd()) {
f, err := os.OpenFile("CONOUT$", os.O_RDWR, 0o644)

Check failure on line 47 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

Magic number: 0o644, in <argument> detected (mnd)

Check failure on line 47 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

Magic number: 0o644, in <argument> detected (mnd)

Check failure on line 47 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

Magic number: 0o644, in <argument> detected (mnd)

Check failure on line 47 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

Magic number: 0o644, in <argument> detected (mnd)

Check failure on line 47 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

Magic number: 0o644, in <argument> detected (mnd)

Check failure on line 47 in query.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

Magic number: 0o644, in <argument> detected (mnd)
if err != nil {
return nil, fmt.Errorf("error opening CONOUT$: %w", err)
}
out = f
}
return backgroundColor(in, out)
}

Expand Down
Loading