cd(1) MPE/iX Shell and Utilities cd(1)
______________________________________________________________________
NAME
cd -- change working directory
SYNOPSIS
cd [directory]
cd old new
DESCRIPTION
The command
cd directory
changes the working directory of the current shell execution
environment (see sh(1)) to directory. If directory is an absolute
path name, beginning with /, this is the target directory. If
directory is a relative path name, cd assumes it is relative to
the current working directory.
In the shell, if the variable CDPATH is defined, the built-in cd
command searches for a relative path name under each of the
directories defined in CDPATH. If cd finds the directory outside
the current working directory, it displays the new working direc-
tory.
Use colons to separate directories in CDPATH. In CDPATH, a null
string represents the current directory. For example, if the
value of CDPATH begins with a separator character, cd searches
the current directory first; if it ends with a separator charac-
ter, cd searches the current directory last.
In the shell, the command
cd -
is a special case that changes the working directory to the pre-
vious working directory by exchanging the values of the variables
PWD and OLDPWD.
Note: Repeating this command toggles the current working direc-
tory between the current and old working directory.
Calling cd without arguments sets the working directory to the
value of the HOME environment variable, if the variable exists.
If there is no HOME variable, cd does not change the current
directory.
The form
cd old new
is an extension to traditional KornShell implementations. The
shell keeps the name of the current directory in the variable
PWD. The cd command scans the current value of PWD and replaces
1
cd(1) MPE/iX Shell and Utilities cd(1)
______________________________________________________________________
the first occurrence of the string old with the string new. The
shell displays the resulting value of PWD and it becomes the new
working directory.
If either directory is a symbolic link to another directory, the
behavior depends upon the setting of the shell's -o logical flag.
See set(1) for more information.
ENVIRONMENT VARIABLES
CDPATH
contains a list of directories for cd to search under when
directory is a relative path name.
HOME
contains the name of your home directory. This is used when
you do not specify directory on the command line.
DIAGNOSTICS
Possible exit status values are:
0 Successful completion.
1 Failure due to any of the following:
-- no HOME directory
-- no previous directory
-- a search for directory failed
-- an old/new substitution failed
2 An invalid command line option.
Messages
Message: "dir" bad directory: system error
Cause: See syserror(3).
Action: See syserror(3).
Message: cd: restricted
Cause: You were using the restricted version of the shell (for
example, by specifying the -r option for sh). The
restricted shell does not allow the cd command.
Action: To use the cd command, you must be using a non-
restricted shell.
Message: no HOME directory
Cause: You attempted to use cd to return to your home direc-
tory; however, the environment variable HOME was not
defined.
Action: Set the environment variable HOME to the path name of
your home directory.
2
cd(1) MPE/iX Shell and Utilities cd(1)
______________________________________________________________________
Message: no previous directory
Cause: You tried the command cd - to return to your previous
directory; however, there was no record of what your
previous directory was.
Action: Make sure that you only use cd - when there is a previ-
ous directory.
Message: pattern "old" not found in "dir"
Cause: You tried a command of the form
cd old new
However, the name of the current directory dir does not
contain any string matching the regular expression old.
Action: Ensure that the name of the current directory contains
the regular expression old.
Message: Unknown option "-option"
Cause: You specified an option that is not valid for cd
Action: Check the DESCRIPTION section for a list of valid cd
options.
PORTABILITY
POSIX.2. x/OPEN Portability Guide 4.0.
All UNIX systems feature the first form of the command.
In the MPE/iX Shell and Utilities implementation of this command,
all forms are built into the shell.
The cd old new form of the command is an extension to the POSIX
standard.
MPE/iX NOTES
For information on how the current MPE/iX implementation may
affect the operation of this utility, see Appendix A, MPE/iX
Implementation Considerations.
SEE ALSO
set(1) sh(1)
3