[ACCEPTED]-source code for unix environments 'cd' command-chdir
Accepted answer
Here is a complete explanation how cd
works: http://web.archive.org/web/20090515201659/http://www.cs.ucr.edu/~brett/cs153_w02/syscall.html
The 2 cd
Unix command just calls chdir
and examines the 1 error codes.
To see the source for the bash cd command, for 1 example:
- Download the bash source from http://ftp.gnu.org/gnu/bash/
- Extract the source
- 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 5 should just look at the code of any shell, e.g. bash, or 4 ash.
The cd command should be ultimately 3 based on the chdir() function, but if you're 2 interested in all the command line expansions, then 1 the source is the shell.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.