-------------- The Unix Shell -------------- -IAN! idallen@idallen.ca What is a shell for? To find and run programs (also called commands or utilities)! (It also does programming kinds of things; but, all that is usually to aid in the finding and running of programs.) Most (but not all) commands take what as arguments? Pathnames, either file names or directory names. The shell has features to make matching pathnames easier. (Not *all* programs take pathnames as arguments!) How does the shell help run commands? Shells look for commands in various places, using a list of directories stored in the $PATH environment variable. Shells provide aliases and variables to save typing the same things (commands or pathnames) over and over. Shells provide wildcards (glob patterns) to generate lists of pathnames as arguments for commands. Shells provide ways of recalling and editing the last commands you enter, to save retyping them. Shells provide ways of completing command and file names, to save typing. Where are wildcard characters (glob patterns) expanded? The shell does the wildcard (glob) expansion, NOT the commands. The wildcards are expanded before the shell looks for the command! Note how different commands treat the same set of arguments differently: $ echo * - args are interpreted as a list of text words $ ls -l * - args are interpreted as a list of pathnames (files or dirs) $ cat * - args are interpreted as a list of file names to open $ mail * - args are interpreted as a list of userids to email The shell does not know anything about the type of command being used when it prepares the argument list for a command. It is quite possible to prepare a list of arguments that don't make sense for the command being run, e.g. $ sleep * - this probably makes no sense Define these terms: whitespace, arguments, wildcard, prompt ------------- Nested Shells ------------- Your default login shell on ACADUNIX is the Korn shell (ksh). Your default login shell on Linux is the Bourne-Again shell (bash). You can call up other shells by name: sh, ksh, bash, csh, tcsh (Not all shells may be installed on your system.) Each new shell is another Unix process. To get a list of your current processes, use: ps To exit from a shell: exit When you exit from your first, login shell, you log out from Unix. Another way to exit a shell is to type your EOF character. (Your EOF character is usualy CONTROL-D.) Some shells can be told to ignore EOF. Remember: all Unix programs (should) have manual pages! $ man sh $ man ksh $ man bash $ man csh $ man tcsh The shells sh, ksh, and bash (the "Bourne" shells) all have a common ancestry. They are all derived from the original Bourne shell "sh", and the programming features of these shells (if statements, for loops, etc.) all look and work the same way. The shells csh and tcsh (the "C" shells) are similar. Their syntax for programming is not the same as the Bourne shells. We do not cover the C shell syntax in this course.