summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-15 16:02:52 +0200
committerwm4 <wm4@nowhere>2013-05-15 16:02:52 +0200
commitd4987bf5ebc7f7830259326daf9dc1c685b34ac0 (patch)
tree07cd02a8904d818ed3c5b7916809713f2e8d5889 /core
parenta32cc6fcb2d76a396935ee8bddf2023c0f1196be (diff)
downloadmpv-d4987bf5ebc7f7830259326daf9dc1c685b34ac0.tar.bz2
mpv-d4987bf5ebc7f7830259326daf9dc1c685b34ac0.tar.xz
options: fix exit code when using help options
Basically a cosmetic change. Fixes github issue #88.
Diffstat (limited to 'core')
-rw-r--r--core/mplayer.c16
-rw-r--r--core/parser-mpcmd.c16
-rw-r--r--core/parser-mpcmd.h6
3 files changed, 22 insertions, 16 deletions
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);