xref: /original-bsd/share/man/man1/cd.1 (revision e61fc7ea)
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.3 (Berkeley) 07/24/90
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
18The cd utility changes the working directory
19to
20.Ar directory .
21.Pp
22The
23.Ar directory
24is an absolute or relative pathname
25which becomes the new working directory.
26The
27interpretation of a relative pathname by cd depends
28on the CDPATH environment variable (see below).
29.Pp
30.Sh ENVIRONMENT
31The following environment variables affect the execution of
32cd:
33.Pp
34.Tw Fl
35.Tp Ev HOME
36If
37.Nm cd
38is
39invoked without arguments, the
40.Ev HOME
41environment variable is checked for a default
42directory name. If
43.Ev HOME
44exists and contains
45a directory name,
46that directory becomes the new working directory.
47.Tp Ev CDPATH
48If the
49.Ar directory
50operand does not
51begin with a slash (/) character, and the first
52component is not dot (.) or dot-dot (..),
53.Nm cd
54searches for
55the directory relative to each directory named in the
56.Ev CDPATH
57variable, in the order listed.
58The new
59working directory is set to the first matching
60directory found.
61An empty string in place of a
62directory pathname represents the current directory.
63.Nm Cd
64will print the pathname of the new working directory if it
65was an element of
66.Ev CDPATH .
67See
68.Xr csh 1
69for info on environment variables.
70.Tp
71.Pp
72The
73.Nm cd
74utility exits 0 on success, and >0 if an error occurs.
75.Sh SEE ALSO
76.Xr csh 1 ,
77.Xr sh 1 ,
78.Xr pwd 1 ,
79.Xr chdir 2
80.Sh STANDARDS
81The
82.Nm cd
83function is expected to be POSIX 1003.2 compatible.
84