cd可执行文件的位置 [英] Location of cd executable

查看:113
本文介绍了cd可执行文件的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到,使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆