aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-05-17 10:07:24 +0200
committerMarc André Tanner <mat@brain-dump.org>2017-05-17 10:07:24 +0200
commitfbf4a58b75d997273b6e2b5ab471a986dbfd1151 (patch)
treeca3a9e8f990fb716670ba2b27c4c046be3cd733a
parentad93f50bf43214fc4ed6c44fdc8b87616e2a5603 (diff)
downloadvis-fbf4a58b75d997273b6e2b5ab471a986dbfd1151.tar.gz
vis-fbf4a58b75d997273b6e2b5ab471a986dbfd1151.tar.xz
vis: ensure complete ! command output is displayed
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 #545
-rw-r--r--vis.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/vis.c b/vis.c
index cf0a922..e4a706c 100644
--- a/vis.c
+++ b/vis.c
@@ -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) {