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