Require at least one argument.

This commit is contained in:
ru 2005-02-10 16:04:22 +00:00
parent a0431095cf
commit da2f5711ad
2 changed files with 6 additions and 10 deletions

View File

@ -38,8 +38,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl as
.Op Ar command
.Ar ...
.Ar program ...
.Sh DESCRIPTION
The
.Nm

View File

@ -52,10 +52,6 @@ main(int argc, char **argv)
status = EXIT_SUCCESS;
/* If called without args, die silently to conform */
if (argc < 2)
exit(EXIT_FAILURE);
while ((opt = getopt(argc, argv, "as")) != -1) {
switch (opt) {
case 'a':
@ -73,6 +69,9 @@ main(int argc, char **argv)
argv += optind;
argc -= optind;
if (argc == 0)
usage();
if ((p = getenv("PATH")) == NULL)
exit(EXIT_FAILURE);
pathlen = strlen(p) + 1;
@ -80,9 +79,6 @@ main(int argc, char **argv)
if (path == NULL)
err(EXIT_FAILURE, NULL);
if (argc == 0)
status = EXIT_FAILURE;
while (argc > 0) {
memcpy(path, p, pathlen);
@ -101,7 +97,8 @@ static void
usage(void)
{
errx(EXIT_FAILURE, "usage: which [-as] program ...");
(void)fprintf(stderr, "usage: which [-as] program ...\n");
exit(EXIT_FAILURE);
}
static int