Skip to content

Commit

Permalink
vis: ensure complete ! command output is displayed
Browse files Browse the repository at this point in the history
For interactive processes started using `:!` stdout is redirected
to stderr normally used by vis to draw its user interface.
For some reason the first byte written by the interactive application
is not being displayed. I suspect it has something to do with the
terminal state change. For now we are writing a dummy space (which
is never shown) ourself to ensure that the complete output is visible.

Fix martanne#545
  • Loading branch information
martanne committed May 17, 2017
1 parent ad93f50 commit fbf4a58
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions vis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1734,12 +1734,20 @@ int vis_pipe(Vis *vis, File *file, Filerange *range, const char *argv[],
dup2(pin[0], STDIN_FILENO);
close(pin[0]);
close(pin[1]);
if (interactive)
if (interactive) {
dup2(STDERR_FILENO, STDOUT_FILENO);
else if (read_stdout)
/* For some reason the first byte written by the
* interactive application is not being displayed.
* It probably has something to do with the terminal
* state change. By writing a dummy byte ourself we
* ensure that the complete output is visible.
*/
write(STDOUT_FILENO, " ", 1);
} else if (read_stdout) {
dup2(pout[1], STDOUT_FILENO);
else
} else {
dup2(null, STDOUT_FILENO);
}
close(pout[1]);
close(pout[0]);
if (!interactive) {
Expand Down

0 comments on commit fbf4a58

Please sign in to comment.