vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit aeafc8bf2f40b5a3458b1cc3d5bc7eadbd626da2 parent 477ea083b57993573eec1fbfefcaee0823e2008d Author: Matias Linares <matiaslina@openmailbox.org> Date: Thu, 7 May 2015 09:31:49 +0200 Add '--' as end of options Now it works properly, `vis -- -v` edit a file named `-v`. Also added the proper info to the man page. Diffstat:
| M | vis.1 | | | 3 | +++ |
| M | vis.c | | | 6 | +++++- |
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/vis.1 b/vis.1 @@ -13,5 +13,8 @@ is a highly efficient vim like text editor. .SH OPTIONS .B \-v Print version information to standard output and exit. + +.B \-\- +Denotes the end of the options. Arguments after this will be handled as a file name. This can be used to edit a filename that starts with a '-'. .SH AUTHOR vis is written by Marc André Tanner <mat at brain-dump.org> diff --git a/vis.c b/vis.c @@ -2026,9 +2026,13 @@ int main(int argc, char *argv[]) { die("Could not load syntax highlighting definitions\n"); char *cmd = NULL; + bool end_of_options = false; for (int i = 1; i < argc; i++) { - if (argv[i][0] == '-') { + if (argv[i][0] == '-' && !end_of_options) { switch (argv[i][1]) { + case '-': + end_of_options = true; + break; case 'v': die("vis %s, compiled " __DATE__ " " __TIME__ "\n", VERSION); break;