Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/touch Recognize --date and --reference like gnu.



details:   https://anonhg.NetBSD.org/src/rev/0e0bb96da2b7
branches:  trunk
changeset: 782241:0e0bb96da2b7
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Oct 22 21:51:58 2012 +0000

description:
Recognize --date and --reference like gnu.

diffstat:

 usr.bin/touch/touch.1 |   6 ++++--
 usr.bin/touch/touch.c |  19 +++++++++++++++----
 2 files changed, 19 insertions(+), 6 deletions(-)

diffs (95 lines):

diff -r eff83ccbbffe -r 0e0bb96da2b7 usr.bin/touch/touch.1
--- a/usr.bin/touch/touch.1     Mon Oct 22 21:21:07 2012 +0000
+++ b/usr.bin/touch/touch.1     Mon Oct 22 21:51:58 2012 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: touch.1,v 1.21 2012/07/27 18:34:35 wiz Exp $
+.\"    $NetBSD: touch.1,v 1.22 2012/10/22 21:51:58 christos Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"     @(#)touch.1    8.3 (Berkeley) 4/28/95
 .\"
-.Dd July 24, 2012
+.Dd October 22, 2012
 .Dt TOUCH 1
 .Os
 .Sh NAME
@@ -66,6 +66,7 @@
 utility does not treat this as an error.
 No error messages are displayed and the exit value is not affected.
 .It Fl d Ar human-datetime
+.It Fl Fl date Ar human-datetime
 Parse
 .Ar human-datetime
 using the human datetime parser
@@ -84,6 +85,7 @@
 .Fl a
 flag is also specified.
 .It Fl r Ar file
+.It Fl Fl reference Ar file
 Use the access and modifications times from
 .Ar file
 instead of the current time of day.
diff -r eff83ccbbffe -r 0e0bb96da2b7 usr.bin/touch/touch.c
--- a/usr.bin/touch/touch.c     Mon Oct 22 21:21:07 2012 +0000
+++ b/usr.bin/touch/touch.c     Mon Oct 22 21:51:58 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: touch.c,v 1.31 2012/07/25 01:23:46 christos Exp $      */
+/*     $NetBSD: touch.c,v 1.32 2012/10/22 21:51:58 christos Exp $      */
 
 /*
  * Copyright (c) 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)touch.c    8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: touch.c,v 1.31 2012/07/25 01:23:46 christos Exp $");
+__RCSID("$NetBSD: touch.c,v 1.32 2012/10/22 21:51:58 christos Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -57,6 +57,7 @@
 #include <tzfile.h>
 #include <unistd.h>
 #include <util.h>
+#include <getopt.h>
 
 static void    stime_arg0(char *, struct timeval *);
 static void    stime_arg1(char *, struct timeval *);
@@ -64,6 +65,15 @@
 static void    stime_file(char *, struct timeval *);
 __dead static void     usage(void);
 
+struct option touch_longopts[] = {
+       { "date",               required_argument,      0,
+                                               'd' },
+       { "reference",          required_argument,      0,
+                                               'r' },
+       { NULL,                 0,                      0,
+                                               0 },
+};
+
 int
 main(int argc, char *argv[])
 {
@@ -80,7 +90,8 @@
        if (gettimeofday(&tv[0], NULL))
                err(1, "gettimeofday");
 
-       while ((ch = getopt(argc, argv, "acd:fhmr:t:")) != -1)
+       while ((ch = getopt_long(argc, argv, "acd:fhmr:t:", touch_longopts,
+           NULL)) != -1)
                switch(ch) {
                case 'a':
                        aflag = 1;
@@ -320,7 +331,7 @@
 usage(void)
 {
        (void)fprintf(stderr,
-           "Usage: %s [-acfhm] [-d datetime] [-r file] [-t time] file ...\n",
+           "Usage: %s [-acfhm] [-d|--date datetime] [-r|--reference file] [-t time] file ...\n",
            getprogname());
        exit(EXIT_FAILURE);
 }



Home | Main Index | Thread Index | Old Index