Skip to content

Commit 247038f

Browse files
committed
fix: restore terminal state after TUI exits
When invoked via curl|bash, huh/bubbletea TUI components could leave the terminal in raw mode on exit, breaking echo and signal handling. Save terminal state at startup and defer restore to guarantee cleanup.
1 parent ce3d387 commit 247038f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd/openboot/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@ import (
44
"os"
55

66
"github.com/openbootdotdev/openboot/internal/cli"
7+
"golang.org/x/term"
78
)
89

910
func main() {
11+
// Save terminal state before any TUI (huh/bubbletea) runs.
12+
// Ensures the terminal is restored even if a TUI component crashes
13+
// or exits without proper cleanup (e.g., when invoked via curl|bash).
14+
if fd := int(os.Stdin.Fd()); term.IsTerminal(fd) {
15+
if oldState, err := term.GetState(fd); err == nil {
16+
defer term.Restore(fd, oldState)
17+
}
18+
}
19+
1020
if err := cli.Execute(); err != nil {
1121
os.Exit(1)
1222
}

0 commit comments

Comments
 (0)