summaryrefslogtreecommitdiffstats
path: root/usr.bin/which
diff options
context:
space:
mode:
authorasami <asami@FreeBSD.org>1995-01-28 17:35:56 +0000
committerasami <asami@FreeBSD.org>1995-01-28 17:35:56 +0000
commitafd6259b6034dbc8f916327de82df8d2336f1f8d (patch)
tree7d4d4eaf851a99123a5ad53b6d1b0648a3fc3672 /usr.bin/which
parent8b380261fb87a0cf7a9e3b0ec5003a1300c89699 (diff)
downloadFreeBSD-src-afd6259b6034dbc8f916327de82df8d2336f1f8d.zip
FreeBSD-src-afd6259b6034dbc8f916327de82df8d2336f1f8d.tar.gz
Add a `-s' flag for `silent' processing. Make the script return 0 for
success and 1 for failure. Describe the options in manpage.
Diffstat (limited to 'usr.bin/which')
-rw-r--r--usr.bin/which/which.112
-rwxr-xr-xusr.bin/which/which.pl21
2 files changed, 28 insertions, 5 deletions
diff --git a/usr.bin/which/which.1 b/usr.bin/which/which.1
index 757ae1e..234fe47 100644
--- a/usr.bin/which/which.1
+++ b/usr.bin/which/which.1
@@ -27,7 +27,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id$
+.\" $Id: which.1,v 1.1 1995/01/26 21:49:48 jkh Exp $
.Dd January 26, 1995
.Dt WHICH 1
.Os FreeBSD
@@ -36,12 +36,22 @@
.Nd "locate a program file in the user's path"
.Sh SYNOPSIS
.Nm which
+.Op Fl as
.Op Ar command
.Ar ...
.Sh DESCRIPTION
.Nm Which
takes a list of command names and searches the path for each executable
file that would be run had these commands actually been invoked.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl a
+List all instances of executables found (instead of just the first one
+of each).
+.It Fl s
+No output, just return 0 if any of the executables are found, or 1 if
+none are found.
.Sh HISTORY
The
.Nm
diff --git a/usr.bin/which/which.pl b/usr.bin/which/which.pl
index 757da9b..bd24a2a 100755
--- a/usr.bin/which/which.pl
+++ b/usr.bin/which/which.pl
@@ -31,22 +31,35 @@
#
# [whew!]
#
-# $Id: which.sh,v 1.1.1.1 1995/01/25 19:18:33 jkh Exp $
+# $Id: which.pl,v 1.1 1995/01/26 21:49:54 jkh Exp $
$all = 0;
+$silent = 0;
+$found = 0;
@path = split(/:/, $ENV{'PATH'});
if ($ARGV[0] eq "-a") {
$all = 1; shift @ARGV;
+} elsif ($ARGV[0] eq "-s") {
+ $silent = 1; shift @ARGV;
} elsif ($ARGV[0] =~ /^-(h|help|\?)$/) {
- die "usage:\n\twhich [-a] program ...\n";
+ die "usage:\n\twhich [-a] [-s] program ...\n";
}
foreach $prog (@ARGV) {
foreach $e (@path) {
if (-x "$e/$prog") {
- print "$e/$prog\n";
- last unless $all;
+ if (! $silent) {
+ print "$e/$prog\n";
+ }
+ $found = 1;
+ last unless $all;
}
}
}
+
+if ($found) {
+ exit 0;
+} else {
+ exit 1;
+}
OpenPOWER on IntegriCloud