Tiiffi/mcrcon

'no password' condition needs an error code instead of success

SecretAgentOne opened this issue · 0 comments

When no password is provided (either by -P or by MCRCON_PASS environment), mcrcon fails to perform the requested action but has a success return code. Instead the program should return EXIT_FAILURE. Below is a patch.

:~/git/mcrcon$ git diff HEAD^
diff --git a/mcrcon.c b/mcrcon.c
index 79c8aba..d3c8874 100644
--- a/mcrcon.c
+++ b/mcrcon.c
@@ -209,7 +209,7 @@ int main(int argc, char *argv[])
 
        if (pass == NULL) {
                puts("You must give password (-p password).\nTry 'mcrcon -h' or 'man mcrcon' for help.");
-               return 0;
+               exit(EXIT_FAILURE);
        }
 
        if(optind == argc && terminal_mode == 0)