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..
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..
using chdir function:
http://www.opengroup.org/onlinepubs/009695399/functions/chdir.html
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.
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.