I want to be able to see the code that gets executed whenever I type 'ls' or 'cd' in my terminal. With that I would like to get into modifying existing programs and writing new ones. In what language are those programs written?
I want to be able to see the code that gets executed whenever I type 'ls' or 'cd' in my terminal. With that I would like to get into modifying existing programs and writing new ones. In what language are those programs written?
Where to find it depends on the command. There are several locations.
Regarding the two you mention:
GNU coreutils
ls
is part of GNU Coreutils. You can get the source code for all the GNU core utilities (so not just forls
: wikipedia list of core utilities) on www.gnu.org. From the command line using git (git
needs to be installed):The source for
ls
can also be found online on git.savannah.gnu.org. All the other commands are accessible there too.cd
is a built-in in the shell so is part ofbash
. You can find the source code for bash on ftp.gnu.org. That will also be the source code for all builtins.C or C++
You are better off using the existing tools and adding to them: create a script called
ls2
and then add functionality to that script to mimicls
+ your additions. Your additions could be extra letters as parameters that trigger functions. Biggest advantage: you can write it in the language you prefer. Safer since you do not mess with the normal commands if your intention is to code new functionality for your these tools you should join their respective mailing lists.