Skip to content
Myr

fix: check if os.Stdin is a terminal before opening the TTY

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This change checks if os.Stdin is a terminal before attempting to open the TTY for input. If os.Stdin is not a terminal, it will proceed to open the TTY as before.

authored by Ayman Bagabas · committed by GitHub · parent 110a919 · Browse files · 1 file+7 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Fixes: #1595

Diff stats

1 file+7 added−5 removed

  • other:+7 added−5 removed

1 file+7 added−5 removed

modified:tea.go+7 added-5 removed
985 unmodified lines
986987 if p.disableInput {988 p.input = nil989 } else if p.input == nil {990 p.input = os.Stdin990 // Always open the TTY for input.991 ttyIn, _, err := OpenTTY()992 if err != nil {993 return p.initialModel, fmt.Errorf("bubbletea: error opening TTY: %w", err)991 if !term.IsTerminal(os.Stdin.Fd()) {992 ttyIn, _, err := OpenTTY()993 if err != nil {994 return p.initialModel, fmt.Errorf("bubbletea: error opening TTY: %w", err)995 }996 p.input = ttyIn997 }995 p.input = ttyIn998 }9991000 // Handle signals.1001 if !p.disableSignalHandler {
416 unmodified lines