From: Sami Kerola Date: Tue, 6 Sep 2022 13:16:04 +0000 (+0100) Subject: ui: make interactive and non-interactive exit code the same X-Git-Tag: v0.96~29^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2a29fffb434ef5561e309ee2686d9de1f7f7338;p=thirdparty%2Fmtr.git ui: make interactive and non-interactive exit code the same Before this change the report gave successful exit value when destination hostname could not be found. $ ./mtr --report nxdomain. ; echo $? ./mtr: Failed to resolve host: nxdomain.: Name or service not known 0 Quickly looking 'git grep ---after-context if.*Interactive' there does not appear to be more than the two instances in main() where exit is called depending on interactive, so this change should cover all these cases. Reported-by: Marek Kroemeke Signed-off-by: Sami Kerola --- diff --git a/ui/mtr.c b/ui/mtr.c index e4a4041..5a70f31 100644 --- a/ui/mtr.c +++ b/ui/mtr.c @@ -710,6 +710,7 @@ int main( int argc, char **argv) { + int exit_val = EXIT_SUCCESS; names_t *names_head = NULL; names_t *names_walk; @@ -784,6 +785,7 @@ int main( if (ctl.Interactive) exit(EXIT_FAILURE); else { + exit_val = EXIT_FAILURE; names_walk = names_walk->next; continue; } @@ -794,6 +796,7 @@ int main( if (ctl.Interactive) exit(EXIT_FAILURE); else { + exit_val = EXIT_FAILURE; names_walk = names_walk->next; continue; } @@ -829,5 +832,5 @@ int main( item = NULL; } - return 0; + return exit_val; }