Mercurial > vim
diff src/evalvars.c @ 18477:e93cab5d0f0f v8.1.2233
patch 8.1.2233: cannot get the Vim command line arguments
Commit: https://github.com/vim/vim/commit/69bf634858a2a75f2984e42b1e4017bc529a040a
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Oct 29 04:16:57 2019 +0100
patch 8.1.2233: cannot get the Vim command line arguments
Problem: Cannot get the Vim command line arguments.
Solution: Add v:argv. (Dmitri Vereshchagin, closes https://github.com/vim/vim/issues/1322)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 29 Oct 2019 04:30:05 +0100 |
parents | 9ea364ccf216 |
children | e47b04b01793 |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -143,6 +143,7 @@ static struct vimvar {VV_NAME("event", VAR_DICT), VV_RO}, {VV_NAME("versionlong", VAR_NUMBER), VV_RO}, {VV_NAME("echospace", VAR_NUMBER), VV_RO}, + {VV_NAME("argv", VAR_LIST), VV_RO}, }; // shorthand @@ -2086,6 +2087,27 @@ set_vim_var_dict(int idx, dict_T *val) } /* + * Set the v:argv list. + */ + void +set_argv_var(char **argv, int argc) +{ + list_T *l = list_alloc(); + int i; + + if (l == NULL) + getout(1); + l->lv_lock = VAR_FIXED; + for (i = 0; i < argc; ++i) + { + if (list_append_string(l, (char_u *)argv[i], -1) == FAIL) + getout(1); + l->lv_last->li_tv.v_lock = VAR_FIXED; + } + set_vim_var_list(VV_ARGV, l); +} + +/* * Set v:register if needed. */ void