vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 82eb7d5ee5d14d290b3bb49d9b6bdffb4de26225 parent cfb8f4c8cefab2b5f089f1c621b602f9b9277849 Author: Marc André Tanner <mat@brain-dump.org> Date: Sat, 1 Nov 2014 11:11:20 +0100 Improve usage as a filter When used as in echo Hello World | vis | cat prevent intermediate writes to stdout, only save to stdout when also quiting the editor. Diffstat:
| M | vis.c | | | 8 | ++++++-- |
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/vis.c b/vis.c @@ -1416,8 +1416,12 @@ static bool cmd_write(Filerange *range, const char *argv[]) { if (!argv[1]) argv[1] = text_filename_get(text); if (!argv[1]) { - if (text_fd_get(text) == STDIN_FILENO) - return text_range_write(text, range, STDOUT_FILENO) >= 0; + if (text_fd_get(text) == STDIN_FILENO) { + if (strchr(argv[0], 'q')) + return text_range_write(text, range, STDOUT_FILENO) >= 0; + editor_info_show(vis, "No filename given, use 'wq' to write to stdout"); + return false; + } editor_info_show(vis, "Filename expected"); return false; }