procstat: Fix regression after 365880.

Basically it reverts one chunk that reversed the parsing logic, making
legacy variants of invocation, like `procstat -a -f', non-operational.

Reported and tested by:	Dewayne Geraghty <dewayne@heuristicsystems.com.au>
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
This commit is contained in:
Konstantin Belousov 2020-09-29 00:20:58 +00:00
parent 5f0601fd19
commit 34d7dd1561

View File

@ -425,9 +425,7 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
if (cmd == NULL && argv[0] != NULL)
cmd = getcmd(argv[0]);
if (cmd != NULL) {
if (cmd == NULL && argv[0] != NULL && (cmd = getcmd(argv[0])) != NULL) {
if ((procstat_opts & PS_SUBCOMMAND_OPTS) != 0)
usage(cmd);
if (cmd->opt != NULL) {
@ -443,12 +441,13 @@ main(int argc, char *argv[])
argv += 1;
}
} else {
cmd = getcmd("basic");
if (cmd == NULL)
cmd = getcmd("basic");
if (cmd->cmd != procstat_files &&
(procstat_opts & PS_OPT_CAPABILITIES) != 0 &&
(cmd->cmp & PS_MODE_COMPAT) == 0)
usage(cmd);
}
if (cmd->cmd != procstat_files &&
(procstat_opts & PS_OPT_CAPABILITIES) != 0 &&
(cmd->cmp & PS_MODE_COMPAT) == 0)
usage(cmd);
/* Must specify either the -a flag or a list of pids. */
if (!(aflag == 1 && argc == 0) && !(aflag == 0 && argc > 0))