Harley Hahn's Guide to
|
A Personal Note
Chapters...
Command
INSTRUCTOR |
Appendix G... Shell Options & Shell Variables
Every shell supports a variety of ways for you
to control its behavior. The Bourne Shell
family (Bash, Korn Shell) uses
shell options; the For a detailed discussion of both shell options and shell variables, see Chapter 12.
The Bourne Shell family uses a large number of options to control the behavior of the shell. In particular, interactive shells require different options than non-interactive shells. (In fact, this is what makes them interactive.) There are two ways to specify such options. First, they may be invoked in the standard manner by specifying options on the command line when the shell is started. This is the case for non-interactive shells that are run automatically, and for interactive shells that you yourself start by entering a command. For example: bash -vx (By the way, these two options are particularly useful when you are testing or debugging a shell script.) Within an interactive shell — that is, at the shell prompt — you can turn options on or off as you wish. To set (turn on) an option, use the set ‑o command. To unset (turn off) an option, use the set +o command. When you use these commands, you specify the long name for the option, not its abbreviation. For example:
set -o verbose
To display the current state of all the options, use either command by itself:
set -o
The -o variation prints human-readable output; +o prints output suitable for a script. (Try them.) In all, the Bourne Shell family uses a great many shell options. In most cases, you will not need to change them, because the defaults will work just fine. For reference, however, the table in Figure G-1 summarizes the shell options for Bash and the Korn Shell. Not all options are available with all shells, so be sure to look at the leftmost column, which shows you which shells support each option. hint With Bash, there are extra options available to control a variety of features. To set and unset these options, you use the shopt ("shell options") command. The shopt options are so esoteric that you are unlikely to need them. If you have a moment, though, and you'd like to take a look at them, see the shopt man page. If you have a moment, though, and you'd like to take a look at them, the best place to read about the shopt options is the Bash man page. To find the relevant discussion, search for "shopt". Figure G-1: Bourne Shell family: Shell options |
|
|
Figure G-3: C-Shell family: Shell variables |
|
List of Chapters + Appendixes
© All contents Copyright 2024, Harley Hahn
|