[vim/vim] WIP: system()/systemlist(): accept List as command argument (PR #19791)

14 views
Skip to first unread message

mattn

unread,
Mar 22, 2026, 3:22:07 PM (2 days ago) Mar 22
to vim/vim, Subscribed

Allow system() and systemlist() to accept a List as the first argument, like job_start() does. When a List is given, the command is executed directly without invoking the shell.

This is still work in progress. Platform-specific implementations, documentation, and tests are not yet included.

Closes #19789


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19791

Commit Summary

  • 5da978b WIP: system()/systemlist(): accept List as command argument

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791@github.com>

mattn

unread,
Mar 22, 2026, 3:31:17 PM (2 days ago) Mar 22
to vim/vim, Push

@mattn pushed 1 commit.

  • f47c008 WIP: system()/systemlist(): add Windows implementation


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/5da978be953883a02b7002aea12e3d514841fe6a/after/f47c00889bb377b17af99350144a0282d1c860ed@github.com>

mattn

unread,
Mar 22, 2026, 3:34:11 PM (2 days ago) Mar 22
to vim/vim, Push

@mattn pushed 1 commit.

  • 97cd256 WIP: system()/systemlist(): add comments to Windows implementation


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/f47c00889bb377b17af99350144a0282d1c860ed/after/97cd256cfaa0f53a0d63da76aeebc9d89fd1a764@github.com>

mattn

unread,
Mar 22, 2026, 3:35:57 PM (2 days ago) Mar 22
to vim/vim, Push

@mattn pushed 1 commit.

  • 5e56d5c WIP: system()/systemlist(): add verbose logging to Windows implementation


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/97cd256cfaa0f53a0d63da76aeebc9d89fd1a764/after/5e56d5cd0d53b5ffaa0b34f634113080a0b11384@github.com>

mattn

unread,
Mar 22, 2026, 3:38:23 PM (2 days ago) Mar 22
to vim/vim, Push

@mattn pushed 1 commit.

  • 16c8996 WIP: system()/systemlist(): add ch_log to Windows implementation


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/5e56d5cd0d53b5ffaa0b34f634113080a0b11384/after/16c89967545f4d835161ed5400e330e3f1be4d25@github.com>

mattn

unread,
Mar 22, 2026, 6:22:10 PM (2 days ago) Mar 22
to vim/vim, Push

@mattn pushed 1 commit.

  • 6993664 WIP: system()/systemlist(): add Unix implementation


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/16c89967545f4d835161ed5400e330e3f1be4d25/after/6993664722d0f33d621b724519d3bac304dfaf67@github.com>

mattn

unread,
Mar 22, 2026, 6:27:19 PM (2 days ago) Mar 22
to vim/vim, Subscribed
mattn left a comment (vim/vim#19791)

I'm considering whether to add process tree termination (like job_start() does with JobObject on Windows and process groups on Unix), but not sure if it's needed for synchronous execution.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/c4107109765@github.com>

mattn

unread,
Mar 22, 2026, 7:19:56 PM (2 days ago) Mar 22
to vim/vim, Subscribed
mattn left a comment (vim/vim#19791)

The current system() and systemlist() with a string argument don't have a mechanism to terminate the child process on CTRL-C either, so I'll leave this as-is for now.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/c4107187811@github.com>

mattn

unread,
Mar 22, 2026, 7:22:45 PM (2 days ago) Mar 22
to vim/vim, Push

@mattn pushed 1 commit.

  • 11e48bd WIP: system()/systemlist(): fix vim9 builtin test for new type check


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/6993664722d0f33d621b724519d3bac304dfaf67/after/11e48bd0b51c7e6bad6d59fa1376735a04542d89@github.com>

mattn

unread,
Mar 22, 2026, 7:25:37 PM (2 days ago) Mar 22
to vim/vim, Subscribed
mattn left a comment (vim/vim#19791)

Note to self: if process tree termination is needed in the future, Unix would use kill(9) on a process group, and Windows would use JobObject like job_start() does. In that case, interrupt detection would also be needed.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/c4107195765@github.com>

mattn

unread,
Mar 22, 2026, 7:41:56 PM (2 days ago) Mar 22
to vim/vim, Push

@mattn pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/a6d2c4d3825f7184787cdbfdcef3c67c24e6f153/after/0309b25adffcabcce684b0341fe188510eed38ce@github.com>

mattn

unread,
Mar 22, 2026, 7:50:31 PM (2 days ago) Mar 22
to vim/vim, Push

@mattn pushed 1 commit.

  • a409a5b WIP: system()/systemlist(): fix preprocessor indentation in os_win32.c


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/0309b25adffcabcce684b0341fe188510eed38ce/after/a409a5bbf4c75252777f28a13d8d66a7d1d3d040@github.com>

mattn

unread,
Mar 22, 2026, 8:14:17 PM (2 days ago) Mar 22
to vim/vim, Push

@mattn pushed 1 commit.

  • cc67414 system()/systemlist(): add tests for List argument


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/a409a5bbf4c75252777f28a13d8d66a7d1d3d040/after/cc6741433d9c0b7a9864cd9cc3c06e77caeec2c8@github.com>

mattn

unread,
Mar 22, 2026, 8:19:47 PM (2 days ago) Mar 22
to vim/vim, Subscribed
mattn left a comment (vim/vim#19791)

Now that the List form bypasses the shell, environment variables like $HOME or %USERPROFILE% are no longer expanded. We may need to support a dict as the first argument to pass environment variables explicitly, like:

system({"cmd": ["foo", "bar"], "env": {"FOO": "BAR"}})

Since the second argument of system() is already used for stdin input, this would be the natural place to put it.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/c4107295544@github.com>

mattn

unread,
Mar 22, 2026, 8:24:15 PM (2 days ago) Mar 22
to vim/vim, Subscribed
mattn left a comment (vim/vim#19791)

But for this PR, I'll keep it to List support only. Dict support can be added in a follow-up.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/c4107306396@github.com>

mattn

unread,
Mar 22, 2026, 8:31:59 PM (2 days ago) Mar 22
to vim/vim, Push

@mattn pushed 1 commit.

  • 17794e4 system()/systemlist(): fix test for CR on Windows


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/cc6741433d9c0b7a9864cd9cc3c06e77caeec2c8/after/17794e4dddbb09dbe2098e7561bf9a219094b0e8@github.com>

mattn

unread,
Mar 22, 2026, 10:17:17 PM (2 days ago) Mar 22
to vim/vim, Subscribed
mattn left a comment (vim/vim#19791)

Implemented list argument of system()/systemlist()


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/c4107560709@github.com>

Christian Brabandt

unread,
Mar 23, 2026, 3:09:12 AM (yesterday) Mar 23
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19791)

Thanks for working on this. However this requires documentation updates that the list form works without a shell. We should also mention, that certain things won't work then (redirection, expansions, etc).


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/c4108471856@github.com>

mattn

unread,
Mar 23, 2026, 3:24:17 AM (yesterday) Mar 23
to vim/vim, Push

@mattn pushed 1 commit.

  • 8fae2f8 system()/systemlist(): document List argument form


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/17794e4dddbb09dbe2098e7561bf9a219094b0e8/after/8fae2f8603f9d7e84b800887ab6a9c1ddccb030d@github.com>

mattn

unread,
Mar 23, 2026, 12:12:11 PM (yesterday) Mar 23
to vim/vim, Subscribed
mattn left a comment (vim/vim#19791)

Document updated


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/c4111817139@github.com>

Christian Brabandt

unread,
Mar 23, 2026, 4:16:35 PM (yesterday) Mar 23
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In src/misc1.c:

> +
+	if (p_verbose > 3)
+	{
+	    int		i;
+	    garray_T	ga;
+
+	    verbose_enter();
+	    ga_init2(&ga, 1, 200);
+	    for (i = 0; i < argc; ++i)
+	    {
+		if (i > 0)
+		    ga_append(&ga, ' ');
+		ga_concat(&ga, (char_u *)argv[i]);
+	    }
+	    ga_append(&ga, NUL);
+	    smsg(_("Executing directly: \"%s\""), (char *)ga.ga_data);

okay, you are logging here.


In src/os_unix.c:

> +
+    if (p_verbose > 3)
+    {
+	garray_T    log_ga;
+	int	    i;
+
+	verbose_enter();
+	ga_init2(&log_ga, 1, 200);
+	for (i = 0; argv[i] != NULL; ++i)
+	{
+	    if (i > 0)
+		ga_append(&log_ga, ' ');
+	    ga_concat(&log_ga, (char_u *)argv[i]);
+	}
+	ga_append(&log_ga, NUL);
+	smsg(_("Executing directly: \"%s\""), (char *)log_ga.ga_data);

now you are logging it again for the Unix implementation.


In src/os_win32.c:

> +		break;
+	    }
+
+	if (i > 0)
+	    ga_append(&cmd_ga, ' ');
+
+	if (has_spaces)
+	{
+	    ga_append(&cmd_ga, '"');
+	    for (j = 0; arg[j] != NUL; j++)
+	    {
+		if (arg[j] == '"')
+		    ga_append(&cmd_ga, '\\');
+		ga_append(&cmd_ga, arg[j]);
+	    }
+	    ga_append(&cmd_ga, '"');

Hm, when cmd_ga ends with a backslash like C:\user\ this will escape the double quote and make the command invalid, no?


In src/os_win32.c:

> +    }
+
+    ZeroMemory(&pi, sizeof(pi));
+    ZeroMemory(&si, sizeof(si));
+    si.cb = sizeof(si);
+    si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
+    si.wShowWindow = SW_HIDE;
+    si.hStdOutput = hChildStdoutWr;
+    si.hStdError = hChildStdoutWr;
+    si.hStdInput = (hChildStdinRd != INVALID_HANDLE_VALUE)
+		    ? hChildStdinRd : INVALID_HANDLE_VALUE;
+
+    if (p_verbose > 3)
+    {
+	verbose_enter();
+	smsg(_("Executing directly: \"%s\""), (char *)cmd_ga.ga_data);

logging again on the Windows implementation


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/review/3994356405@github.com>

mattn

unread,
Mar 23, 2026, 7:36:01 PM (yesterday) Mar 23
to vim/vim, Push

@mattn pushed 1 commit.

  • 2dedfef system()/systemlist(): remove duplicate verbose logging


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/8fae2f8603f9d7e84b800887ab6a9c1ddccb030d/after/2dedfef7e6d00fd7aa4c44b78668cc7069bdcdc7@github.com>

mattn

unread,
Mar 23, 2026, 7:40:36 PM (yesterday) Mar 23
to vim/vim, Push

@mattn pushed 1 commit.

  • bfb5150 system()/systemlist(): fix backslash quoting on Windows


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/2dedfef7e6d00fd7aa4c44b78668cc7069bdcdc7/after/bfb5150b96498d90aacbdeaa3932755a7aa2def9@github.com>

mattn

unread,
Mar 23, 2026, 7:41:19 PM (yesterday) Mar 23
to vim/vim, Subscribed
mattn left a comment (vim/vim#19791)

ptal


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/c4114414417@github.com>

Christian Brabandt

unread,
4:20 PM (7 hours ago) 4:20 PM
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In src/os_unix.c:

> +    int		*ret_len)
+{
+    pid_t	pid;
+    int		fd_out[2] = {-1, -1};
+    int		status = -1;
+    char_u	*buffer = NULL;
+    garray_T	ga;
+    SIGSET_DECL(curset)
+
+    ga_init2(&ga, 1, 4096);
+
+    ch_log(NULL, "directly executing: %s", argv[0]);
+
+    if (pipe(fd_out) < 0)
+    {
+	emsg(_("E5677: Cannot create pipes"));

sorry, I did not notice previously, can you make this a proper error message inside error.h?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/review/4002037903@github.com>

mattn

unread,
8:44 PM (3 hours ago) 8:44 PM
to vim/vim, Push

@mattn pushed 1 commit.

  • 33526ce system()/systemlist(): move E5677 to errors.h


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/before/bfb5150b96498d90aacbdeaa3932755a7aa2def9/after/33526ce8a42b9f70adf65f124778aed74d82aef6@github.com>

mattn

unread,
8:44 PM (3 hours ago) 8:44 PM
to vim/vim, Subscribed
mattn left a comment (vim/vim#19791)

thank you. fixed


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19791/c4122377981@github.com>

Reply all
Reply to author
Forward
0 new messages