]> granicus.if.org Git - cronie/commitdiff
all: add version printing option -V
authorSami Kerola <kerolasa@iki.fi>
Sun, 11 Jun 2017 13:53:44 +0000 (14:53 +0100)
committerTomáš Mráz <t8m@users.noreply.github.com>
Mon, 10 Jul 2017 16:13:14 +0000 (18:13 +0200)
Also mention the option in usage() and manual pages.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
anacron/main.c
man/cron.8
man/cronnext.1
man/crontab.1
src/cron.c
src/cronnext.c
src/crontab.c

index 37475131e959a15dcc2a740deb47c5764a322a12..58d1b567c846351a16759ac6e4bb3a8cb8b70bbe 100644 (file)
@@ -22,6 +22,7 @@
     `COPYING' that comes with the Anacron source distribution.
 */
 
+#include "config.h"
 
 #include <time.h>
 #include <sys/time.h>
@@ -66,13 +67,13 @@ int preferred_hour = -1;
 static void
 print_version(void)
 {
-    printf("Anacron \n"
+    printf("Anacron from project %s\n"
           "Copyright (C) 1998  Itai Tzur <itzur@actcom.co.il>\n"
           "Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh@debian.org>\n"
           "Copyright (C) 2004  Pascal Hakim <pasc@redellipse.net>\n"
           "\n"
           "Mail comments, suggestions and bug reports to <pasc@redellipse.net>."
-          "\n\n");
+          "\n\n", PACKAGE_STRING);
 }
 
 static void
index 633dbc04bac700f7f9f83a0644b2249ddd2773cd..0a6cc876026816282292c5e9fe820e9719ddcf4c 100644 (file)
@@ -32,6 +32,9 @@ crond \- daemon to execute scheduled commands
 .B crond
 .B -x
 .RB [ext,sch,proc,pars,load,misc,test,bit]
+.br
+.B crond
+.B -V
 .SH DESCRIPTION
 .I Cron
 is started from
@@ -188,6 +191,9 @@ installed or if mail is disabled.
 .TP
 .B "\-x"
 This option allows you to set debug flags.
+.TP
+.B "\-V"
+Print version and exit.
 .SH SIGNALS
 When the
 .I SIGHUP
index 3edb0f24d9dfea26d863c4fc3aa9a8eeaaf81ce7..7d324b49d8c1c6efe74f8cb660e67dbccf3b38eb 100644 (file)
@@ -4,7 +4,7 @@ cronnext \- time of next job cron will execute
 .SH SYNOPSIS
 .TP 9
 .B cronnext
-[-i users] [-e users] [-s] [-t time] [-v] [-h]
+[-i users] [-e users] [-s] [-t time] [-v] [-h] [-V]
 .SH DESCRIPTION
 Determine the time cron will execute the next job.
 Without arguments, it prints that time considering all crontabs,
@@ -40,6 +40,9 @@ Epoch and in the standard format
 .TP
 -h
 summary of options
+.TP
+-V
+Print version and exit.
 .SH AUTHOR
 Marco Migliori <sgerwk@aol.com>
 .SH SEE ALSO
index a04cbe085e8291b95fdbd9d92154b4333fadb30a..7d387e22887e54578613501e36f15b54c38fb6ca 100644 (file)
@@ -42,6 +42,9 @@ crontab \- maintains crontab files for individual users
 .br
 .B crontab
 .BR -c
+.br
+.B crontab
+.BR -V
 .SH DESCRIPTION
 .I Crontab
 is the program used to install a crontab table
@@ -178,6 +181,9 @@ files in the directory
 , as set using the
 .B \-n
 option.
+.TP
+.B "\-V"
+Print version and exit.
 .SH "SEE ALSO"
 .BR crontab (5),
 .BR cron (8)
index 4c18dc06f6ae682c067b2fbc39c1d09de569a135..558c7013f6552530659f574c2a27bbf6fcbc4b24 100644 (file)
@@ -188,6 +188,7 @@ static void usage(void) {
        fprintf(stderr, " -P         use PATH=\"%s\"\n", _PATH_DEFPATH);
        fprintf(stderr, " -c         enable clustering support\n");
        fprintf(stderr, " -s         log into syslog instead of sending mails\n");
+       fprintf(stderr, " -V         print version and exit\n");
        fprintf(stderr, " -x <flag>  print debug information\n");
        fprintf(stderr, "\n");
        fprintf(stderr, "Debugging flags are: ");
@@ -688,7 +689,7 @@ static void sigchld_reaper(void) {
 static void parse_args(int argc, char *argv[]) {
        int argch;
 
-       while (-1 != (argch = getopt(argc, argv, "hnpsiPx:m:c"))) {
+       while (-1 != (argch = getopt(argc, argv, "hnpsiPx:m:cV"))) {
                switch (argch) {
                        case 'x':
                                if (!set_debug_flags(optarg))
@@ -715,6 +716,9 @@ static void parse_args(int argc, char *argv[]) {
                        case 'c':
                                EnableClustering = 1;
                                break;
+                       case 'V':
+                               puts(PACKAGE_STRING);
+                               exit(EXIT_SUCCESS);
                        case 'h':
                        default:
                                usage();
index b4608505f9f3e2789bcc75d6a1410ad804e05e9f..3659b6e8bc6b6eba903bd3a71e29ad8a97f766d8 100644 (file)
@@ -257,6 +257,7 @@ void usage() {
        fprintf(stderr, " -t time   start from this time (seconds since epoch)\n");
        fprintf(stderr, " -v        verbose mode\n");
        fprintf(stderr, " -h        this help\n");
+       fprintf(stderr, " -V        print version and exit\n");
 }
 
 /*
@@ -274,7 +275,7 @@ int main(int argn, char *argv[]) {
        start = time(NULL);
        verbose = 0;
 
-       while (-1 != (opt = getopt(argn, argv, "i:e:st:vh"))) {
+       while (-1 != (opt = getopt(argn, argv, "i:e:st:vhV"))) {
                switch (opt) {
                case 'i':
                        include = optarg;
@@ -294,6 +295,9 @@ int main(int argn, char *argv[]) {
                case 'h':
                        usage();
                        return EXIT_SUCCESS;
+               case 'V':
+                       puts(PACKAGE_STRING);
+                       return EXIT_SUCCESS;
                default:
                        fprintf(stderr, "unrecognized option: %s\n",
                                argv[optind - 1]);
index c14255287489e957cee893969597b685e7ccab66..5916c7806f0e99733e03e06dd0e72cf21263c9b6 100644 (file)
@@ -72,15 +72,15 @@ enum opt_t {opt_unknown, opt_list, opt_delete, opt_edit, opt_replace, opt_hostse
 static const char *Options[] = {"???", "list", "delete", "edit", "replace", "hostset", "hostget"};
 
 # ifdef WITH_SELINUX
-static const char *getoptargs = "u:lerisncx:";
+static const char *getoptargs = "u:lerisncx:V";
 # else
-static const char *getoptargs = "u:lerincx:";
+static const char *getoptargs = "u:lerincx:V";
 # endif
 #else
 # ifdef WITH_SELINUX
-static const char *getoptargs = "u:lerisnc";
+static const char *getoptargs = "u:lerisncV";
 # else
-static const char *getoptargs = "u:lerinc";
+static const char *getoptargs = "u:lerincV";
 # endif
 #endif
 #ifdef WITH_SELINUX
@@ -125,6 +125,7 @@ static void usage(const char *msg) {
 #ifdef WITH_SELINUX
        fprintf(stderr, " -s         selinux context\n");
 #endif
+       fprintf(stderr, " -V         print version and exit\n");
 #ifdef DEBUGGING
        fprintf(stderr, " -x <mask>  enable debugging\n");
 #endif
@@ -317,6 +318,9 @@ static void parse_args(int argc, char *argv[]) {
                        }
                        Option = opt_hostget;
                        break;
+               case 'V':
+                       puts(PACKAGE_STRING);
+                       exit(EXIT_SUCCESS);
                default:
                        usage("unrecognized option");
                }