Previous | Table of Contents | Next |
The Bourne shell, written by Steve Bourne when he was at AT&T Bell Laboratories, is the original UNIX shell. This shell is preferred for shell programming because of its programming capabilities and its universal availability. It lacks features for interactive use, such as built-in arithmetic and the capability to recall previous commands (history). The Bourne shell is the default login shell for the root account, and it serves as the default user login shell if you do not specify another shell in the user's passwd file. The Bourne shell is used for all system-supplied administration scripts.
The Bourne shell command is /bin/sh. The default prompt for the Bourne shell is a dollar sign ($). The root prompt is a pound sign (#).
The Korn shell, written by David Korn of AT&T Bell Laboratories, was designed to be compatible with the Bourne shell and to offer interactive features comparable to the C shell. The Korn shell includes convenient programming features such as built-in integer arithmetic, arrays, and string-manipulation facilities. The Korn shell runs faster than the C shell, and runs virtually all scripts that are written for the Bourne shell.
The Korn shell command is /bin/ksh. The default prompt for the Korn shell is a dollar sign ($). The root prompt is a pound sign (#).
The C shell, written by Bill Joy when he was at the University of California at Berkeley, was designed to incorporate features such as aliases and command history for interactive use. The syntax for its programming features is similar to that for the C programming language.
The C shell command is /bin/csh. The default prompt for the C shell is the system name followed by a percent sign (%). The root prompt is the system name followed by a pound sign (#).
Each shell creates subshells and child processessubordinate shells and processes that are executed within the originating, or parent, shellto interpret and execute commands. For example, the following list shows a simplified version of the order in which the Korn shell processes commands:
The Bourne shell interprets commands similarly, but does not check for aliases, tildes, or arithmetic. The C shell interprets commands in a different order.
When you assign a name to a shell script, follow the general rule for naming Solaris 2.x files. Make a script name as descriptive as possible so that you can easily remember its designated function. Be careful to avoid names that Solaris 2.x itself uses for its own programs unless you intend to replace those utilities with your own scripts.
Each shell has a list of built-in commands. You should also avoid using built-in shell commands as script names. If you name a file with one of the shell built-in commandssuch as alias, break, case, cd, continue, echo, else, exit, or history for the C shellthe shell interprets the script name as a built-in shell command and tries to execute it instead of executing the script. For example, with the Bourne or Korn shell, you will run into trouble if you name a script "test," which you might easily do if you are testing something out, because test is a built-in Bourne and Korn shell command. Refer to the shell syntax sections in Chapter 17 and to the sh(1), ksh(1), and csh(1) manual pages for a complete list of built-in commands.
Previous | Table of Contents | Next |