usage(): return success if -h is called && print more appropriate usage, opts can't be all called at the same time, that's why a separator is required

This commit is contained in:
raiz 2016-12-27 20:41:40 +03:00
parent d1dd72bae9
commit cfb4a5d3ff

View file

@ -70,7 +70,7 @@ static char *wifi_perc(const char *iface);
static char *wifi_essid(const char *iface); static char *wifi_essid(const char *iface);
static char *kernel_release(void); static char *kernel_release(void);
static void sighandler(const int signo); static void sighandler(const int signo);
static void usage(void); static void usage(int);
char *argv0; char *argv0;
char concat[]; char concat[];
@ -756,10 +756,10 @@ sighandler(const int signo)
} }
static void static void
usage(void) usage(int eval)
{ {
fprintf(stderr, "usage: %s [-dhov]\n", argv0); fprintf(stderr, "usage: %s [-d] [-o] [-v] [-h]\n", argv0);
exit(1); exit(eval);
} }
int int
@ -781,12 +781,14 @@ main(int argc, char *argv[])
case 'v': case 'v':
printf("slstatus %s (C) 2016 slstatus engineers\n", VERSION); printf("slstatus %s (C) 2016 slstatus engineers\n", VERSION);
return 0; return 0;
case 'h':
usage(0);
default: default:
usage(); usage(1);
} ARGEND } ARGEND
if (dflag && oflag) { if (dflag && oflag) {
usage(); usage(1);
} }
if (dflag && daemon(1, 1) < 0) { if (dflag && daemon(1, 1) < 0) {
err(1, "daemon"); err(1, "daemon");