Skip to content

Commit 9d64dec

Browse files
committed
compton -h should quit after printing help
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
1 parent 83eff25 commit 9d64dec

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/options.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <stdlib.h>
99
#include <string.h>
1010
#include <unistd.h>
11-
#include <xcb/render.h> // for xcb_render_fixed_t, XXX
11+
#include <xcb/render.h> // for xcb_render_fixed_t, XXX
1212

1313
#include "common.h"
1414
#include "config.h"
@@ -20,7 +20,7 @@
2020
#pragma GCC diagnostic error "-Wunused-parameter"
2121

2222
/**
23-
* Print usage text and exit.
23+
* Print usage text.
2424
*/
2525
static void usage(int ret) {
2626
#define WARNING_DISABLED " (DISABLED AT COMPILE TIME)"
@@ -479,25 +479,27 @@ bool get_early_config(int argc, char *const *argv, char **config_file, bool *all
479479
// arguments
480480
optind = 1;
481481
*config_file = NULL;
482+
*exit_code = 0;
482483
while (-1 != (o = getopt_long(argc, argv, shortopts, longopts, &longopt_idx))) {
483484
if (o == 256) {
484485
*config_file = strdup(optarg);
486+
} else if (o == 'h') {
487+
usage(0);
488+
return true;
485489
} else if (o == 'd') {
486490
log_warn("-d will be ignored, please use the DISPLAY "
487491
"environment variable");
488492
} else if (o == 314) {
489493
*all_xerrors = true;
490494
} else if (o == 318) {
491495
printf("%s\n", COMPTON_VERSION);
492-
*exit_code = 0;
493496
return true;
494497
} else if (o == 'S') {
495498
log_warn("-S will be ignored");
496499
} else if (o == 320) {
497500
log_warn("--no-name-pixmap will be ignored");
498501
} else if (o == '?' || o == ':') {
499502
usage(1);
500-
*exit_code = 1;
501503
return true;
502504
}
503505
}

0 commit comments

Comments
 (0)