svn commit: r345365 - head/bin/date

Warner Losh imp at FreeBSD.org
Thu Mar 21 06:47:24 UTC 2019


Author: imp
Date: Thu Mar 21 06:47:23 2019
New Revision: 345365
URL: https://svnweb.freebsd.org/changeset/base/345365

Log:
  Remove -n flag, fix setting date / time
  
  r342139 bork setting the date. This fixes it by simply removing the -n
  flag.
  
  Differential Revision: https://reviews.freebsd.org/D19668

Modified:
  head/bin/date/date.1
  head/bin/date/date.c

Modified: head/bin/date/date.1
==============================================================================
--- head/bin/date/date.1	Thu Mar 21 06:31:14 2019	(r345364)
+++ head/bin/date/date.1	Thu Mar 21 06:47:23 2019	(r345365)
@@ -32,7 +32,7 @@
 .\"     @(#)date.1	8.3 (Berkeley) 4/28/95
 .\" $FreeBSD$
 .\"
-.Dd March 12, 2019
+.Dd March 20, 2019
 .Dt DATE 1
 .Os
 .Sh NAME
@@ -52,13 +52,13 @@
 .Ar ...
 .Op Cm + Ns Ar output_fmt
 .Nm
-.Op Fl jnu
+.Op Fl ju
 .Sm off
 .Op Oo Oo Oo Oo Ar cc Oc Ar yy Oc Ar mm Oc Ar dd Oc Ar HH
 .Ar MM Op Ar .ss
 .Sm on
 .Nm
-.Op Fl jnRu
+.Op Fl jRu
 .Fl f Ar input_fmt new_date
 .Op Cm + Ns Ar output_fmt
 .Nm
@@ -142,16 +142,6 @@ This allows you to use the
 flag in addition to the
 .Cm +
 option to convert one date format to another.
-.It Fl n
-By default, if the
-.Xr timed 8
-daemon is running,
-.Nm
-sets the time on all of the machines in the local group.
-The
-.Fl n
-option suppresses this behavior and causes the time to be set only on the
-current machine.
 .It Fl R
 Use RFC 2822 date and time output format.
 This is equivalent to using
@@ -431,23 +421,6 @@ can be used to parse the output from
 .Nm
 and express it in Epoch time.
 .Sh DIAGNOSTICS
-Occasionally, when
-.Xr timed 8
-synchronizes the time on many hosts, the setting of a new time value may
-require more than a few seconds.
-On these occasions,
-.Nm
-prints:
-.Ql Network time being set .
-The message
-.Ql Communication error with timed
-occurs when the communication
-between
-.Nm
-and
-.Xr timed 8
-fails.
-.Pp
 It is invalid to combine the
 .Fl I
 flag with either
@@ -465,8 +438,7 @@ and exits with an error status.
 .Xr gettimeofday 2 ,
 .Xr getutxent 3 ,
 .Xr strftime 3 ,
-.Xr strptime 3 ,
-.Xr timed 8
+.Xr strptime 3
 .Rs
 .%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
 .%A R. Gusella
@@ -478,7 +450,7 @@ The
 utility is expected to be compatible with
 .St -p1003.2 .
 The
-.Fl d , f , I , j , n , r , t ,
+.Fl d , f , I , j , r , t ,
 and
 .Fl v
 options are all extensions to the standard.

Modified: head/bin/date/date.c
==============================================================================
--- head/bin/date/date.c	Thu Mar 21 06:31:14 2019	(r345364)
+++ head/bin/date/date.c	Thu Mar 21 06:47:23 2019	(r345365)
@@ -72,7 +72,7 @@ static void iso8601_usage(const char *);
 static void multipleformats(void);
 static void printdate(const char *);
 static void printisodate(struct tm *);
-static void setthetime(const char *, const char *, int, int);
+static void setthetime(const char *, const char *, int);
 static void usage(void);
 
 static const struct iso8601_fmt {
@@ -92,7 +92,7 @@ int
 main(int argc, char *argv[])
 {
 	int ch, rflag;
-	bool Iflag, jflag, nflag, Rflag;
+	bool Iflag, jflag, Rflag;
 	const char *format;
 	char buf[1024];
 	char *fmt;
@@ -107,8 +107,8 @@ main(int argc, char *argv[])
 	fmt = NULL;
 	(void) setlocale(LC_TIME, "");
 	rflag = 0;
-	Iflag = jflag = nflag = Rflag = 0;
-	while ((ch = getopt(argc, argv, "f:I::jnRr:uv:")) != -1)
+	Iflag = jflag = Rflag = 0;
+	while ((ch = getopt(argc, argv, "f:I::jRr:uv:")) != -1)
 		switch((char)ch) {
 		case 'f':
 			fmt = optarg;
@@ -132,9 +132,6 @@ main(int argc, char *argv[])
 		case 'j':
 			jflag = 1;	/* don't set time */
 			break;
-		case 'n':		/* don't set network */
-			nflag = 1;
-			break;
 		case 'R':		/* RFC 2822 datetime format */
 			if (Iflag)
 				multipleformats();
@@ -179,7 +176,7 @@ main(int argc, char *argv[])
 	}
 
 	if (*argv) {
-		setthetime(fmt, *argv, jflag, nflag);
+		setthetime(fmt, *argv, jflag);
 		++argv;
 	} else if (fmt != NULL)
 		usage();
@@ -250,7 +247,7 @@ printisodate(struct tm *lt)
 #define	ATOI2(s)	((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0'))
 
 static void
-setthetime(const char *fmt, const char *p, int jflag, int nflag)
+setthetime(const char *fmt, const char *p, int jflag)
 {
 	struct utmpx utx;
 	struct tm *lt;
@@ -343,20 +340,17 @@ setthetime(const char *fmt, const char *p, int jflag, 
 		errx(1, "nonexistent time");
 
 	if (!jflag) {
-		/* set the time */
-		if (nflag) {
-			utx.ut_type = OLD_TIME;
-			memset(utx.ut_id, 0, sizeof(utx.ut_id));
-			(void)gettimeofday(&utx.ut_tv, NULL);
-			pututxline(&utx);
-			tv.tv_sec = tval;
-			tv.tv_usec = 0;
-			if (settimeofday(&tv, NULL) != 0)
-				err(1, "settimeofday (timeval)");
-			utx.ut_type = NEW_TIME;
-			(void)gettimeofday(&utx.ut_tv, NULL);
-			pututxline(&utx);
-		}
+		utx.ut_type = OLD_TIME;
+		memset(utx.ut_id, 0, sizeof(utx.ut_id));
+		(void)gettimeofday(&utx.ut_tv, NULL);
+		pututxline(&utx);
+		tv.tv_sec = tval;
+		tv.tv_usec = 0;
+		if (settimeofday(&tv, NULL) != 0)
+			err(1, "settimeofday (timeval)");
+		utx.ut_type = NEW_TIME;
+		(void)gettimeofday(&utx.ut_tv, NULL);
+		pututxline(&utx);
 
 		if ((p = getlogin()) == NULL)
 			p = "???";


More information about the svn-src-head mailing list