cd is usually built-in in the shell, you should just look at the code of any shell, e.g. bash, or ash.
The cd command should be ultimately based on the chdir() function, but if you're interested in all the command line expansions, then the source is the shell.
Examine bash-./builtins/cd.def, where "." represents the version you downloaded (e.g. 4.2). This is the file from which cd.c is created, according to the comment at the top of the file.
cd is usually built-in in the shell, you should just look at the code of any shell, e.g. bash, or ash.
The cd command should be ultimately based on the chdir() function, but if you're interested in all the command line expansions, then the source is the shell.
http://en.wikipedia.org/wiki/Comparison_of_computer_shells
using chdir function:
http://www.opengroup.org/onlinepubs/009695399/functions/chdir.html
To see the source for the bash cd command, for example:
Here is a complete explanation how
cd
works: http://web.archive.org/web/20090515201659/http://www.cs.ucr.edu/~brett/cs153_w02/syscall.htmlThe
cd
Unix command just callschdir
and examines the error codes.