diff options
author | wm4 <wm4@nowhere> | 2013-11-29 23:36:44 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-30 01:08:23 +0100 |
commit | e61e6e6fd9676ce3ff3971851755cdb7cf63dbf1 (patch) | |
tree | 81e29c6c927c7b0bfcb306c2ddb7741c2f2d3677 /mpvcore/player/command.c | |
parent | 5fe5fb02b49eb2c5dbea507b5e4fa914751debf1 (diff) | |
download | mpv-e61e6e6fd9676ce3ff3971851755cdb7cf63dbf1.tar.bz2 mpv-e61e6e6fd9676ce3ff3971851755cdb7cf63dbf1.tar.xz |
command: change the syntax and semantics of the "run" command
See the changes in input.rst for explanations.
Technically speaking, this also gets rid of some undefined behavior:
passing NULL as a vararg (execl()) is always a bug.
Diffstat (limited to 'mpvcore/player/command.c')
-rw-r--r-- | mpvcore/player/command.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mpvcore/player/command.c b/mpvcore/player/command.c index f6aa429b99..3bd618da8e 100644 --- a/mpvcore/player/command.c +++ b/mpvcore/player/command.c @@ -2942,14 +2942,18 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) screenshot_to_file(mpctx, cmd->args[0].v.s, cmd->args[1].v.i, msg_osd); break; - case MP_CMD_RUN: + case MP_CMD_RUN: { #ifndef __MINGW32__ + char *args[MP_CMD_MAX_ARGS + 1] = {0}; + for (int n = 0; n < cmd->nargs; n++) + args[n] = cmd->args[n].v.s; if (!fork()) { - execl("/bin/sh", "sh", "-c", cmd->args[0].v.s, NULL); + execvp(args[0], args); exit(0); } #endif break; + } case MP_CMD_ENABLE_INPUT_SECTION: mp_input_enable_section(mpctx->input, cmd->args[0].v.s, |