Sunday, December 21, 2014

Shell Scripting : Why directory change can't be made in a separate process?

While executing cd command, if a new process is forked as a child process of the current shell, then after the cd command execution is completed, the control would revert back to the parent process(the current shell) and the original directory would be restored back. Hence, it would be impossible to change directories.

Hence cd command is executed within the current shell process itself.

No comments:

Post a Comment