3 ms·
> You want to understand why cd is not an executable but a builtin? Because a sub-process cannot change the working directory of its parent. The shell process
by codetrotter 3y ago
> You want to understand why cd is not an executable but a builtin?
Because a sub-process cannot change the working directory of its parent. The shell process needs to change its own working directory. Therefore cd must be a builtin.
Although, I suppose that one might execve a cd binary, which would change directory and then in turn the cd binary would execve the shell that is specified in the $SHELL env var. That would be terribly silly though :p
- neuromanser 3y agohttps://www.skarnet.org/software/execline/execline-cd.html https://www.skarnet.org/software/execline/execline-cd.html