Dave Voutila wrote: > Preben Guldberg writes: > > The patch below addresses an off-by-one error reading argv when > > generating the error message.
> > I personally find it clearer if the condition of mixing -a with an id > > is highlighted. I included a suggestion in the patch below. > Since -a and providing an id are mutually exclusive, I think it's more > helpful to print usage information via ctl_usage(res->ctl). From the > usage details, it's self explanatory what's wrong. > usage: vmctl [-v] stop [-fw] [id | -a] The updated diff below would do just that: % vmctl stop -a testvm usage: vmctl [-v] stop [-fw] [id | -a] diff 09b708f572d76de8db7f7948ea7359b19bbd1c5a /usr/src blob - 249eaa3ded1ee9c804a81874613c292a74ea4b21 file + usr.sbin/vmctl/main.c --- usr.sbin/vmctl/main.c +++ usr.sbin/vmctl/main.c @@ -961,7 +961,7 @@ ctl_stop(struct parse_result *res, int argc, char *arg /* VM id is only expected without the -a flag */ if ((res->action != CMD_STOPALL && ret == -1) || (res->action == CMD_STOPALL && ret != -1)) - errx(1, "invalid id: %s", argv[1]); + ctl_usage(res->ctl); return (vmmaction(res)); }