Skip to content

Commit 0a6889d

Browse files
committed
cleanup output
only print the requested information. when running with -V simply print the version and exit. when running with -h only print help and exit
1 parent 822aac6 commit 0a6889d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/naemon/naemon.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ int main(int argc, char **argv)
125125
{
126126
int result;
127127
int error = FALSE;
128+
int display_version = FALSE;
128129
int display_license = FALSE;
129130
int display_help = FALSE;
130131
int c = 0;
@@ -161,7 +162,7 @@ int main(int argc, char **argv)
161162

162163
/* get all command line arguments */
163164
while (1) {
164-
c = getopt(argc, argv, "+hVvdspuxTW");
165+
c = getopt(argc, argv, "+hLVvdspuxTW");
165166

166167
if (c == -1 || c == EOF)
167168
break;
@@ -174,6 +175,10 @@ int main(int argc, char **argv)
174175
break;
175176

176177
case 'V': /* version */
178+
display_version = TRUE;
179+
break;
180+
181+
case 'L': /* license */
177182
display_license = TRUE;
178183
break;
179184

@@ -238,17 +243,18 @@ int main(int argc, char **argv)
238243
exit(nm_core_worker(worker_socket));
239244
}
240245

241-
if (daemon_mode == FALSE) {
242-
printf("\nNaemon Core " VERSION "\n");
246+
if (display_version == TRUE) {
247+
printf("Naemon Core " VERSION "\n");
248+
249+
exit(OK);
250+
}
251+
252+
if (display_license == TRUE) {
243253
printf("Copyright (c) 2013-present Naemon Core Development Team and Community Contributors\n");
244254
printf("Copyright (c) 2009-2013 Nagios Core Development Team and Community Contributors\n");
245255
printf("Copyright (c) 1999-2009 Ethan Galstad\n");
246-
printf("License: GPL\n\n");
256+
printf("License: GPLv2\n\n");
247257
printf("Website: https://www.naemon.io\n");
248-
}
249-
250-
/* just display the license */
251-
if (display_license == TRUE) {
252258

253259
printf("This program is free software; you can redistribute it and/or modify\n");
254260
printf("it under the terms of the GNU General Public License version 2 as\n");

0 commit comments

Comments
 (0)