Skip to content

Commit

Permalink
Standardize version output
Browse files Browse the repository at this point in the history
Changes:

* Only print the version line in the print_version function
* Add a print_version function where missing (put it in usage.c if the
  file exists)
* Always a blank line after the version
  • Loading branch information
kmk3 committed May 14, 2023
1 parent b84495b commit 727da58
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/firecfg/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ static char *usage_str =
"License GPL version 2 or later\n"
"Homepage: https://firejail.wordpress.com\n\n";

static void usage(void) {
static void print_version(void) {
printf("firecfg version %s\n\n", VERSION);
puts(usage_str);
}

static void usage(void) {
print_version();
puts(usage_str);
}

static void list(void) {
DIR *dir = opendir(arg_bindir);
Expand Down Expand Up @@ -364,7 +367,7 @@ int main(int argc, char **argv) {
else if (strcmp(argv[i], "--debug") == 0)
arg_debug = 1;
else if (strcmp(argv[i], "--version") == 0) {
printf("firecfg version %s\n\n", VERSION);
print_version();
return 0;
}
else if (strcmp(argv[i], "--clean") == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/firemon/firemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ int main(int argc, char **argv) {
return 0;
}
else if (strcmp(argv[i], "--version") == 0) {
printf("firemon version %s\n\n", VERSION);
print_version();
return 0;
}
else if (strcmp(argv[i], "--debug") == 0)
Expand Down
1 change: 1 addition & 0 deletions src/firemon/firemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void firemon_sleep(int st);
void procevent(pid_t pid) __attribute__((noreturn));

// usage.c
void print_version(void);
void usage(void);

// top.c
Expand Down
6 changes: 5 additions & 1 deletion src/firemon/usage.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ static char *help_str =
"Homepage: https://firejail.wordpress.com\n"
"\n";

void print_version(void) {
printf("firemon version %s\n\n", VERSION);
}

void usage(void) {
printf("firemon version %s\n", VERSION);
print_version();
puts(help_str);
}
7 changes: 5 additions & 2 deletions src/jailcheck/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ static char *usage_str =
" --help, -? - this help screen.\n"
" --version - print program version and exit.\n";

static void print_version(void) {
printf("jailcheck version %s\n\n", VERSION);
}

static void usage(void) {
printf("jailcheck version %s\n\n", VERSION);
print_version();
puts(usage_str);
}

Expand All @@ -62,7 +65,7 @@ int main(int argc, char **argv) {
return 0;
}
else if (strcmp(argv[i], "--version") == 0) {
printf("firetest version %s\n\n", VERSION);
print_version();
return 0;
}
else if (strncmp(argv[i], "--hello=", 8) == 0) { // used by noexec test
Expand Down

0 comments on commit 727da58

Please sign in to comment.