我想使用 exec()
在 c
中 source
一些 shell 脚本。
什么是source
?是 二进制可执行文件
还是 shell 脚本
?我在哪里可以在 Linux 文件系统中找到它?
我跑了
charan@PC-113:~$ which source
charan@PC-113:~$
最佳答案
这是一个内置的 shell 命令,如 cd
、exit
、pwd
...:
$ enable -p | grep source
enable source
请注意,enable -p
显示了所有内置函数。更多信息在 enable Man page .
更新
刚刚在 SuperUser 中看到一个非常有趣的线程:What does source do?
$ type source
source is a shell builtin
更新 2 - Tony D 评论
@SIGSEGV: sometimes a command can be implemented as an external (non-shell) executable, but some shells will still want to provide their own implementation... possibly with different behaviour, possibly just to make it faster. test and pwd are examples of this. For example, the shell can get its current working directory using getcwd(), but if it runs a separate executable without changing the current directory for that executable, and the executable runs getcwd() - it still works.
关于c - 在 Linux 中 "which source"什么都不返回?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17487514/