diff --git a/core/mplayer.c b/core/mplayer.c index 3bbaaf43b4..ac597beac1 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -4711,16 +4711,20 @@ static int mpv_main(int argc, char *argv[]) print_libav_versions(); if (!parse_cfgfiles(mpctx, mpctx->mconfig)) - exit_player(mpctx, EXIT_NONE, 1); - - if (!m_config_parse_mp_command_line(mpctx->mconfig, mpctx->playlist, - argc, argv)) - { exit_player(mpctx, EXIT_ERROR, 1); + + int r = m_config_parse_mp_command_line(mpctx->mconfig, mpctx->playlist, + argc, argv); + if (r < 0) { + if (r <= M_OPT_EXIT) { + exit_player(mpctx, EXIT_NONE, 0); + } else { + exit_player(mpctx, EXIT_ERROR, 1); + } } if (handle_help_options(mpctx)) - exit_player(mpctx, EXIT_NONE, 1); + exit_player(mpctx, EXIT_NONE, 0); mp_msg(MSGT_CPLAYER, MSGL_V, "Configuration: " CONFIGURATION "\n"); mp_tmsg(MSGT_CPLAYER, MSGL_V, "Command line:"); diff --git a/core/parser-mpcmd.c b/core/parser-mpcmd.c index 25535582a2..3336fce027 100644 --- a/core/parser-mpcmd.c +++ b/core/parser-mpcmd.c @@ -118,9 +118,11 @@ static bool parse_flag(bstr name, bstr f) return !!val; } -bool m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, - int argc, char **argv) +// returns M_OPT_... error code +int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, + int argc, char **argv) { + int ret = M_OPT_UNKNOWN; int mode = 0; struct playlist_entry *local_start = NULL; bool shuffle = false; @@ -139,8 +141,10 @@ bool m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, int r; r = m_config_set_option_ext(config, p.arg, p.param, mode == LOCAL ? M_SETOPT_CHECK_ONLY : 0); - if (r <= M_OPT_EXIT) + if (r <= M_OPT_EXIT) { + ret = r; goto err_out; + } if (r < 0) { mp_tmsg(MSGT_CFGPARSER, MSGL_FATAL, "Setting commandline option --%.*s=%.*s failed.\n", @@ -276,15 +280,13 @@ bool m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, if (shuffle) playlist_shuffle(files); - talloc_free(local_params); - assert(!config->file_local_mode); - return true; + ret = 0; // success err_out: talloc_free(local_params); if (config->file_local_mode) m_config_leave_file_local(config); - return false; + return ret; } extern int mp_msg_levels[]; diff --git a/core/parser-mpcmd.h b/core/parser-mpcmd.h index 674903fe4d..256bc514b2 100644 --- a/core/parser-mpcmd.h +++ b/core/parser-mpcmd.h @@ -24,9 +24,9 @@ struct playlist; struct m_config; -bool m_config_parse_mp_command_line(struct m_config *config, - struct playlist *files, - int argc, char **argv); +int m_config_parse_mp_command_line(struct m_config *config, + struct playlist *files, + int argc, char **argv); void m_config_preparse_command_line(struct m_config *config, int argc, char **argv);