|
|
|
|
|
by abhishekjha
3031 days ago
|
|
>SO!! If you had a /usr/bin/cd program that ran chdir, that would be fine, but when you started it it would change its own working directory and exit which is not very helpful. It wouldn’t change the working directory of you (the parent process) I am a little confused. What is the parent process and why does that matter here? |
|
What you want cd to do is change the caller's (or parent's) working directory, or in this case the shell's working directory.
There are hacks to do it that you can find elsewhere in this thread (process injection and debug APIs to name two) but frankly the shell changing its own working directory via a builtin is a much simpler and more reliable solution that is also cross-platform.