Re:How does `cd` work?
by Someone1234 on Friday March 02, 2018 @12:30PM
(#16503681)
The parent is the shell that called the theoretical /user/bin/cd. It means that a cd program would get launched by the shell, change its own working directory and then terminate, which is completely useless.
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.
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.