Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/usr.bin/at Pull up revision 1.18 (requested by kleink):



details:   https://anonhg.NetBSD.org/src/rev/dc06a0d1af9b
branches:  netbsd-1-5
changeset: 490610:dc06a0d1af9b
user:      he <he%NetBSD.org@localhost>
date:      Sat Feb 03 21:01:33 2001 +0000

description:
Pull up revision 1.18 (requested by kleink):
  Support the 1003.2-92 -t option.  Fixes PR#11205.
  For symmetry, extend -t to batch(1) as well.

diffstat:

 usr.bin/at/at.c |  42 +++++++++++++++++++++++++++++++++---------
 1 files changed, 33 insertions(+), 9 deletions(-)

diffs (101 lines):

diff -r a957865705c6 -r dc06a0d1af9b usr.bin/at/at.c
--- a/usr.bin/at/at.c   Sat Feb 03 21:01:17 2001 +0000
+++ b/usr.bin/at/at.c   Sat Feb 03 21:01:33 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: at.c,v 1.14.4.1 2000/06/26 00:40:38 simonb Exp $       */
+/*     $NetBSD: at.c,v 1.14.4.2 2001/02/03 21:01:33 he Exp $   */
 
 /*
  *  at.c : Put file into atrun queue
@@ -54,6 +54,7 @@
 #include "parsetime.h"
 #include "perm.h"
 #include "pathnames.h"
+#include "stime.h"
 #define MAIN
 #include "privs.h"
 
@@ -69,7 +70,7 @@
 #if 0
 static char rcsid[] = "$OpenBSD: at.c,v 1.15 1998/06/03 16:20:26 deraadt Exp $";
 #else
-__RCSID("$NetBSD: at.c,v 1.14.4.1 2000/06/26 00:40:38 simonb Exp $");
+__RCSID("$NetBSD: at.c,v 1.14.4.2 2001/02/03 21:01:33 he Exp $");
 #endif
 #endif
 
@@ -577,10 +578,11 @@
        int c;
        char queue = DEFAULT_AT_QUEUE;
        char queue_set = 0;
+       char time_set = 0;
        char *pgm;
 
-       int program = AT;               /* our default program */
-       char *options = "q:f:mvldbrVc"; /* default options for at */
+       int program = AT;                       /* our default program */
+       char *options = "q:f:t:mvldbrVc";       /* default options for at */
        int disp_version = 0;
        time_t timer;
 
@@ -603,7 +605,7 @@
                options = "V";
        } else if (strcmp(pgm, "batch") == 0) {
                program = BATCH;
-               options = "f:q:mvV";
+               options = "f:q:t:mvV";
        }
 
        /* process whatever options we can process */
@@ -632,6 +634,10 @@
 
                        queue_set = 1;
                        break;
+               case 't':       /* touch(1) date format */
+                       timer = stime(optarg);
+                       time_set = 1;
+                       break;
 
                case 'd':
                case 'r':
@@ -698,7 +704,17 @@
                break;
 
        case AT:
-               timer = parsetime(argc, argv);
+               if (argc > optind) {
+                       /* -t and timespec argument are mutually exclusive */
+                       if (time_set) {
+                               usage();
+                               exit(EXIT_FAILURE);
+                       } else {
+                               timer = parsetime(argc, argv);
+                               time_set = 1;
+                       }
+               }
+
                if (atverify) {
                        struct tm *tm = localtime(&timer);
                        (void)fprintf(stderr, "%s\n", asctime(tm));
@@ -712,10 +728,18 @@
                else
                        queue = DEFAULT_BATCH_QUEUE;
 
-               if (argc > optind)
-                       timer = parsetime(argc, argv);
-               else
+               if (argc > optind) {
+                       /* -t and timespec argument are mutually exclusive */
+                       if (time_set) {
+                               usage();
+                               exit(EXIT_FAILURE);
+                       } else {
+                               timer = parsetime(argc, argv);
+                               time_set = 1;
+                       }
+               } else if (!time_set) {
                        timer = time(NULL);
+               }
 
                if (atverify) {
                        struct tm *tm = localtime(&timer);



Home | Main Index | Thread Index | Old Index