Add a usage().

Print usage() if right before executing the specified command, it comes to be
that *argv is NULL (i.e. a flag was specified without a command being given).
This commit is contained in:
jmallett 2002-05-22 16:09:52 +00:00
parent a00707167b
commit 618595e7c7

View File

@ -296,6 +296,8 @@ char *gstrcat(char *, const char *, size_t);
char *gstrcpy(char *, const char *, size_t);
char *gstrncat(char *, const char *, size_t, size_t);
static void usage(void);
#define FBUFSIZ BUFSIZ
#define PFILELG 120
@ -345,8 +347,7 @@ main(int argc, char *argv[])
if (argc < 2)
{
fprintf(stderr, "Usage: %s [flags] command [flags]\n", MyName);
exit(EX_USAGE);
usage();
}
argv[argc] = NULL;
@ -392,11 +393,27 @@ main(int argc, char *argv[])
SccsPath = ".";
}
if (*argv == NULL)
{
usage();
}
i = command(argv, FALSE, "");
exit(i);
}
/*
** USAGE -- print usage
**
** This function prints the usage for this program.
*/
static void
usage(void)
{
fprintf(stderr, "Usage: %s [flags] command [flags]\n", MyName);
exit(EX_USAGE);
}
/*
** COMMAND -- look up and perform a command
**
** This routine is the guts of this program. Given an