Restore the -n flag parsing, but ignore it.

Since D19668 was done, new users of the -n flag have surfaced. Parse
and ignore it on the command line until they can be updated.

Suggested by: rgrimes (in D19668).
This commit is contained in:
Warner Losh 2019-04-24 05:24:10 +00:00
parent b106e0fccc
commit 8b82def341
2 changed files with 7 additions and 3 deletions

View File

@ -32,7 +32,7 @@
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
.\" $FreeBSD$
.\"
.Dd March 20, 2019
.Dd April 23, 2019
.Dt DATE 1
.Os
.Sh NAME
@ -40,7 +40,7 @@
.Nd display or set date and time
.Sh SYNOPSIS
.Nm
.Op Fl jRu
.Op Fl jnRu
.Op Fl r Ar seconds | Ar filename
.Oo
.Fl v
@ -142,6 +142,8 @@ This allows you to use the
flag in addition to the
.Cm +
option to convert one date format to another.
.It Fl n
Obsolete flag, accepted and ignored for compatibility.
.It Fl R
Use RFC 2822 date and time output format.
This is equivalent to using

View File

@ -108,7 +108,7 @@ main(int argc, char *argv[])
(void) setlocale(LC_TIME, "");
rflag = 0;
Iflag = jflag = Rflag = 0;
while ((ch = getopt(argc, argv, "f:I::jRr:uv:")) != -1)
while ((ch = getopt(argc, argv, "f:I::jnRr:uv:")) != -1)
switch((char)ch) {
case 'f':
fmt = optarg;
@ -132,6 +132,8 @@ main(int argc, char *argv[])
case 'j':
jflag = 1; /* don't set time */
break;
case 'n':
break;
case 'R': /* RFC 2822 datetime format */
if (Iflag)
multipleformats();