44.3 What's a Shell, Anyway?A shell is a program that interprets your command lines and runs other programs. Another name for the shell is "command interpreter." This article covers the two major UNIX shells, including discussion about how shells run, how they search for programs, and how they read shell script files. 44.3.1 How Shells Run Other Programs
For each command it runs, a shell does a series of steps.
First,
if the shell is reading commands from a terminal (interactively),
it prints a prompt (such as a 44.3.2 Interactive Use vs. Shell Scripts
A shell can read command lines from a terminal or it can read them from
a file.
When you put command lines into a file, that file is called a
shell script
(
44.2
)
or shell program.
The shell handles the shell script just as it handles the commands you type
from a terminal (though it doesn't print the In addition though, there are a number of programming constructs that make it possible to write shell programs that are much more powerful than just a list of commands. 44.3.3 Types of ShellsThere are two main kinds of shells in UNIX:
44.3.4 Shell Search PathsAs article 8.7 explains, if the shell is trying to run a command and the command isn't built-in to the shell itself, it looks in a list of directories called a search path . UNIX systems have standard directories with names like /bin and /usr/bin that hold standard UNIX programs. Almost everyone's search path has these directories. If you do much shell programming, you should make a directory on your account for executable files. Most people name theirs bin and put it under the home directory. See article 4.2 . 44.3.5 Bourne Shell Used HereMost serious shell programmers write their scripts for the Bourne shell. So do we. Newer Bourne shells have features - like shell functions ( 10.9 ) , an unset command for shell variables, and others - that the earlier Version 7 Bourne shell didn't. Most scripts in this book are written to work on all Bourne shells, though - for portability, the scripts don't use these new features.
For the rest of
these introductory articles,
it may be easier if you have a terminal
close by so you can try the examples.
If your account uses the Bourne shell or one of its relatives (
ksh
,
bash
, etc.), your prompt probably has a dollar sign (
% - |
|