Previous Section
 < Day Day Up > 
Next Section


Controlling Shell Operations

The BASH shell has several features that enable you to control the way different shell operations work. For example, setting the noclobber feature prevents redirection from overwriting files. You can turn these features on and off like a toggle, using the set command. The set command takes two arguments: an option specifying on or off and the name of the feature. To set a feature on, you use the -o option, and to set it off, you use the +o option. Here is the basic form:

$ set -o feature        turn the feature on
$ set +o feature        turn the feature off

Three of the most common features are ignoreeof, noclobber, and noglob. Table 9-1 lists these different features, as well as the set command. Setting ignoreeof enables a feature that prevents you from logging out of the user shell with CTRL-D. CTRL-D is not only used to log out of the user shell, but also to end user input entered directly into the standard input. CTRL-D is used often for the Mail program or for utilities such as cat. You could easily enter an extra CTRL-D in such circumstances and accidentally log yourself out. The ignoreeof feature prevents such accidental logouts. In the next example, the ignoreeof feature is turned on using the set command with the -o option. The user can now log out only by entering the logout command.

$ set -o ignoreeof
$ ctrl-d
Use exit to logout
$
Table 9-1: BASH Shell Special Variables and Features

BASH Shell Special Variables

Description

HOME

Pathname for user's home directory

LOGNAME

Login name

USER

User name

SHELL

Pathname of program for type of shell you are using

BASH_ENV

Holds name of BASH initialization script executed whenever a BASH shell script is run or BASH shell entered; usually $HOME/.bashrc

PATH

List of pathnames for directories searched for executable commands

PS1

Primary shell prompt

PS2

Secondary shell prompt

IFS

Interfield delimiter symbol

MAIL

Name of mail file checked by Mail utility for received messages

MAILCHECK

Interval for checking for received mail

MAILPATH

List of mail files to be checked by Mail for received messages

TERM

Terminal name

CDPATH

Pathnames for directories searched by cd command for subdirectories

EXINIT

Initialization commands for Ex/Vi editor

BASH Shell Features

 

$ set -+o feature

Bash shell features are turned on and off with the set command; -o sets a feature on and +o turns it off:
$ set -o noclobber set noclobber on
$ set +o noclobber set noclobber off

ignoreeof

Disabled CTRL-D logout

noclobber

Does not overwrite files through redirection

noglob

Disables special characters used for filename expansion: *, ?, ~, and []



Previous Section
 < Day Day Up > 
Next Section
This HTML Help has been published using the chm2web software.