Describe the bug
The init() function calls _ = lipgloss.HasDarkBackground(), which accesses the terminal and produces OSC/DSR sequences (e.g., ^[]11;rgb:0000/0000/0000^[\^[[78;1R) before main().
This output appears when the program is run via spawn in an expect script.
Setup
- OS: macOS
- Shell: bash
- Terminal Emulator: iTerm2
- Terminal Multiplexer: no
To Reproduce
- Write an expect script that uses
spawn to run a Bubble Tea program.
- Observe that terminal sequences are printed before main() executes.
Source Code
#!/usr/bin/env expect
spawn ./program
expect "Hello"
interact
package main
import (
"flag"
"fmt"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
useTea := flag.Bool("tea", false, "use Bubble Tea")
flag.Parse()
if *useTea {
tea.Println("Hello, Tea.")
return
}
fmt.Println("Hello, World.")
}
Expected behavior
The init() function should not produce unwanted terminal output when the program is run via spawn in an expect script.
Screenshots
$ ./expect.sh
spawn ./program
^[]11;rgb:0000/0000/0000^[\^[[78;1RHello, World.
^[]11;rgb:0000/0000/0000^[\^[[78;1R
Additional context
Consider performing terminal detection lazily, e.g., with sync.Once when it is actually needed in the program.
Describe the bug
The init() function calls
_ = lipgloss.HasDarkBackground(), which accesses the terminal and produces OSC/DSR sequences (e.g.,^[]11;rgb:0000/0000/0000^[\^[[78;1R) before main().This output appears when the program is run via
spawnin an expect script.Setup
To Reproduce
spawnto run a Bubble Tea program.Source Code
Expected behavior
The init() function should not produce unwanted terminal output when the program is run via spawn in an expect script.
Screenshots
Additional context
Consider performing terminal detection lazily, e.g., with sync.Once when it is actually needed in the program.