From 009747ae6f596ec4078aaf68190dc877c3c58bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl-Einar=20Bergstr=C3=B8m?= Date: Wed, 14 Oct 2026 13:37:07 +0200 Subject: [PATCH] fix: lazysecrets starts from fzf's become, on a non-blocking terminal --- cmd/lazysecrets/main.go | 1 + cmd/lazysecrets/stdin_other.go | 5 +++++ cmd/lazysecrets/stdin_unix.go | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 cmd/lazysecrets/stdin_other.go create mode 100644 cmd/lazysecrets/stdin_unix.go diff --git a/cmd/lazysecrets/main.go b/cmd/lazysecrets/main.go index 32a63f4..256fb45 100644 --- a/cmd/lazysecrets/main.go +++ b/cmd/lazysecrets/main.go @@ -436,6 +436,7 @@ Flags: Styles: &theme, DefaultFg: defaultFg, }) + blockingStdin() p = tea.NewProgram(m) final, err := p.Run() if fm, ok := final.(app.Model); ok { diff --git a/cmd/lazysecrets/stdin_other.go b/cmd/lazysecrets/stdin_other.go new file mode 100644 index 0000000..f02a344 --- /dev/null +++ b/cmd/lazysecrets/stdin_other.go @@ -0,0 +1,5 @@ +//go:build !unix + +package main + +func blockingStdin() {} diff --git a/cmd/lazysecrets/stdin_unix.go b/cmd/lazysecrets/stdin_unix.go new file mode 100644 index 0000000..c7403a3 --- /dev/null +++ b/cmd/lazysecrets/stdin_unix.go @@ -0,0 +1,20 @@ +//go:build unix + +package main + +import ( + "os" + "syscall" + + "golang.org/x/term" +) + +// blockingStdin makes a terminal on stdin blocking again. fzf's become +// hands on its /dev/tty non-blocking; Go can't poll /dev/tty on macOS, +// so it reads it directly, and the TUI's first read would fail with +// EAGAIN ("resource temporarily unavailable"). +func blockingStdin() { + if fd := int(os.Stdin.Fd()); term.IsTerminal(fd) { + _ = syscall.SetNonblock(fd, false) + } +}