diff options
author | wm4 <wm4@nowhere> | 2020-01-19 19:25:54 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-01-19 19:25:54 +0100 |
commit | 00cdda2ae80f2f3c5b6fc4302d7edaf14755d037 (patch) | |
tree | 783efd7934056ad73a68593cf2878c5e89235958 /player/scripting.c | |
parent | ee7be62dbc3c25b835c5f14b81382a5c306aa15b (diff) | |
download | mpv-00cdda2ae80f2f3c5b6fc4302d7edaf14755d037.tar.bz2 mpv-00cdda2ae80f2f3c5b6fc4302d7edaf14755d037.tar.xz |
scripting: make player error when attempting to load unknown scripts
It's ridiculous that --script=something.dumb does not cause an error.
Make it error, and extend this behavior to the scripts/ sub-dir in the
mpv config dir.
Diffstat (limited to 'player/scripting.c')
-rw-r--r-- | player/scripting.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/player/scripting.c b/player/scripting.c index c37f3af9ce..5f1ae5ce96 100644 --- a/player/scripting.c +++ b/player/scripting.c @@ -103,6 +103,9 @@ static void *script_thread(void *p) static int mp_load_script(struct MPContext *mpctx, const char *fname) { char *ext = mp_splitext(fname, NULL); + if (ext && strcasecmp(ext, "disable") == 0) + return 0; + const struct mp_scripting *backend = NULL; for (int n = 0; scripting_backends[n]; n++) { const struct mp_scripting *b = scripting_backends[n]; @@ -113,7 +116,7 @@ static int mp_load_script(struct MPContext *mpctx, const char *fname) } if (!backend) { - MP_VERBOSE(mpctx, "Can't load unknown script: %s\n", fname); + MP_ERR(mpctx, "Can't load unknown script: %s\n", fname); return -1; } @@ -211,16 +214,18 @@ void mp_load_builtin_scripts(struct MPContext *mpctx) load_builtin_script(mpctx, mpctx->opts->lua_load_console, "@console.lua"); } -void mp_load_scripts(struct MPContext *mpctx) +bool mp_load_scripts(struct MPContext *mpctx) { + bool ok = true; + // Load scripts from options char **files = mpctx->opts->script_files; for (int n = 0; files && files[n]; n++) { if (files[n][0]) - mp_load_user_script(mpctx, files[n]); + ok &= mp_load_user_script(mpctx, files[n]) >= 0; } if (!mpctx->opts->auto_load_scripts) - return; + return ok; // Load all scripts void *tmp = talloc_new(NULL); @@ -228,9 +233,11 @@ void mp_load_scripts(struct MPContext *mpctx) for (int i = 0; scriptsdir && scriptsdir[i]; i++) { files = list_script_files(tmp, scriptsdir[i]); for (int n = 0; files && files[n]; n++) - mp_load_script(mpctx, files[n]); + ok &= mp_load_script(mpctx, files[n]) >= 0; } talloc_free(tmp); + + return ok; } #if HAVE_CPLUGINS |