xref: /original-bsd/share/man/man1/cd.1 (revision 4092c5cc)
1.\" Copyright (c) 1980, 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
7.\" %sccs.include.redist.man%
8.\"
9.\"     @(#)cd.1	8.1 (Berkeley) 06/05/93
10.\"
11.Dd
12.Dt CD 1
13.Os BSD 4
14.Sh NAME
15.Nm cd
16.Nd change working directory
17.Sh SYNOPSIS
18.Nm cd
19.Ar directory
20.Sh DESCRIPTION
21.Ar Directory
22is an absolute or relative pathname which becomes the new working
23directory.
24The interpretation of a relative pathname by cd depends on the CDPATH
25environment variable (see below).
26.Sh ENVIRONMENT
27The following environment variables affect the execution of cd:
28.Pp
29.Bl -tag -width indent
30.It Ev CDPATH
31If the
32.Ar directory
33operand does not begin with a slash (/) character, and the first
34component is not dot (.) or dot-dot (..),
35.Nm cd
36searches for the directory relative to each directory named in the
37.Ev CDPATH
38variable, in the order listed.
39The new working directory is set to the first matching directory found.
40An empty string in place of a directory pathname represents the current
41directory.
42If the new working directory was derived from
43.Ev CDPATH ,
44it will be printed to the standard output.
45.It Ev HOME
46If
47.Nm cd
48is invoked without arguments and the
49.Ev HOME
50environment variable exists and contains a directory name, that directory
51becomes the new working directory.
52.El
53.Pp
54See
55.Xr csh 1
56for more information on environment variables.
57.Pp
58The
59.Nm cd
60utility exits 0 on success, and >0 if an error occurs.
61.Sh SEE ALSO
62.Xr csh 1 ,
63.Xr pwd 1 ,
64.Xr sh 1 ,
65.Xr chdir 2
66.Sh STANDARDS
67The
68.Nm cd
69command is expected to be
70.St -p1003.2
71compatible.
72