diff options
author | wm4 <wm4@nowhere> | 2020-08-16 02:54:44 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-08-16 02:54:44 +0200 |
commit | e27c523a10708b7265c33a4bae631663df4bb297 (patch) | |
tree | 34bdcd1bc48a5311ec24181dec913768180ad851 /TOOLS/lua/command-test.lua | |
parent | d6bf3880d74459103a39426275837ec0a1d48e54 (diff) | |
download | mpv-e27c523a10708b7265c33a4bae631663df4bb297.tar.bz2 mpv-e27c523a10708b7265c33a4bae631663df4bb297.tar.xz |
command: extend subprocess command stdin, change behavior
Make it possible to feed a string to stdin of a subprocess. Out of
laziness, it can't be an arbitrary byte string. (Would require adding an
option type that takes in a Lua byte string.)
Do not set stdin of a subprocess to fd 0 (i.e. mpv's stdin) anymore,
because it makes things more consistent. Enabling stdin didn't make too
much sense in the first place, so this behavior change seems
justifiable.
win32 support missing.
Fixes: #8003
Diffstat (limited to 'TOOLS/lua/command-test.lua')
-rw-r--r-- | TOOLS/lua/command-test.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/TOOLS/lua/command-test.lua b/TOOLS/lua/command-test.lua index 30d8cc05ff..877cacdeb6 100644 --- a/TOOLS/lua/command-test.lua +++ b/TOOLS/lua/command-test.lua @@ -76,6 +76,25 @@ mp.observe_property("vo-configured", "bool", function(_, v) end) + mp.command_native_async({name = "subprocess", args = {"wc", "-c"}, + stdin_data = "hello", capture_stdout = true}, + function(res, val, err) + print("Should be '5': " .. val.stdout) + end) + -- blocking stdin by default + mp.command_native_async({name = "subprocess", args = {"cat"}, + capture_stdout = true}, + function(res, val, err) + print("Should be 0: " .. #val.stdout) + end) + -- stdin + detached + mp.command_native_async({name = "subprocess", + args = {"bash", "-c", "(sleep 5s ; cat)"}, + stdin_data = "this should appear after 5s.\n", + detach = true}, + function(res, val, err) + print("5s test: " .. val.status) + end) -- This should get killed on script exit. mp.command_native_async({name = "subprocess", playback_only = false, |