Fix numerous bugs when parsing options and arguments.

This commit is contained in:
Ruslan Ermilov 2007-11-09 15:14:08 +00:00
parent 5b4ab4a032
commit b8272c9193

View File

@ -154,11 +154,12 @@ main(int ac, char **av)
switch (**av) {
case 'j':
++*av;
if (**av == '\0')
if (**av == '\0') {
++av;
--ac;
--ac;
}
jflag++;
if (!*av)
if (*av == NULL)
errx(1, "must specify jid");
jid = strtol(*av, &ep, 10);
if (!*av || *ep)
@ -168,23 +169,32 @@ main(int ac, char **av)
break;
case 'u':
++*av;
if (**av == '\0')
if (**av == '\0') {
++av;
--ac;
--ac;
}
if (*av == NULL)
errx(1, "must specify user");
user = *av;
break;
case 't':
++*av;
if (**av == '\0')
if (**av == '\0') {
++av;
--ac;
--ac;
}
if (*av == NULL)
errx(1, "must specify tty");
tty = *av;
break;
case 'c':
++*av;
if (**av == '\0')
if (**av == '\0') {
++av;
--ac;
--ac;
}
if (*av == NULL)
errx(1, "must specify procname");
cmd = *av;
break;
case 'v':