From bf3ae2166fbe20831bc42e4778fa2ff6cd32bb78 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 15 Mar 2016 09:17:44 -0400 Subject: [PATCH] main: EXIT_SUCCESS with --help I was actually trying to do a simple test of `--help` and was surprised that we `exit (1)` by default there. Only do that if we actually fail to parse options. Pull request: #21 Approved by: alexlarsson --- bubblewrap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bubblewrap.c b/bubblewrap.c index 0a68718..68acd63 100644 --- a/bubblewrap.c +++ b/bubblewrap.c @@ -126,7 +126,7 @@ lock_file_new (const char *path) static void -usage () +usage (int ecode) { fprintf (stderr, "usage: %s [OPTIONS...] COMMAND [ARGS...]\n\n", argv0); @@ -157,7 +157,7 @@ usage () " --symlink SRC DEST Create symlink at DEST with target SRC\n" " --seccomp FD Load and use seccomp rules from FD\n" ); - exit (1); + exit (ecode); } static void @@ -792,7 +792,7 @@ parse_args (int *argcp, const char *arg = argv[0]; if (strcmp (arg, "--help") == 0) - usage (); + usage (EXIT_SUCCESS); else if (strcmp (arg, "--version") == 0) { printf ("%s\n", PACKAGE_STRING); @@ -1142,7 +1142,7 @@ main (int argc, argc--; if (argc == 0) - usage (); + usage (EXIT_FAILURE); parse_args (&argc, &argv); @@ -1150,7 +1150,7 @@ main (int argc, die ("bubblewrap is not privileged, --share-user not supported"); if (argc == 0) - usage (); + usage (EXIT_FAILURE); __debug__(("Creating root mount point\n"));