Make sure 'become' process is given a proper tty device

This commit is contained in:
Junegunn Choi 2023-05-21 13:51:06 +09:00
parent 86e4f4a841
commit 16b0aeda7d
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 13 additions and 0 deletions

View File

@ -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())
}

View File

@ -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