diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-11-25 16:46:38 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-11-25 17:07:39 +0100 |
| commit | ab65ab5d027e97ead372264a6ecfd3ac642299ba (patch) | |
| tree | 747a869eadeed1effb902298b90cd828fa7ba806 /vis.h | |
| parent | 1c9c52647fe2984472246eb2c12b3412fd5fafa4 (diff) | |
| download | vis-ab65ab5d027e97ead372264a6ecfd3ac642299ba.tar.gz vis-ab65ab5d027e97ead372264a6ecfd3ac642299ba.tar.xz | |
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.
Diffstat (limited to 'vis.h')
| -rw-r--r-- | vis.h | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -445,9 +445,9 @@ bool vis_prompt_cmd(Vis*, const char *cmd); /* pipe a given file range to an external process * - * in interactive mode stdin and stderr are not redirected, hence they - * can be used to read keyboard input and draw a user interface on top - * of vis. Attempting to pipe an invalid range enables interactive mode. + * if the range is invalid 'interactive' mode is enabled, meaning that + * stdin and stderr are passed through the underlying command, stdout + * points to vis' stderr. * * if argv contains only one non-NULL element the command is executed using * /bin/sh -c (i.e. argument expansion is performed by the shell). In contrast @@ -457,14 +457,14 @@ bool vis_prompt_cmd(Vis*, const char *cmd); * if read_std{out,err} are non-NULL they will be called when output from * the forked process is available. */ -int vis_pipe(Vis *vis, Filerange *range, bool interactive, const char *argv[], +int vis_pipe(Vis *vis, Filerange *range, const char *argv[], void *stdout_context, ssize_t (*read_stdout)(void *stdout_context, char *data, size_t len), void *stderr_context, ssize_t (*read_stderr)(void *stderr_context, char *data, size_t len)); /* pipe a range to an external application, return its exit status and store * everything that is written to stdout/stderr in the gitven char pointers * which have to be free(3)-ed by the caller */ -int vis_pipe_collect(Vis *vis, Filerange *range, bool interactive, const char *argv[], char **out, char **err); +int vis_pipe_collect(Vis *vis, Filerange *range, const char *argv[], char **out, char **err); /* given the start of a key, returns a pointer to the start of the one immediately * following as will be processed by the input system. skips over special keys |
