On Mon, 2011-02-07 at 21:37 -0300, Eduardo Silva wrote:
> When passing an invalid option to monkey we should be returning an
> EXIT_FAILURE code indicating the wrong status.

Weird, attached is a fresh new patch. thanks.
>From fe403137f4b5d244845095e742b1a38f5488e49d Mon Sep 17 00:00:00 2001
From: Davidlohr Bueso <[email protected]>
Date: Tue, 8 Feb 2011 11:10:26 -0300
Subject: [PATCH] When passing an invalid option to monkey we should be returning an EXIT_FAILURE code indicating the wrong status.

Signed-off-by: Davidlohr Bueso <[email protected]>
---
 src/monkey.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/monkey.c b/src/monkey.c
index 17e7406..79ed6d1 100644
--- a/src/monkey.c
+++ b/src/monkey.c
@@ -86,7 +86,7 @@ void mk_version()
     fflush(stdout);
 }
 
-void mk_help()
+void mk_help(int rc)
 {
     printf("Usage : monkey [-c directory] [-D] [-v] [-h]\n\n");
     printf("%sAvailable options%s\n", ANSI_BOLD, ANSI_RESET);
@@ -96,7 +96,8 @@ void mk_help()
     printf("  -h, --help\t\tprint this help\n\n");
     printf("%sDocumentation%s\n", ANSI_BOLD, ANSI_RESET);
     printf("  http://www.monkey-project.com/documentation\n\n";);
-    exit(EXIT_SUCCESS);
+
+    exit(rc);
 }
 
 /* MAIN */
@@ -123,10 +124,8 @@ int main(int argc, char **argv)
         case 'v':
             mk_version();
             exit(EXIT_SUCCESS);
-            break;
         case 'h':
-            mk_help();
-            break;
+            mk_help(EXIT_SUCCESS);
         case 'D':
             config->is_daemon = VAR_ON;
             break;
@@ -137,8 +136,7 @@ int main(int argc, char **argv)
             }
         case '?':
             printf("Monkey: Invalid option or option needs an argument.\n");
-            mk_help();
-            break;
+            mk_help(EXIT_FAILURE);
         }
     }
 
-- 
1.7.1

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to