From 34d7dd1561e0836368e94b43e0f5a5f4801f4489 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 29 Sep 2020 00:20:58 +0000 Subject: [PATCH] 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 Sponsored by: The FreeBSD Foundation MFC after: 3 days --- usr.bin/procstat/procstat.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/usr.bin/procstat/procstat.c b/usr.bin/procstat/procstat.c index 0431169030db..a1cd082ecb5a 100644 --- a/usr.bin/procstat/procstat.c +++ b/usr.bin/procstat/procstat.c @@ -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))