Go to the previous, next section.

The Shell

The shell is the system's user interface. It allows you, the user, to enter commands which the system then performs. When the system is initialised a special shell, called the system shell is created.

Basics

Each shell simply loops reading commands until it is told to exit, each time a command is required the current prompt is printed to the tty and a line of input is read from the same tty (see section The TTY Device Driver).

Once a whole line has been read it is split into words, each of which is separated by a sequence of white-space characters (either spaces or tabs). To create a word which contains spaces it can be bracketed by two single-quote (`'') characters. If the first non-white space character in a line is a hash character (`#') the line is treated as a comment and ignored.

After tokenising its input line the shell uses the first word in the line to identify the command being invoked. It uses this word to search the table of available commands, if a match is found the action associated with this command is performed, using the remaining words in the command line as parameters.

The system is not restricted to only one shell; the shell shell command and the hot key Alt-ESC both create a new shell process, running in a new tty.

Shell Scripts

A shell script is a file containing lines of shell commands. This file can then be executed by the shell as though each line in the file had been entered by hand. The only difference is that no prompt is printed before each line. To execute a shell script use the source command.

Command: source file-name

Execute in order the lines of the file called file-name. A synonym for this command is ..

To allow you to configure the system to your needs two special shell scripts can exist,

`/.profile'
This shell script is executed when the system has finished initialising itself.

`/.shrc'
This shell script is executed each time a new interactive shell is created.

Online Help

To help you use the system the shell and its commands provide a simple online help system. Each command provides a short string documenting itself. The help shell command then uses these strings to provide short pieces of help information.

Command: help [command-name]

This command implements the shell's online help system. Invoking the command with no parameter prints a list of the available commands to the shell's tty.

When given, the command-name parameter should name a shell command, its documentation string is searched for and if it exists it will be printed to the tty.

Miscellaneous Commands

This section describes some of the other available shell commands. Note that these are only the commands provided by the shell. Commands provided by other modules of the system are documented with the rest of that module.

Command: echo args...

Prints each member of args to the tty, followed by a newline character.

Command: prompt prompt

Set the string printed before each line in this shell to prompt.

Command: quit

Terminate the current shell.

Command: cls

Clear the screen of the current shell and move the cursor to its top-left corner.

Command: shell

Spawn a new sub-shell in a new tty.

Command: ed dest-file

Copies the following lines typed at the shell's tty to the file called dest-file. The original contents of the file are discarded. End the process by typing an end-of-file character (Ctrl-d).

Go to the previous, next section.