The user requesting usage or version information is not an error.

Signed-off-by: Andrew Gregory <[email protected]>
---

Expanded patch to include pacsort.  All other utilities already exit 0.

 src/pacman/pacman.c            | 4 ++--
 src/util/pacsort.c             | 9 ++++++++-
 test/pacman/tests/pacman001.py | 2 +-
 test/pacman/tests/pacman002.py | 2 +-
 test/pacman/tests/pacman003.py | 2 +-
 5 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 7144339..8c76987 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -889,11 +889,11 @@ static int parseargs(int argc, char *argv[])
        }
        if(config->help) {
                usage(config->op, mbasename(argv[0]));
-               return 2;
+               cleanup(0);
        }
        if(config->version) {
                version();
-               return 2;
+               cleanup(0);
        }
 
        /* parse all other options */
diff --git a/src/util/pacsort.c b/src/util/pacsort.c
index 948b03d..2d53a1c 100644
--- a/src/util/pacsort.c
+++ b/src/util/pacsort.c
@@ -45,6 +45,7 @@ static struct options_t {
        int sortkey;
        int null;
        int filemode;
+       int help;
        char delim;
 } opts;
 
@@ -374,7 +375,8 @@ static int parse_options(int argc, char **argv)
                                opts.filemode = 1;
                                break;
                        case 'h':
-                               return 1;
+                               opts.help = 1;
+                               return 0;
                        case 'k':
                                opts.sortkey = (int)strtol(optarg, NULL, 10);
                                if(opts.sortkey <= 0) {
@@ -420,6 +422,11 @@ int main(int argc, char *argv[])
                return 2;
        }
 
+       if(opts.help) {
+               usage();
+               return 0;
+       }
+
        list = list_new(100);
        buffer = buffer_new(BUFSIZ * 3);
 
diff --git a/test/pacman/tests/pacman001.py b/test/pacman/tests/pacman001.py
index d467e3f..1d3a36a 100644
--- a/test/pacman/tests/pacman001.py
+++ b/test/pacman/tests/pacman001.py
@@ -2,4 +2,4 @@
 
 self.args = "--version"
 
-self.addrule("PACMAN_RETCODE=2")
+self.addrule("PACMAN_RETCODE=0")
diff --git a/test/pacman/tests/pacman002.py b/test/pacman/tests/pacman002.py
index c021725..2add614 100644
--- a/test/pacman/tests/pacman002.py
+++ b/test/pacman/tests/pacman002.py
@@ -2,4 +2,4 @@
 
 self.args = "--help"
 
-self.addrule("PACMAN_RETCODE=2")
+self.addrule("PACMAN_RETCODE=0")
diff --git a/test/pacman/tests/pacman003.py b/test/pacman/tests/pacman003.py
index b527594..a80e2d6 100644
--- a/test/pacman/tests/pacman003.py
+++ b/test/pacman/tests/pacman003.py
@@ -2,4 +2,4 @@
 
 self.args = "-S --help"
 
-self.addrule("PACMAN_RETCODE=2")
+self.addrule("PACMAN_RETCODE=0")
-- 
1.8.5.3


Reply via email to