# HG changeset patch # User Bram Moolenaar # Date 1627466406 -7200 # Node ID a6c347a0c6e37c4adbce9f5df530950f7ac4d39d # Parent 19b15ae5eb9f4401b158d7d4369e394ca0c388c2 patch 8.2.3232: system() does not work without a second argument Commit: https://github.com/vim/vim/commit/7e6a2a64f09df577f29e024c1d1e6733d6bc1b7c Author: Yegappan Lakshmanan Date: Wed Jul 28 11:51:48 2021 +0200 patch 8.2.3232: system() does not work without a second argument Problem: system() does not work without a second argument. Solution: Do not require a second argument. (Yegappan Lakshmanan, closes #8651, closes #8650) diff --git a/src/misc1.c b/src/misc1.c --- a/src/misc1.c +++ b/src/misc1.c @@ -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) diff --git a/src/proto/typval.pro b/src/proto/typval.pro --- a/src/proto/typval.pro +++ b/src/proto/typval.pro @@ -36,6 +36,7 @@ int check_for_string_or_list_arg(typval_ 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); diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -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', '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', '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() diff --git a/src/typval.c b/src/typval.c --- a/src/typval.c +++ b/src/typval.c @@ -727,6 +727,17 @@ check_for_string_or_number_or_list_arg(t } /* + * 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. */ diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3232, +/**/ 3231, /**/ 3230,