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)
diff --git a/src/evalvars.c b/src/evalvars.c
index eb198fd..3aaae13 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -143,6 +143,7 @@
{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 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