aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>1998-07-27 16:08:58 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>1998-07-27 16:08:58 +0000
commitfabfd1334a5ceebee9d15058c4726a84de1194c3 (patch)
treef0cb71df5758d7584be25bddf8646578929f731e /usr.bin
parent15b29aabe4cac1192cc9a167bc3f911f81cfef76 (diff)
downloadsrc-fabfd1334a5ceebee9d15058c4726a84de1194c3.tar.gz
src-fabfd1334a5ceebee9d15058c4726a84de1194c3.zip
Clean up the previous commit.
Notes
Notes: svn path=/head/; revision=37888
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/time/time.132
-rw-r--r--usr.bin/time/time.c48
2 files changed, 45 insertions, 35 deletions
diff --git a/usr.bin/time/time.1 b/usr.bin/time/time.1
index b095281c60e0..a3f805ff0163 100644
--- a/usr.bin/time/time.1
+++ b/usr.bin/time/time.1
@@ -40,7 +40,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl a Ar file
-.Op Fl f Ar file
+.Op Fl o Ar file
.Op Fl l
.Ar command
.Sh DESCRIPTION
@@ -74,22 +74,14 @@ Append the output of
to
.Ar file
instead of writing to stderr.
-.It Fl f Ar file
+.It Fl o Ar file
Write the output to
.Ar file
instead of stderr. If
.Ar file
exists, then
.Nm
-will overwrite the file if premissions permit such an operation.
-The output can be sent to stdout by giving
-a file name
-.Do
--
-.Dc
-to the
-.Fl f
-option.
+will overwrite the file if its permissions allow it.
.It Fl l
The contents of the
.Em rusage
@@ -106,6 +98,24 @@ is available as
to
.Xr csh
users.
+.Sh NOTES
+The output of
+.Nm
+can be directed to standard output by specifying
+.Do
+-
+.Dc
+as the argument to the
+.Fl a
+or
+.Fl o
+option.
+.Pp
+The
+.Fl a
+and
+.Fl o
+options are mutually exclusive.
.Sh BUGS
The granularity of seconds on micro processors is crude and
can result in times being reported for CPU usage which are too large by
diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c
index ff703fd464d3..6aa698f36055 100644
--- a/usr.bin/time/time.c
+++ b/usr.bin/time/time.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: time.c,v 1.6 1997/08/14 06:48:59 charnier Exp $";
+ "$Id: time.c,v 1.7 1998/07/24 07:19:29 phk Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -55,8 +55,9 @@ static const char rcsid[] =
#include <err.h>
#include <stdio.h>
-#include <unistd.h>
#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
static int getstathz __P((void));
static void usage __P((void));
@@ -70,31 +71,25 @@ main(argc, argv)
extern int optind;
register int pid;
- int ch, status, lflag;
+ int ch, status, lflag, aflag = 0;
struct timeval before, after;
struct rusage ru;
- FILE *out = NULL;
+ FILE *out = stderr;
+ char *ofn = NULL;
lflag = 0;
- while ((ch = getopt(argc, argv, "a:f:l")) != -1)
+ while ((ch = getopt(argc, argv, "a:o:l")) != -1)
switch((char)ch) {
case 'a':
- if (out)
- err(1, optarg);
- out = fopen(optarg, "a");
- if (!out)
- err(1, optarg);
+ if (ofn)
+ usage();
+ ofn = optarg;
+ aflag = 1;
break;
- case 'f':
- if (out)
- err(1, optarg);
- if (strcmp(optarg, "-") == 0)
- out = stdout;
- else {
- out = fopen(optarg, "w");
- if (!out)
- err(1, optarg);
- }
+ case 'o':
+ if (ofn)
+ usage();
+ ofn = optarg;
break;
case 'l':
lflag = 1;
@@ -108,8 +103,13 @@ main(argc, argv)
exit(0);
argv += optind;
- if (!out)
- out = stderr;
+ if (ofn) {
+ if (strcmp(ofn, "-") == 0)
+ out = stdout;
+ else
+ if ((out = fopen(ofn, aflag?"a":"w")) == NULL)
+ err(EX_IOERR, ofn);
+ }
gettimeofday(&before, (struct timezone *)NULL);
switch(pid = vfork()) {
@@ -187,8 +187,8 @@ main(argc, argv)
static void
usage()
{
- fprintf(stderr, "usage: time [-l] command\n");
- exit(1);
+ fprintf(stderr, "usage: time [-l] [-{o|a} file] command\n");
+ exit(EX_USAGE);
}
/*