awk: check presence of parameters

This commit is contained in:
David van Moolenbroek 2009-12-14 20:24:33 +00:00
parent 307ad7b3b0
commit 14367afaf7

View file

@ -70,6 +70,7 @@ main(argc, argv, envp) char **argv, *envp;
else {
argc--; s = *++argv;
}
if (s == NULL) usage();
pfp = efopen(s, "r");
s += strlen(s) - 1;
break;
@ -93,6 +94,8 @@ main(argc, argv, envp) char **argv, *envp;
}
*/
if (pfp == NULL && srcprg == NULL) usage();
while (*xargv != NULL && strchr(*xargv, '=') != NULL) {
setvar(*xargv++);
xargc--;
@ -139,3 +142,12 @@ onint(i)
closeall();
exit(0x80 | i);
}
void
usage()
{
fprintf(stderr,
"usage: %s [options] [-f <rulefile> | <rules>] [inputfiles]\n", cmd);
closeall();
exit(1);
}