Shell commands are written in what language?

There are many shell commands, for example,

ls, cd, cat etc.

What programming language is used when writing these commands? How are they made up?

My understanding:

Shell is a program which takes command; ** does this mean that it interprets those commands(like ls is interpreted by shell program)?** 

Another question, in what language is Shell program written?

+10
linux bash shell kernel
source share
3 answers

Most basic linux utilities are written in C This can be checked in busybox source code , which supports most of the basic Linux commands written in C So the command ls, cd ... etc. Located in C

How the shell interprets the check below the link

the operating system has a special program called the shell. The shell accepts user-readable instructions and converts them into something that the kernel can read and process.

http://www.math.iitb.ac.in/resources/manuals/Unix_Unleashed/Vol_1/ch08.htm

+4
source share

These programs are mostly written in the C programming language, like the linux kernel.

+5
source share

Programs are a regular executable file written in any language (mainly C).

The shell accepts an input command that is just a string. He then looks for specific sequences of characters that have particular meaning for the shell, such as environment variables that are $ , followed by a word or redirects that are > , followed by a path. After this substitution has been preformed, it has a line that is split into spaces to generate the name of the executable file and parameters. The shell will then search for the executable in the directory list in the PATH environment variable. The shell then uses system calls to create a process from an executable file with parameters.

For example, to execute the ls $HOME , the shell first recognizes that $HOME is an environment variable and substitutes its value in this case /home/user , leaving the ls /home/user . He then splits the command into space to get the ls executable and the /home/user option. The shell finds the first executable that matches ls usually /bin/ls . He then uses the on-air calls to spawn () / posix_spawn () or fork () and exec () to create a new process.

+1
source share

All Articles