Source-Changes-HG archive

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

[src/trunk]: src/sbin/shutdown Bring shutdown(8) into the 21st century.



details:   https://anonhg.NetBSD.org/src/rev/4ca0d27f149c
branches:  trunk
changeset: 368247:4ca0d27f149c
user:      kre <kre%NetBSD.org@localhost>
date:      Fri Jul 01 16:45:12 2022 +0000

description:
Bring shutdown(8) into the 21st century.

I found this juxtaposition in the shutdown man page kind of
interesting:

     time  Time is the time at which shutdown will bring the system down
           and may be the word now or a future time in one of two formats:
           ... [2nd format:] [[[[[cc]yy]mm]dd]hh]mm,  ...
           If the century [cc] is not specified, it defaults to 1900 for
           years [yy] between 69 and 99, ...

In that, all the "[text]" except the one "[[[[["(etc) sequence are my
interjections, The ellipses ("...") represent where I omitted irrelevant
(for here) text.

Interesting yes, bizarre also.   Requiring a future time, and then
defaulting to the (long gone) 20th century (for any random year)
makes no sense at all.    So I fixed it.

In another hundred years or so, anytime from 2100 onwards, but best
left at least a decade into the new century, it will need altering again.
[One could write the code to automate this adjustment, but the man
page would still need updating.]   More significant changes will be
needed as the 101st century approaches (years 10000 and beyond), as
then a 2 digit century will no longer be adequate.   Call me then, and
if I'm able, I'll fix it.

If someone really has a need to schedule a shutdown for sometime
between 1969 and 1999 that can still be done by explicitly giving
the "19" cc value.  It is just no longer ever the default.

Otherwise, now, years 20..90 mean the 21st century (2020..2099)
(the first 2 of those are already unusable, but, IMO, that's OK)
and years 00..19 mean the 22nd century (2100..2119) (except that
00, 2100, is still technically the final year of the 21st century).

This is advance planning for near the end of the 21st century when
someone wants to schedule a shutdown for early in the following
century, and can't be bothered typing the 2 century digits.

diffstat:

 sbin/shutdown/shutdown.8 |  17 +++++++++++------
 sbin/shutdown/shutdown.c |  10 +++++-----
 2 files changed, 16 insertions(+), 11 deletions(-)

diffs (77 lines):

diff -r 605559bfec0d -r 4ca0d27f149c sbin/shutdown/shutdown.8
--- a/sbin/shutdown/shutdown.8  Fri Jul 01 09:54:36 2022 +0000
+++ b/sbin/shutdown/shutdown.8  Fri Jul 01 16:45:12 2022 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: shutdown.8,v 1.33 2016/09/14 00:16:31 kre Exp $
+.\"    $NetBSD: shutdown.8,v 1.34 2022/07/01 16:45:12 kre Exp $
 .\"
 .\" Copyright (c) 1988, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)shutdown.8 8.2 (Berkeley) 4/27/95
 .\"
-.Dd September 12, 2016
+.Dd July 1, 2022
 .Dt SHUTDOWN 8
 .Os
 .Sh NAME
@@ -148,17 +148,22 @@
 .Ar +number ,
 or
 .Ar [[[[[cc]yy]mm]dd]hh]mm ,
-where the century, year, month, day, and hour may be defaulted
+where the century, year, month, day, and hour are two digit decimal
+values, which may be defaulted
 to the current system values.
+The two digit (decimal, even with a leading zero) minute field is
+required in this form.
 The first form brings the system down
 .Ar number
 minutes from the current time; the second brings the system down at the
 absolute time specified.
-If the century is not specified, it defaults to 1900 for years between 69
-and 99, or 2000 for years between 0 and 68.
+If the century is not specified, but the year is,
+the century defaults to 2000 (cc==20, the 21st century)
+for years between 20 and 99,
+or 2100 for years between 0 and 19.
 A leading zero in the
 .Dq yy
-value is
+value (as with all the others) is
 .Em not
 optional.
 .It Ar message ...
diff -r 605559bfec0d -r 4ca0d27f149c sbin/shutdown/shutdown.c
--- a/sbin/shutdown/shutdown.c  Fri Jul 01 09:54:36 2022 +0000
+++ b/sbin/shutdown/shutdown.c  Fri Jul 01 16:45:12 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: shutdown.c,v 1.57 2017/08/07 22:08:12 uwe Exp $        */
+/*     $NetBSD: shutdown.c,v 1.58 2022/07/01 16:45:12 kre Exp $        */
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)shutdown.c 8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: shutdown.c,v 1.57 2017/08/07 22:08:12 uwe Exp $");
+__RCSID("$NetBSD: shutdown.c,v 1.58 2022/07/01 16:45:12 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -486,10 +486,10 @@
                        lt->tm_year += ATOI2(timearg);
                } else {
                        yearset = ATOI2(timearg);
-                       if (yearset < 69)
+                       if (yearset < 20)
+                               lt->tm_year = yearset + 2100 - TM_YEAR_BASE;
+                       else
                                lt->tm_year = yearset + 2000 - TM_YEAR_BASE;
-                       else
-                               lt->tm_year = yearset + 1900 - TM_YEAR_BASE;
                }
                /* FALLTHROUGH */
        case 8:



Home | Main Index | Thread Index | Old Index