diff --git a/usr.bin/which/which.1 b/usr.bin/which/which.1 index 757ae1ecb879..234fe47445c9 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 757da9b3951f..bd24a2a4aee4 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; +}