vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 98dfc31d42a5c428d6f5720ab502447373c79e5f
parent e25a7e5f7708207c8462e4dacfdbe308d5b13dc8
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sat, 26 Nov 2016 17:19:04 +0100

vis: re-open /dev/tty read-writeable

libtermkey's initialization routine tries to write to the underlying
file descriptor which fails with EBADF if it is opened read only.
This was a problem in the terminal restore code called after a shell
command is executed.

It should fix the following:

 $ echo foo | vis - > bar
 :!/bin/sh
 exit

where before vis would no longer accept any input.

Diffstat:
Mmain.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c @@ -2280,7 +2280,7 @@ int main(int argc, char *argv[]) { if (len == -1) vis_die(vis, "Can not read from stdin\n"); text_snapshot(txt); - int fd = open("/dev/tty", O_RDONLY); + int fd = open("/dev/tty", O_RDWR); if (fd == -1) vis_die(vis, "Can not reopen stdin\n"); dup2(fd, STDIN_FILENO);