xref: /openbsd/usr.bin/which/which.1 (revision 41371632)
1*41371632Sderaadt.\"	$OpenBSD: which.1,v 1.7 1998/05/13 10:33:27 deraadt Exp $
2df930be7Sderaadt.\" Copyright (c) 1980, 1991 Regents of the University of California.
3df930be7Sderaadt.\" All rights reserved.
4df930be7Sderaadt.\"
5df930be7Sderaadt.\" Redistribution and use in source and binary forms, with or without
6df930be7Sderaadt.\" modification, are permitted provided that the following conditions
7df930be7Sderaadt.\" are met:
8df930be7Sderaadt.\" 1. Redistributions of source code must retain the above copyright
9df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer.
10df930be7Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright
11df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer in the
12df930be7Sderaadt.\"    documentation and/or other materials provided with the distribution.
13df930be7Sderaadt.\" 3. All advertising materials mentioning features or use of this software
14df930be7Sderaadt.\"    must display the following acknowledgement:
15df930be7Sderaadt.\"	This product includes software developed by the University of
16df930be7Sderaadt.\"	California, Berkeley and its contributors.
17df930be7Sderaadt.\" 4. Neither the name of the University nor the names of its contributors
18df930be7Sderaadt.\"    may be used to endorse or promote products derived from this software
19df930be7Sderaadt.\"    without specific prior written permission.
20df930be7Sderaadt.\"
21df930be7Sderaadt.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22df930be7Sderaadt.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23df930be7Sderaadt.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24df930be7Sderaadt.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25df930be7Sderaadt.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26df930be7Sderaadt.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27df930be7Sderaadt.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28df930be7Sderaadt.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29df930be7Sderaadt.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30df930be7Sderaadt.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31df930be7Sderaadt.\" SUCH DAMAGE.
32df930be7Sderaadt.\"
33df930be7Sderaadt.\"     from: @(#)which.1	6.3 (Berkeley) 4/23/91
34df930be7Sderaadt.\"
3571e895c5Smillert.Dd February 21, 1997
36df930be7Sderaadt.Dt WHICH 1
3771e895c5Smillert.Os
38df930be7Sderaadt.Sh NAME
39df930be7Sderaadt.Nm which
4071e895c5Smillert.Nd "locate a program file (or files) in the path"
41df930be7Sderaadt.Sh SYNOPSIS
42df930be7Sderaadt.Nm which
43d27b3816Smillert.Op Fl a
44df930be7Sderaadt.Op Ar name
45df930be7Sderaadt.Ar ...
46df930be7Sderaadt.Sh DESCRIPTION
47df930be7Sderaadt.Nm Which
48df930be7Sderaadttakes a list of names and looks for the files which would be
49df930be7Sderaadtexecuted had these names been given as commands.
5071e895c5SmillertEach argument is searched for along the user's path.
51d27b3816Smillert.Pp
52d27b3816SmillertIf the
53d27b3816Smillert.Fl a
54d27b3816Smillertflag is given,
55d27b3816Smillert.Nm
56d27b3816Smillertwill return a list of all matches instead of just the first match.
5771e895c5Smillert.Sh RETURN VALUES
58218f70cfSniklasThe
5971e895c5Smillert.Nm
60218f70cfSniklasutility exits with one of the following values:
61218f70cfSniklas.Bl -tag -width 4n
62218f70cfSniklas.It 0
63218f70cfSniklasAll names got successfully resolved.
64218f70cfSniklas.It 1
65218f70cfSniklasSome names got resolved but not all.
66218f70cfSniklas.It 2
67218f70cfSniklasNo names got resolved.
6871e895c5Smillert.It -1
6971e895c5SmillertA system error occurred.
70df930be7Sderaadt.El
71df930be7Sderaadt.Sh DIAGNOSTICS
7271e895c5SmillertA diagnostic is given if an executable file with the argument
7371e895c5Smillertname was not found in the path.
74*41371632Sderaadt.Sh ENVIRONMENT
7571e895c5Smillert.Bl -tag -width PATH
7671e895c5Smillert.It Ev PATH
7771e895c5Smillert.Nm
7871e895c5Smillertuses the environment variable
7971e895c5Smillert.Ev PATH
8071e895c5Smillertas a colon-separated list of directories in which to find executables.
8171e895c5SmillertIf
8271e895c5Smillert.Ev PATH
8371e895c5Smillertis not set, and the given name is not a fully-qualified
8471e895c5Smillertor relative pathname,
8571e895c5Smillert.Nm
8671e895c5Smillertwill fail.
8771e895c5Smillert.El
8871e895c5Smillert.Sh CAVEATS
89df930be7SderaadtThe
90df930be7Sderaadt.Nm
9171e895c5Smillertcommand formerly was a
9271e895c5Smillert.Xr csh 1
9371e895c5Smillertscript and could expand aliases.
9471e895c5Smillert.Xr csh 1
9571e895c5Smillertnow has a built-in
9671e895c5Smillert.Nm
9771e895c5Smillertcomand so this version is intended for use
9871e895c5Smillertwith other shells like
9971e895c5Smillert.Xr sh 1 .
10071e895c5Smillert.Sh SEE ALSO
10171e895c5Smillert.Xr csh 1 ,
10271e895c5Smillert.Xr sh 1 ,
1033d908e8eSmillert.Xr whereis 1 ,
10471e895c5Smillert.Xr environ 7
10571e895c5Smillert.Sh HISTORY
10671e895c5SmillertA
10771e895c5Smillert.Nm
108df930be7Sderaadtcommand appeared in
109df930be7Sderaadt.Bx 3.0 .
110