From: David van Moolenbroek Date: Mon, 14 Dec 2009 20:24:33 +0000 (+0000) Subject: awk: check presence of parameters X-Git-Tag: v3.1.6~154 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/mult.png?a=commitdiff_plain;h=14367afaf781de243bfb1c37dec756040910c783;p=minix.git awk: check presence of parameters --- diff --git a/commands/awk/m.c b/commands/awk/m.c index 1f2ba270d..af8b6e62a 100644 --- a/commands/awk/m.c +++ b/commands/awk/m.c @@ -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 | ] [inputfiles]\n", cmd); + closeall(); + exit(1); +}