diff --git a/util/face-options.hh b/util/face-options.hh index 8bec009a8..347cece1a 100644 --- a/util/face-options.hh +++ b/util/face-options.hh @@ -110,6 +110,7 @@ face_options_t::post_parse (GError **error) { g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, "%s: Failed loading font face", font_path); + return_value = RETURN_VALUE_FACE_LOAD_FAILED; return; } } diff --git a/util/font-options.hh b/util/font-options.hh index 8c7ce1c51..9f3be7ebf 100644 --- a/util/font-options.hh +++ b/util/font-options.hh @@ -110,6 +110,7 @@ font_options_t::post_parse (GError **error) { if (!hb_font_set_funcs_using (font, font_funcs)) { + return_value = RETURN_VALUE_FONT_FUNCS_FAILED; const char **supported_font_funcs = hb_font_list_funcs (); if (unlikely (!supported_font_funcs[0])) { diff --git a/util/main-font-text.hh b/util/main-font-text.hh index ca39c5a47..751515fa7 100644 --- a/util/main-font-text.hh +++ b/util/main-font-text.hh @@ -43,6 +43,7 @@ struct main_font_text_t : int operator () (int argc, char **argv) { add_options (); + parse (&argc, &argv); this->init (this); @@ -52,7 +53,10 @@ struct main_font_text_t : this->finish (this); - return this->failed ? 1 : 0; + if (this->failed && return_value == RETURN_VALUE_SUCCESS) + return_value = RETURN_VALUE_OPERATION_FAILED; + + return return_value; } protected: diff --git a/util/options.hh b/util/options.hh index 07212be13..29e49d381 100644 --- a/util/options.hh +++ b/util/options.hh @@ -54,6 +54,14 @@ #include +enum return_value_t +{ + RETURN_VALUE_SUCCESS = 0, + RETURN_VALUE_OPTION_PARSING_FAILED = 1, + RETURN_VALUE_FACE_LOAD_FAILED = 2, + RETURN_VALUE_OPERATION_FAILED = 3, + RETURN_VALUE_FONT_FUNCS_FAILED = 4, +} return_value = RETURN_VALUE_SUCCESS; static inline void fail (hb_bool_t suggest_help, const char *format, ...) G_GNUC_NORETURN G_GNUC_PRINTF (2, 3); @@ -71,7 +79,10 @@ fail (hb_bool_t suggest_help, const char *format, ...) if (suggest_help) g_printerr ("Try `%s --help' for more information.\n", prgname); - exit (1); + if (return_value == RETURN_VALUE_SUCCESS) + return_value = RETURN_VALUE_OPTION_PARSING_FAILED; + + exit (return_value); } struct option_parser_t