3.3 OptionsWhile aliases let you create convenient names for commands, they don't really let you change the shell's behavior. Options are one way of doing this. A shell option is a setting that is either "on" or "off." While several options relate to arcane shell features that are of interest only to programmers, those that we will cover here are of interest to all users. The basic commands that relate to options are set -o optionnames and set +o optionnames , where optionnames is a list of option names separated by blanks. The use of plus (+ ) and minus (- ) signs is counterintuitive: the - turns the named option on, while the + turns it off. The reason for this incongruity is that the dash (- ) is the conventional UNIX way of specifying options to a command, while the use of + is an afterthought. Most options also have one-letter abbreviations that can be used in lieu of the set -o command; for example, set -o noglob can be abbreviated set -f . These abbreviations are carry-overs from the Bourne shell. Like several other "extra" Korn shell features, they exist to ensure upward compatibility; otherwise, their use is not encouraged. Table 3.1 lists the options that are useful to general UNIX users. All of them are off by default except as noted.
There are several other options (22 in all; Appendix B lists them). To check the status of an option, just type set -o . The Korn shell will print a list of all options along with their settings. There is no direct way to test a single option, but here is a simple shell function to do it: function testopt { if [[ -o $1 ]] ; then print Option $1 is on. else print Option $1 is off. fi } Shell functions will be covered in the next chapter. For now, though, if you want to use the testopt function, just type it into your .profile or environment file (see the section entitled "The Environment File"), then type either login or . .profile . Then you can type testopt optionname to check the status of an option. |
|