Skip to content

Apparent hang in HasDarkBackground when no TTY available #635

@jedevc

Description

@jedevc

Describe the bug

Importing charm.land/lipgloss/v2/compat causes the program to hang when stdin is a pipe (e.g., source <(./program)).

Maybe related to #73?

package main
import (
	"fmt"
	_ "charm.land/lipgloss/v2/compat"
)
func main() {
	fmt.Println("hello")
}
go build -o repro .
./repro              # Works
source <(./repro)    # Hangs

Setup
Please complete the following information along with version numbers, if applicable.

  • OS: Linux
  • Shell: zsh
  • Terminal Emulator: gnome-terminal
  • Terminal Multiplexer: none
  • Locale: en_GB.UTF-8

Expected behavior
It not to hang.

I think this is related to HasDarkBackground. If I change the line:

	HasDarkBackground = lipgloss.HasDarkBackground(os.Stdin, os.Stdout)

to

	HasDarkBackground = true

Then the hang no longer occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions