Require at least one argument.
This commit is contained in:
parent
f5c4f5a580
commit
b7a311f2b8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=141656
@ -38,8 +38,7 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl as
|
||||
.Op Ar command
|
||||
.Ar ...
|
||||
.Ar program ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user