Shell is an application that accepts user commands and requests to operate the system, someone will package the shell kernel out of the kernel and then package a kernel AP. I prefer not to use the same method, for me, shell is just another application. In fact, it is similar to gimp, netscape, and so on, but it will be called by login. So he is a kind of application program that can be used for failover. Using C program, we can also help you understand the historical data.
Shell is actually very simple, mainly after the user command is caught, run another process with fork (remember that unix like is a lot of work, and then ask this child process to use exec to parse this external program, such as ls, rm... and so on. So shell operations are similar)
The shell program controls the hidden screens
Run the prompt command to wait for the user to pull in.
Capture User Token
Fork () a new process
Exec () command
After running this command, return to shell.
In this example, you will see that a program running unix like uses the system call exec, this is an industry system that provides the user program with a travel mechanism. System call is the only channel between the user program and the kernel program.
In the previous ms dos generation, the program command.com on the startup line is shell. He will run
C:>
When the user crashes the command, this C: is the prompt (prompt), The bourne shell usually prompt is $, but not the difference of this dos shell function, so a well-known 4DOS shell can replace him at that time. (The 4DOS shell has many shell features on unix. Of course, unix shell is not comparable.) If you just press some icons with a mouse, then the MS-Windows Time will come later, the command line shell of X is replaced by the simplified interface. However, the host system of another program is still the same, or exec () is required ().
In addition to external commands, the transaction shell of unix like systems can parse some strings to parse the lines, the good thing about these string scripts is that some environments can be set. Combine multiple external commands to complete a task. For example, in Windows, we will also set the TMPDIR category to point to that category, and some windows programs will put some temporary cases in the original line here. The shell scripts statement method of unix like can include if, while, for loop, and so on. With some external commands, you can set different settings in different environments, this makes some daily work more responsive, and larger than the dos shell of the old hacker.
Sed, awk ...., over time, these external tools have been regarded as the mandatory command tools for the standard unix system, just as winzip may become a tool for every windows system. Many tools are unwritten built-in tools to help shell programming.