Change the export option from -w (write) to -X.
While implementing import it became apparent that write as a mnemonic is ambiguous and confusing. MFC after: 8 days
This commit is contained in:
parent
32371d2025
commit
b7dd80b843
@ -43,7 +43,7 @@
|
||||
.Oo
|
||||
.Op Fl EScesu
|
||||
|
|
||||
.Op Fl w
|
||||
.Op Fl X
|
||||
.Oc
|
||||
.Op Fl f Ar file
|
||||
.Op Ar command ...\&
|
||||
@ -72,8 +72,8 @@ Print the amount of elapsed time used by the process.
|
||||
Print the amount of system time used by the process.
|
||||
.It Fl u
|
||||
Print the amount of user time used by the process.
|
||||
.It Fl w
|
||||
Write out the complete contents of each accounting record in a text format
|
||||
.It Fl X
|
||||
Export the complete contents of each accounting record in a text format
|
||||
that can be parsed by programs.
|
||||
The elements are written in the order defined in
|
||||
.Xr acct 5 .
|
||||
|
@ -68,7 +68,7 @@ char *flagbits(int);
|
||||
const char *getdev(dev_t);
|
||||
int requested(char *[], struct acct *);
|
||||
static void usage(void);
|
||||
static void write_record(struct acct *acp);
|
||||
static void export_record(struct acct *acp);
|
||||
|
||||
#define AC_UTIME 1 /* user */
|
||||
#define AC_STIME 2 /* system */
|
||||
@ -92,10 +92,10 @@ main(int argc, char *argv[])
|
||||
int ch;
|
||||
const char *acctfile;
|
||||
int flags = 0;
|
||||
bool write_text = false;
|
||||
bool export_text = false;
|
||||
|
||||
acctfile = _PATH_ACCT;
|
||||
while ((ch = getopt(argc, argv, "f:uwsecSE")) != -1)
|
||||
while ((ch = getopt(argc, argv, "f:usecSEX")) != -1)
|
||||
switch((char)ch) {
|
||||
case 'f':
|
||||
acctfile = optarg;
|
||||
@ -103,8 +103,8 @@ main(int argc, char *argv[])
|
||||
case 'u':
|
||||
flags |= AC_UTIME; /* user time */
|
||||
break;
|
||||
case 'w':
|
||||
write_text = true; /* export */
|
||||
case 'X':
|
||||
export_text = true; /* export */
|
||||
break;
|
||||
case 's':
|
||||
flags |= AC_STIME; /* system time */
|
||||
@ -130,10 +130,10 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* default user + system time and starting time */
|
||||
if (!flags && !write_text)
|
||||
if (!flags && !export_text)
|
||||
flags = AC_CTIME | AC_BTIME;
|
||||
|
||||
if (flags && write_text)
|
||||
if (flags && export_text)
|
||||
usage();
|
||||
|
||||
argc -= optind;
|
||||
@ -161,7 +161,7 @@ main(int argc, char *argv[])
|
||||
do {
|
||||
int rv;
|
||||
|
||||
if (fp != stdin && !write_text) {
|
||||
if (fp != stdin && !export_text) {
|
||||
size -= sizeof(struct acct);
|
||||
if (fseeko(fp, size, SEEK_SET) == -1)
|
||||
err(1, "seek %s failed", acctfile);
|
||||
@ -185,8 +185,8 @@ main(int argc, char *argv[])
|
||||
if (*argv && !requested(argv, &ab))
|
||||
continue;
|
||||
|
||||
if (write_text) {
|
||||
write_record(&ab);
|
||||
if (export_text) {
|
||||
export_record(&ab);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -307,12 +307,12 @@ static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: lastcomm [[-EScesu] | [-w]] [-f file] [command ...] [user ...] [terminal ...]\n");
|
||||
"usage: lastcomm [[-EScesu] | [-X]] [-f file] [command ...] [user ...] [terminal ...]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
write_record(struct acct *acp)
|
||||
export_record(struct acct *acp)
|
||||
{
|
||||
(void)printf("%s %g %g %g",
|
||||
acp->ac_comm,
|
||||
|
Loading…
x
Reference in New Issue
Block a user