tags:

views:

789

answers:

3

can anyone tell me where I could find source code for unix environments 'cd' command I want to know how change directory command is implemented.

prolly linux sources..would be good..

+1  A: 

using chdir function:

http://www.opengroup.org/onlinepubs/009695399/functions/chdir.html

dfa
+1  A: 

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

Metiu
cd must be built into the shell, since you cannot change the working directory of the parent process
1800 INFORMATION
+3  A: 

Here is a complete explanation how cd works: http://www.cs.ucr.edu/~brett/cs153_w02/syscall.html

The cd Unix command just calls chdir and examines the error codes.

Aaron Digulla