summaryrefslogtreecommitdiffstats
path: root/src/evalvars.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-10-29 04:16:57 +0100
committerBram Moolenaar <Bram@vim.org>2019-10-29 04:16:57 +0100
commit69bf634858a2a75f2984e42b1e4017bc529a040a (patch)
tree1584b32f67463ec2b31ac858e5ada499a34967af /src/evalvars.c
parent8b530c1ff91f07cf6b0289a536992b7dfbc86598 (diff)
patch 8.1.2233: cannot get the Vim command line argumentsv8.1.2233
Problem: Cannot get the Vim command line arguments. Solution: Add v:argv. (Dmitri Vereshchagin, closes #1322)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index eb198fdf9f..3aaae13b45 100644
--- 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