From 16b0aeda7dda8790d026873f5efd7d6fb344a1dd Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 21 May 2023 13:51:06 +0900 Subject: [PATCH] Make sure 'become' process is given a proper tty device --- src/terminal.go | 8 ++++++++ test/test_go.rb | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/terminal.go b/src/terminal.go index f25cd2f..7f6adad 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -2961,6 +2961,14 @@ func (t *Terminal) Loop() { if t.history != nil { t.history.append(string(t.input)) } + /* + FIXME: It is not at all clear why this is required. + The following command will report 'not a tty', unless we open + /dev/tty *twice* after closing the standard input for 'reload' + in Reader.terminate(). + : | fzf --bind 'start:reload:ls' --bind 'enter:become:tty' + */ + tui.TtyIn() util.SetStdin(tui.TtyIn()) syscall.Exec(shellPath, []string{shell, "-c", command}, os.Environ()) } diff --git a/test/test_go.rb b/test/test_go.rb index 1f4245a..f7dcfe6 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -2921,6 +2921,11 @@ class TestGoFZF < TestBase OUTPUT tmux.until { assert_block(expected, _1) } end + + def test_become_tty + tmux.send_keys "sleep 0.5 | #{FZF} --bind 'start:reload:ls' --bind 'load:become:tty'", :Enter + tmux.until { |lines| assert_includes lines, '/dev/tty' } + end end module TestShell