diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-04-01 19:49:57 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-04-03 21:38:04 +0200 |
| commit | b6248c95a1a9048716ade3f7a5c6ab4ee9d144aa (patch) | |
| tree | bbfff0b42beac7a9cb1c51e109baffebef2b8989 | |
| parent | d2ae7bc7a5e85ecc7de5188778c20d7ac7282b34 (diff) | |
| download | vis-b6248c95a1a9048716ade3f7a5c6ab4ee9d144aa.tar.gz vis-b6248c95a1a9048716ade3f7a5c6ab4ee9d144aa.tar.xz | |
sam: implement r (read) command in terms of < cat
It replaces current range with the file content. However in the common
case the range is actually defaults to the whole file which is probably
not what is expected.
| -rw-r--r-- | sam.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -964,7 +964,19 @@ static bool cmd_write(Vis *vis, Win *win, Command *cmd, Filerange *range) { } static bool cmd_read(Vis *vis, Win *win, Command *cmd, Filerange *range) { - return false; + + bool ret = false; + Buffer buf; + buffer_init(&buf); + + if (!buffer_put0(&buf, "cat ") || !buffer_append0(&buf, cmd->text)) + goto out; + + Command pipe_cmd = { .text = buf.data }; // FIXME + ret = cmd_pipein(vis, win, &pipe_cmd, range); +out: + buffer_release(&buf); + return ret; } static ssize_t read_stdout(void *context, char *data, size_t len) { |
