From ab65ab5d027e97ead372264a6ecfd3ac642299ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 25 Nov 2016 16:46:38 +0100 Subject: vis: fix I/O redirection bugs, cleanup vis_pipe The `:!` command did redirect stdout to a pipe which was used by `vis-menu` to return the selected entry. However, this breaks other interactive commands such as `:!/bin/sh` where command output was never displayed. Instead we modified `vis-menu` to re-open /dev/tty for its user interface which makes it work as a regular filter `:|` This patch also obsoletes the interactive flag previously passed to the vis_pipe function. Interactive mode is instead enabled by piping an invalid range. --- sam.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sam.c') diff --git a/sam.c b/sam.c index 93c41c2..594de1c 100644 --- a/sam.c +++ b/sam.c @@ -1398,7 +1398,7 @@ static bool cmd_filter(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur Buffer buferr; buffer_init(&buferr); - int status = vis_pipe(vis, range, false, &argv[1], &filter, read_text, &buferr, read_buffer); + int status = vis_pipe(vis, range, &argv[1], &filter, read_text, &buferr, read_buffer); if (status == 0) { text_delete_range(txt, range); @@ -1422,8 +1422,8 @@ static bool cmd_filter(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur } static bool cmd_launch(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor *cur, Filerange *range) { - Filerange empty = text_range_new(cur ? view_cursors_pos(cur) : range->start, EPOS); - return cmd_filter(vis, win, cmd, argv, cur, &empty); + Filerange invalid = text_range_new(cur ? view_cursors_pos(cur) : range->start, EPOS); + return cmd_filter(vis, win, cmd, argv, cur, &invalid); } static bool cmd_pipein(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor *cur, Filerange *range) { @@ -1446,7 +1446,7 @@ static bool cmd_pipeout(Vis *vis, Win *win, Command *cmd, const char *argv[], Cu Buffer buferr; buffer_init(&buferr); - int status = vis_pipe(vis, range, false, (const char*[]){ argv[1], NULL }, NULL, NULL, &buferr, read_buffer); + int status = vis_pipe(vis, range, (const char*[]){ argv[1], NULL }, NULL, NULL, &buferr, read_buffer); if (status == 0 && cur) view_cursors_to(cur, range->start); -- cgit v1.2.3