0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

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 #1322)
This commit is contained in:
Bram Moolenaar
2019-10-29 04:16:57 +01:00
parent 8b530c1ff9
commit 69bf634858
8 changed files with 53 additions and 4 deletions

View File

@@ -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
@@ -2085,6 +2086,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.
*/