From b0f9279824de3ffb206e45992c986457e27b59f4 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Fri, 27 Mar 2026 20:14:23 -0400 Subject: [PATCH] TOOLS/lua/command-test.lua: use _name key for mp.command_native --- TOOLS/lua/command-test.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/TOOLS/lua/command-test.lua b/TOOLS/lua/command-test.lua index 1f485cdf7f..4325bc3171 100644 --- a/TOOLS/lua/command-test.lua +++ b/TOOLS/lua/command-test.lua @@ -52,7 +52,7 @@ mp.observe_property("vo-configured", "bool", function(_, v) end) mp.command_native_async({ - name = "subprocess", + _name = "subprocess", args = {"sh", "-c", "echo hi && sleep 10s"}, capture_stdout = true }, @@ -60,7 +60,7 @@ mp.observe_property("vo-configured", "bool", function(_, v) print("done subprocess: " .. join(" ", {res, val, err})) end) - local x = mp.command_native_async({name = "subprocess", args = {"sleep", "inf"}}, + local x = mp.command_native_async({_name = "subprocess", args = {"sleep", "inf"}}, function(res, val, err) print("done sleep inf subprocess: " .. join(" ", {res, val, err})) end) @@ -70,7 +70,7 @@ mp.observe_property("vo-configured", "bool", function(_, v) end) -- (assuming this "freezes") - local y = mp.command_native_async({name = "sub-add", url = "-"}, + local y = mp.command_native_async({_name = "sub-add", url = "-"}, function(res, val, err) print("done sub-add stdin: " .. join(" ", {res, val, err})) end) @@ -80,19 +80,19 @@ mp.observe_property("vo-configured", "bool", function(_, v) end) - mp.command_native_async({name = "subprocess", args = {"wc", "-c"}, + mp.command_native_async({_name = "subprocess", args = {"wc", "-c"}, stdin_data = "hello", capture_stdout = true}, function(_, val) print("Should be '5': " .. val.stdout) end) -- blocking stdin by default - mp.command_native_async({name = "subprocess", args = {"cat"}, + mp.command_native_async({_name = "subprocess", args = {"cat"}, capture_stdout = true}, function(_, val) print("Should be 0: " .. #val.stdout) end) -- stdin + detached - mp.command_native_async({name = "subprocess", + mp.command_native_async({_name = "subprocess", args = {"bash", "-c", "(sleep 5s ; cat)"}, stdin_data = "this should appear after 5s.\n", detach = true}, @@ -101,11 +101,11 @@ mp.observe_property("vo-configured", "bool", function(_, v) end) -- This should get killed on script exit. - mp.command_native_async({name = "subprocess", playback_only = false, + mp.command_native_async({_name = "subprocess", playback_only = false, args = {"sleep", "inf"}}, function()end) -- Runs detached; should be killed on player exit (forces timeout) - mp.command_native({_flags={"async"}, name = "subprocess", + mp.command_native({_flags={"async"}, _name = "subprocess", playback_only = false, args = {"sleep", "inf"}}) end) @@ -114,7 +114,7 @@ local function freeze_test(playback_only) -- This "freezes" the script, should be killed via timeout. counter = counter and counter + 1 or 0 print("freeze! " .. counter) - local x = mp.command_native({name = "subprocess", + local x = mp.command_native({_name = "subprocess", playback_only = playback_only, args = {"sleep", "inf"}}) print("done, killed=" .. utils.to_string(x.killed_by_us))