summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authormartin <martin@NetBSD.org>2020-04-25 10:50:47 +0000
committermartin <martin@NetBSD.org>2020-04-25 10:50:47 +0000
commitc4126712cffab7cbfc72800e43c40badd26df354 (patch)
tree6190fcc0d6f1f3d33c39d87f5a213ffe101433da /usr.bin
parent4fc511dd0d48aff2c1a4ae1bf4eaa3c45fd201f7 (diff)
Pull up following revision(s) (requested by simonb in ticket #853):
bin/csh/time.c: revision 1.22 usr.bin/time/time.c: revision 1.24 bin/csh/extern.h: revision 1.32 usr.bin/time/time.1: revision 1.29 usr.bin/time/ext.h: revision 1.4 Add '-t' option for tcsh-style time output.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/time/ext.h4
-rw-r--r--usr.bin/time/time.111
-rw-r--r--usr.bin/time/time.c24
3 files changed, 27 insertions, 12 deletions
diff --git a/usr.bin/time/ext.h b/usr.bin/time/ext.h
index 6626a298995..db8e861e195 100644
--- a/usr.bin/time/ext.h
+++ b/usr.bin/time/ext.h
@@ -1,5 +1,5 @@
-/* $NetBSD: ext.h,v 1.3 2017/07/15 14:34:08 christos Exp $ */
+/* $NetBSD: ext.h,v 1.3.8.1 2020/04/25 10:50:47 martin Exp $ */
/* borrowed from ../../bin/csh/extern.h */
-void prusage1(FILE *, const char *fmt, struct rusage *, struct rusage *,
+void prusage1(FILE *, const char *fmt, int, struct rusage *, struct rusage *,
struct timespec *, struct timespec *);
diff --git a/usr.bin/time/time.1 b/usr.bin/time/time.1
index 3f423103684..e95a29409bf 100644
--- a/usr.bin/time/time.1
+++ b/usr.bin/time/time.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: time.1,v 1.28 2017/07/15 14:40:36 wiz Exp $
+.\" $NetBSD: time.1,v 1.28.8.1 2020/04/25 10:50:47 martin Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)time.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd July 15, 2017
+.Dd April 23, 2020
.Dt TIME 1
.Os
.Sh NAME
@@ -124,6 +124,13 @@ structure are printed; see below.
.It Fl p
The output is formatted as specified by
.St -p1003.2-92 .
+.It Fl t
+Displays information in the format used by default the
+.Nm
+builtin of
+.Xr tcsh 1
+uses (%Uu %Ss %E %P\\t%X+%Dk %I+%Oio %Fpf+%Ww) with
+three decimal places for time values.
.El
.Pp
Some shells, such as
diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c
index 263db9a0423..ca3aeca275f 100644
--- a/usr.bin/time/time.c
+++ b/usr.bin/time/time.c
@@ -1,4 +1,4 @@
-/* $NetBSD: time.c,v 1.23 2017/07/15 14:34:08 christos Exp $ */
+/* $NetBSD: time.c,v 1.23.8.1 2020/04/25 10:50:47 martin Exp $ */
/*
* Copyright (c) 1987, 1988, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1988, 1993\
#if 0
static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: time.c,v 1.23 2017/07/15 14:34:08 christos Exp $");
+__RCSID("$NetBSD: time.c,v 1.23.8.1 2020/04/25 10:50:47 martin Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -67,7 +67,7 @@ int
main(int argc, char ** volatile argv)
{
int pid;
- int ch, status;
+ int ch, status, prec;
int volatile portableflag;
int volatile lflag;
const char *decpt;
@@ -79,20 +79,21 @@ main(int argc, char ** volatile argv)
(void)setlocale(LC_ALL, "");
lflag = portableflag = 0;
+ prec = 1;
fmt = NULL;
- while ((ch = getopt(argc, argv, "cf:lp")) != -1) {
+ while ((ch = getopt(argc, argv, "cf:lpt")) != -1) {
switch (ch) {
case 'f':
fmt = optarg;
portableflag = 0;
lflag = 0;
break;
- case 'c':
+ case 'c': /* csh format */
fmt = "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww";
portableflag = 0;
lflag = 0;
break;
- case 'p':
+ case 'p': /* POSIX.2 format */
portableflag = 1;
fmt = NULL;
lflag = 0;
@@ -102,6 +103,12 @@ main(int argc, char ** volatile argv)
portableflag = 0;
fmt = NULL;
break;
+ case 't': /* tcsh format */
+ fmt = "%Uu %Ss %E %P\t%X+%Dk %I+%Oio %Fpf+%Ww";
+ prec = 3;
+ portableflag = 0;
+ lflag = 0;
+ break;
case '?':
default:
usage();
@@ -143,7 +150,7 @@ main(int argc, char ** volatile argv)
static struct rusage null_ru;
before.tv_sec = 0;
before.tv_nsec = 0;
- prusage1(stderr, fmt, &null_ru, &ru, &after, &before);
+ prusage1(stderr, fmt, prec, &null_ru, &ru, &after, &before);
} else if (portableflag) {
prts("real ", decpt, &after, "\n");
prtv("user ", decpt, &ru.ru_utime, "\n");
@@ -184,7 +191,8 @@ static void
usage(void)
{
- (void)fprintf(stderr, "Usage: %s [-clp] [-f <fmt>] utility [argument ...]\n",
+ (void)fprintf(stderr,
+ "Usage: %s [-clpt] [-f <fmt>] utility [argument ...]\n",
getprogname());
exit(EXIT_FAILURE);
}