m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-16 15:23:48 -05:00

Refactor tui.TtyIn()

This commit is contained in:
Junegunn Choi
2024-05-15 00:28:56 +09:00
parent c4cc7891b4
commit 86d92c17c4
3 changed files with 11 additions and 20 deletions

View File

@@ -36,15 +36,8 @@ func ttyname() string {
// TtyIn returns terminal device to be used as STDIN, falls back to os.Stdin
func TtyIn() *os.File {
in, err := os.OpenFile(consoleDevice, syscall.O_RDONLY, 0)
if err != nil {
tty := ttyname()
if len(tty) > 0 {
if in, err := os.OpenFile(tty, syscall.O_RDONLY, 0); err == nil {
return in
}
}
return os.Stdin
if in, err := openTtyIn(); err == nil {
return in
}
return in
return os.Stdin
}