[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 System User's Guide: Operating System and Devices

Bourne Shell

The Bourne shell is an interactive command interpreter and command programming language. The bsh command runs the Bourne shell. /P>

The Bourne shell can be run either as a login shell or as a subshell under the login shell. Only the login command can call the Bourne shell as a login shell. It does this by using a special form of the bsh command name: -bsh. When called with an initial - (hyphen), the shell first reads and runs commands found in the system /etc/profile file and your $HOME/.profile, if one exists. The /etc/profile file sets variables needed by all users. Finally, the shell is ready to read commands from your standard input.

If the File [Parameter] parameter is specified when the Bourne shell is started, the shell runs the script file identified by the File parameter, including any parameters specified. The script file specified must have read permission; any setuid and setgid settings are ignored. The commands are then read. A script file should not be specified if either the -c or -s flag is used.

This section discusses:

Bourne Shell Environment

All variables (with their associated values) known to a command at the beginning of its execution constitute its environment. This environment includes variables that a command inherits from its parent process and variables specified as keyword parameters on the command line that calls the command.

The shell passes to its child processes the variables named as arguments to the built-in export command. This command places the named variables in the environments of both the shell and all its future child processes.

Keyword parameters are variable-value pairs that appear in the form of assignments, normally before the procedure name on a command line (but see also the flag for the set command). Such variables are placed in the environment of the procedure being called.

For example, consider the following simple procedure, which displays the values of two variables (saved in a command file named key_command):

# key_command
echo $a $b

The following command lines produce the output shown:

Input                              Output
a=key1   b=key2  key_command       key1 key2
a=tom    b=john  key_command       tom john

A procedure's keyword parameters are not included in the parameter count stored in $#.

A procedure can access the values of any variables in its environment. If it changes any of these values, however, the changes are not reflected in the shell environment. They are local to the procedure in question. To place the changes in the environment that the procedure passes to its child processes, you must export the new values within that procedure.

To obtain a list of variables that are exportable from the current shell, enter:

export

To obtain a list of read-only variables from the current shell, enter:

readonly

To obtain a list of variable-value pairs in the current environment, enter:

env

For more information about user environments, see /etc/environment File


[ Previous | Next | Contents | Glossary | Home | Search ]