cd可执行文件的位置 [英] Location of cd executable
问题描述
我了解到,使用exec()调用发出的命令的可执行文件应该存储在PATH变量的一部分中.
I read that the executables for the commands issued using exec() calls are supposed to be stored in directories that are part of the PATH variable.
因此,我在/bin中找到了ls, chmod, grep, cat
的可执行文件.
Accordingly, I found the executables for ls, chmod, grep, cat
in /bin.
但是,我找不到cd
的可执行文件.
However, I could not find the executable for cd
.
它在哪里?
推荐答案
一个进程只能影响其自己的工作目录.当可执行文件由外壳执行时,它作为子进程执行,因此cd可执行文件(如果存在)将在不影响父进程(外壳)的情况下更改该子进程的工作目录,因此cd命令必须实现为内置的shell,实际上是在shell自己的进程中执行的.
A process can only affect its own working directory. When an executable is executed by the shell it executes as a child process, so a cd executable (if one existed) would change that child process's working directory without affecting the parent process (the shell), hence the cd command must be implemented as a shell built-in that actually executes in the shell's own process.
这篇关于cd可执行文件的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!