Generic Command Language Operations

Contents

Manage processes
Redirect I/O
Execute commands
Variables
Loops and conditionals
Command languages and their shells have the following capabilities

Manage processes

The O/S is ultimately responsible for process management. The shell provides a simple interface to this. It allows
Process creation
In a command line environment, the shell usually provides a prompt at which you can type a command. In a GUI environment, it provides menus and supplies icons. A GUI will also usually provide a link between file types and the program that will handle them, so that selecting a file will start the corresponding program.
Process destruction
In a command line environment, a process may be killed by keyboard actions or by special programs. In a GUI environment it may be killed by window manager actions.
Running processes
Usually a process will start running immediately its program is ``selected''. There may be means of scheduling it to run at later times, to restart a stopped process, etc.
Process suspension
There will be a means of switching processor control away from a process till the user decides to resume it

Redirect I/O

Processes can read and write files. Often they read from a default ``standard input'' and write to a default ``standard output''. These are usually the keyboard and screen.

These can often be reset by the shell to read and write from different locations. They can be chained together for simple communication.

Execute commands

Most shells have a set of builtin commands. The Unix shells maintain ``current working directory'' in each shell. So the cd command must run as an internal command so that the shell can keep track of the value. The exit command, to terminate execution of the shell, must also be internal.

If a command is not an internal one, then it is expected to be run from a program on disk. The shell will have a means of searching for this (using the PATH variable in Unix and DOS). Once found, a new process will be started for this.

Variables

Command languages typically have untyped variables. They usually do not have to be declared. i.e. make it simple to use them.

Loops and conditionals

To qualify as a language, command languages must have some form of conditional and loop (or recursion or goto's). This in turn requires a Boolean mechanism. An appropriate one for process control languages is to use the termination status of a process.

A process is started and eventually terminates. It may consider that it has performed its task successfully, so its ``boolean'' value is true. If it failed, its ``boolean'' value is false. MSDOS uses errorlevel for this, Unix uses exit codes.

Home Program Development using Unix Home
Jan Newmarch (http://jan.newmarch.name)
jan@newmarch.name
Copyright © Jan Newmarch
Last modified: Wed Nov 19 17:36:11 EST 1997