4 ms·
> cd is a good example of something that has to be a built-in command Theoretically you could also have a cd that would IPC the shell to change the pwd but I g
by daptaq 4y ago
> cd is a good example of something that has to be a built-in command
Theoretically you could also have a cd that would IPC the shell to change the pwd but I guess you could also say that is overengineering.
- remram 4y agoThat sounds like a weird way to implement a built-in command (the IPC handler still needs to be built-in, so you didn't really remove it from the shell). And then if course that binary would be available globally but only work if you're using the shell it's built for...
- daptaq 4y agoYeah, that is why it isn't done. I am just pointing out the pointless fact that you could write a cd command that wasn't itself built-in.
- remram 4y agoYou could hook up to the parent process with ptrace or the equivalent debugging API of your OS of choice and forcibly change the directory. Stackoverflow even has an implementation: https://unix.stackexchange.com/a/114262/81005 https://unix.stackexchange.com/a/114262/81005