如何阅读shell命令的源代码? [英] How do I read the source code of shell commands?
问题描述
我想阅读用linux命令编写的实际源代码.我已经获得了使用它们的一些经验,现在我认为是时候与我的机器进行更深层次的互动了.
I would like to read the actual source code which the linux commands are written with. I've gained some experience using them and now I think it's time to interact with my machine at a deeper level.
我在这里找到了一些命令 http://directory.fsf.org/wiki/GNU一个>.不幸的是,我找不到基本的命令,例如"ls",在我看来这很容易上手.
I've found some commands here http://directory.fsf.org/wiki/GNU. Unfortunately I wasn't able to find basic commands such as 'ls' which seems to me easy enough to begin.
我如何准确地读取诸如'ls'之类的简单shell命令的源代码? 我在Ubuntu 12.04上运行
How exactly do I read the source code of the simple shell commands like 'ls'? I'm running on Ubuntu 12.04
推荐答案
所有这些基本命令都是coreutils
软件包的一部分.
All these basic commands are part of the coreutils
package.
您可以在此处找到所需的所有信息:
You can find all information you need here:
http://www.gnu.org/software/coreutils/
如果要下载最新的源代码,则应使用git:
If you want to download the latest source, you should use git:
git clone git://git.sv.gnu.org/coreutils
要在Ubuntu计算机上安装git,应使用apt-get(标准Ubuntu安装中不包含git):
To install git on your Ubuntu machine, you should use apt-get (git is not included in the standard Ubuntu installation):
sudo apt-get install git
需要说明的是,在这里您可以找到ls
命令的特定来源:
Truth to be told, here you can find specific source for the ls
command:
http://git.savannah.gnu. org/cgit/coreutils.git/tree/src/ls.c
仅4984条代码行足以像ls
一样使命令足够简单" ...您仍然对阅读它感兴趣吗?祝你好运! :D
Only 4984 code lines for a command 'easy enough' as ls
... are you still interested in reading it?? Good luck! :D
这篇关于如何阅读shell命令的源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!