]> granicus.if.org Git - vim/commitdiff
patch 8.2.3232: system() does not work without a second argument v8.2.3232
authorYegappan Lakshmanan <yegappan@yahoo.com>
Wed, 28 Jul 2021 09:51:48 +0000 (11:51 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 28 Jul 2021 09:51:48 +0000 (11:51 +0200)
Problem:    system() does not work without a second argument.
Solution:   Do not require a second argument. (Yegappan Lakshmanan,
            closes #8651, closes #8650)

src/misc1.c
src/proto/typval.pro
src/testdir/test_vim9_builtin.vim
src/typval.c
src/version.c

index e66f5a85d3cd793306a922f9a502380c6fdebfe8..7d7f022f1e4592c5c0b65998b25b885712fa84c8 100644 (file)
@@ -2359,7 +2359,7 @@ get_cmd_output_as_rettv(
 
     if (in_vim9script()
            && (check_for_string_arg(argvars, 0) == FAIL
-               || check_for_string_or_number_or_list_arg(argvars, 1) == FAIL))
+               || check_for_opt_string_or_number_or_list_arg(argvars, 1) == FAIL))
        return;
 
     if (argvars[1].v_type != VAR_UNKNOWN)
index 9b5af699db30e821c582286448b9cd1f4768de03..e509e4d9515d19d27d7201deca367811baeb31e2 100644 (file)
@@ -36,6 +36,7 @@ int check_for_string_or_list_arg(typval_T *args, int idx);
 int check_for_opt_string_or_list_arg(typval_T *args, int idx);
 int check_for_string_or_dict_arg(typval_T *args, int idx);
 int check_for_string_or_number_or_list_arg(typval_T *args, int idx);
+int check_for_opt_string_or_number_or_list_arg(typval_T *args, int idx);
 int check_for_string_or_list_or_dict_arg(typval_T *args, int idx);
 int check_for_list_or_blob_arg(typval_T *args, int idx);
 int check_for_list_or_dict_arg(typval_T *args, int idx);
index bd52f702c304b51542fcd46a7c9c3070d6f26c88..20a81baac02b4ae64d8fd0617ba48a022975cf1e 100644 (file)
@@ -3290,11 +3290,17 @@ enddef
 def Test_system()
   CheckDefAndScriptFailure2(['system(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
   CheckDefAndScriptFailure2(['system("a", {})'], 'E1013: Argument 2: type mismatch, expected string but got dict<unknown>', 'E1224: String or List required for argument 2')
+  assert_equal("123\n", system('echo 123'))
 enddef
 
 def Test_systemlist()
   CheckDefAndScriptFailure2(['systemlist(1)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
   CheckDefAndScriptFailure2(['systemlist("a", {})'], 'E1013: Argument 2: type mismatch, expected string but got dict<unknown>', 'E1224: String or List required for argument 2')
+  if has('win32')
+    call assert_equal(["123\r"], systemlist('echo 123'))
+  else
+    call assert_equal(['123'], systemlist('echo 123'))
+  endif
 enddef
 
 def Test_tabpagebuflist()
index 34032177dbd36eb074be8b86211ab24f4bd8587c..fb527e988b77573f1f0b2964393c5de627e3e480 100644 (file)
@@ -726,6 +726,17 @@ check_for_string_or_number_or_list_arg(typval_T *args, int idx)
     return OK;
 }
 
+/*
+ * Give an error and return FAIL unless "args[idx]" is an optional string
+ * or number or a list
+ */
+    int
+check_for_opt_string_or_number_or_list_arg(typval_T *args, int idx)
+{
+    return (args[idx].v_type == VAR_UNKNOWN
+           || check_for_string_or_number_or_list_arg(args, idx) != FAIL);
+}
+
 /*
  * Give an error and return FAIL unless "args[idx]" is a string or a list
  * or a dict.
index e6491db0f120f314af3b2f4736a341066046260a..85b8ae9f5c6a2430ba67f80366bb302ddc21a009 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3232,
 /**/
     3231,
 /**/