The C standard specifies two constants, EXIT_SUCCESS and EXIT_FAILURE, that may be passed to exit() to indicate successful or unsuccessful termination, respectively. The value of status in exit(status) may be EXIT_SUCCESS, EXIT_FAILURE, or any other value, though only the least significant 8 bits (that is, status & 0377) shall be available to a waiting parent proces. So exit(-1) return 255. Use the C standard EXIT_SUCCESS and EXIT_FAILURE to indicate the program exit status instead of "0" or "1", respectively. In <stdlib.h> EXIT_FAILURE has the value "1": use EXIT_FAILURE even if the program uses exit(-1), ie 255, for consistency. Signed-off-by: Elia Pinto <gitter.spiros@xxxxxxxxx> --- git.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/git.c b/git.c index a25940d72e..7b75e6e720 100644 --- a/git.c +++ b/git.c @@ -158,20 +158,20 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) else { puts(git_exec_path()); trace2_cmd_name("_query_"); - exit(0); + exit(EXIT_SUCCESS); } } else if (!strcmp(cmd, "--html-path")) { puts(system_path(GIT_HTML_PATH)); trace2_cmd_name("_query_"); - exit(0); + exit(EXIT_SUCCESS); } else if (!strcmp(cmd, "--man-path")) { puts(system_path(GIT_MAN_PATH)); trace2_cmd_name("_query_"); - exit(0); + exit(EXIT_SUCCESS); } else if (!strcmp(cmd, "--info-path")) { puts(system_path(GIT_INFO_PATH)); trace2_cmd_name("_query_"); - exit(0); + exit(EXIT_SUCCESS); } else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) { use_pager = 1; } else if (!strcmp(cmd, "-P") || !strcmp(cmd, "--no-pager")) { @@ -318,7 +318,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) for (i = 0; i < list.nr; i++) printf("%s ", list.items[i].string); string_list_clear(&list, 0); - exit(0); + exit(EXIT_SUCCESS); } else { exit(list_cmds(cmd)); } @@ -900,7 +900,7 @@ int cmd_main(int argc, const char **argv) printf(_("usage: %s\n\n"), git_usage_string); list_common_cmds_help(); printf("\n%s\n", _(git_more_info_string)); - exit(1); + exit(EXIT_FAILURE); } cmd = argv[0]; @@ -920,7 +920,7 @@ int cmd_main(int argc, const char **argv) fprintf(stderr, _("expansion of alias '%s' failed; " "'%s' is not a git command\n"), cmd, argv[0]); - exit(1); + exit(EXIT_FAILURE); } if (!done_help) { cmd = argv[0] = help_unknown_cmd(cmd); -- 2.35.1