next up previous contents
Next: Command Line Parsing Up: What is a Shell? Previous: Unix Commands versus Built

Interactive and Sub Shells

When a user logs onto a Unix account, a shell is immediately set running. The shell that is started depends on some predetermined settings in special files that are executed during the logon process. Ultimately then, the shell started during logon is determined by the system administrator. As will be seen in later chapters, a different shell can be set to start at logon using the chsh command. This shell is called a login (or root) shell. This is a shell that runs at all times during a users session. When the user exits the session the shell is terminated by the operating system. The login shell is a special kind of interactive shell. The purpose of an interactive shell is to let the user interact with the computer during a session. The interactive shell (as discussed briefly in the begining of this chapter) examines each command line entered by the user and then executes the command if it is correct syntactically (in usage). One must be careful when using the term correct however, as by correct it is meant that the proper usage of the command (outlined in the man page for that command) is used. The user could still enter a command that makes absolutely no sense in terms of what it accomplishes, yet is syntactically correct. The shell has no way of checking for this. A new interacive shell can be started within a login shell at any time.

A subshell is a shell that runs underneath of an interactive shell. The user cannot interact directly with a subshell as subshells only take input from commands or another shell. A subshell is really just where a command is executed. When a command line is entered in an interactive shell, the command(s) may be passed to a subshell to execute. This would occur for exemple if a group of commads is enclosed in parentheses. Programs written in the shells will be automatically executed in subshells. It is important to understand that variables declared in an interactive shell are not automatically passed to a subshell. This will be covered in more detail in the chapters pertaining to the shells themselves.


next up previous contents
Next: Command Line Parsing Up: What is a Shell? Previous: Unix Commands versus Built

Douglas M Gingrich
Mon Apr 27 15:25:49 MDT 1998