xref: /openbsd/usr.bin/which/which.1 (revision 892a7bb8)
1.\"	$OpenBSD: which.1,v 1.9 1999/05/12 13:26:52 aaron Exp $
2.\" Copyright (c) 1980, 1991 Regents of the University of California.
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\"    must display the following acknowledgement:
15.\"	This product includes software developed by the University of
16.\"	California, Berkeley and its contributors.
17.\" 4. Neither the name of the University nor the names of its contributors
18.\"    may be used to endorse or promote products derived from this software
19.\"    without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE.
32.\"
33.\"     from: @(#)which.1	6.3 (Berkeley) 4/23/91
34.\"
35.Dd February 21, 1997
36.Dt WHICH 1
37.Os
38.Sh NAME
39.Nm which
40.Nd "locate a program file (or files) in the path"
41.Sh SYNOPSIS
42.Nm which
43.Op Fl a
44.Ar name Op Ar ...
45.Sh DESCRIPTION
46.Nm which
47takes a list of names and looks for the files which would be
48executed had these names been given as commands.
49Each argument is searched for along the user's path.
50.Pp
51If the
52.Fl a
53flag is given,
54.Nm
55will return a list of all matches instead of just the first match.
56.Sh RETURN VALUES
57The
58.Nm
59utility exits with one of the following values:
60.Bl -tag -width 4n
61.It 0
62All names were successfully resolved.
63.It 1
64Some names were resolved but not all.
65.It 2
66No names were resolved.
67.It -1
68A system error occurred.
69.El
70.Sh DIAGNOSTICS
71A diagnostic is given if an executable file with the argument
72name was not found in the path.
73.Sh ENVIRONMENT
74.Bl -tag -width PATH
75.It Ev PATH
76.Nm
77uses the environment variable
78.Ev PATH
79as a colon-separated list of directories in which to find executables.
80If
81.Ev PATH
82is not set, and the given name is not a fully qualified
83or relative pathname,
84.Nm
85will fail.
86.El
87.Sh CAVEATS
88The
89.Nm
90command formerly was a
91.Xr csh 1
92script and could expand aliases.
93.Xr csh 1
94now has a built-in
95.Nm
96comand so this version is intended for use
97with other shells like
98.Xr sh 1 .
99.Sh SEE ALSO
100.Xr csh 1 ,
101.Xr sh 1 ,
102.Xr whereis 1 ,
103.Xr environ 7
104.Sh HISTORY
105A
106.Nm
107command appeared in
108.Bx 3.0 .
109