summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2005-02-10 16:04:22 +0000
committerru <ru@FreeBSD.org>2005-02-10 16:04:22 +0000
commit4666872d3b5d712b3d83fc128d787daafaf1d9ac (patch)
treed573d1798e338eb9b699ef77dd58746d88d0518f /usr.bin
parent6d2ea50e04b1cb80a95249df97cb35af63fb396f (diff)
downloadFreeBSD-src-4666872d3b5d712b3d83fc128d787daafaf1d9ac.zip
FreeBSD-src-4666872d3b5d712b3d83fc128d787daafaf1d9ac.tar.gz
Require at least one argument.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/which/which.13
-rw-r--r--usr.bin/which/which.c13
2 files changed, 6 insertions, 10 deletions
diff --git a/usr.bin/which/which.1 b/usr.bin/which/which.1
index 9e0c559..c00a14a 100644
--- a/usr.bin/which/which.1
+++ b/usr.bin/which/which.1
@@ -38,8 +38,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl as
-.Op Ar command
-.Ar ...
+.Ar program ...
.Sh DESCRIPTION
The
.Nm
diff --git a/usr.bin/which/which.c b/usr.bin/which/which.c
index c3cccfc..3b8224da 100644
--- a/usr.bin/which/which.c
+++ b/usr.bin/which/which.c
@@ -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
OpenPOWER on IntegriCloud