The SUPREM-IV.GS Shell

DESCRIPTION

The shell is the user interface to the program. The shell was designed to be similar to Unix's csh(1) shell and allow some of the same actions. The shell is a command line interpreter. It reads commands from the user and executes the commands with the arguments listed.

The shell executes commands from the system wide model file to set up coefficients. It then executes commands from the file .supremrc before providing a user prompt. This allows start up commands to be executed before the session begins. The .supremrc file is looked for in the current directory and the user's home directory.

COMMANDS

A simple command is a sequence of words, the first of which specifies the command to be executed. Sequences of commands may be separated by semicolons (;), and are then executed sequentially. A command may be executed in background mode by following the last entry with an ampersand (&) character.

Any sequence may be placed in braces to form a simple command.

Built-In Command Summary

Built-in commands are executed within the shell. The built-in commands are:
define
define name wordlist
define name( args ) wordlist
The first form prints all aliases. The second and third forms assign the specified wordlist as the macro of name. Every occurrence of name in the input stream is replaced by the wordlist associated with it. Optionally, as shown in the third form, a definition can contain arguments which will be mapped when the macro is substituted. name will only be substituted for when it is separated by blank space or shell special characters.

foreach name ( val1, val2, val3 ) commands end
name is set to each of the values contained in the parenthesis consecutively and the commands are executed. This allows a command to be run several times with different parameters. name is substituted in the commands using the macro features.

help command
help without any arguments will list all of the available commands. The command "help command_name" will give information on the listed command name. When used in the second style, the help command provides a list of parameters and short description of each of the parameters.

Man command
man examines the command name and attempts to find a manual page for that command. The manual pages are piped through more(1) for user viewing.

set ( echo | noexecute | prompt string )
This command allows the parameters listed to be changed. echo causes the command buffer to be echoed. noexecute is described in the non-built-in command section below. prompt is the string which appears when the shell is ready to accept input. set with no input lists the current settings.

source filename
The source command allows the file filename to be opened and the contents of the file are placed in the input stream of the shell to be parsed.

undef name
This command removes the macro name from the macro table.

unset ( echo | noexecute )
This command turns off the echo or noexecute modes.

Non-Built-In Command Execution

If a command is entered that is not a built-in, the program checks its parse tables for that command. If the command is found, that parameters are passed to the command for execution.

If the noexecute flag is set, the command will only check on the parameters to see if they are legal. It will exit without performing any action other that the check. This mode is useful for debugging long scripts of input.

Macro Substitution

A command line is scanned, it is parsed into distinct words and each word is checked to see if it is in the macro table. If it is, then the text which is the macro for that command is placed in the input stream. To disable macro substitution, the % character can be used at the beginning of the line. That line will not be macro expanded. Selective macro evaluation can be achieved by disabling macros (with %) and putting $ before the names which are desired to be evaluated. That is, use $name (or ${name} in cases of ambiguity). The intent is to provide shell variables in a simple way.

If a macro is found, substitution is performed of the macro body for the macro name. Any arguments are paired up and they are substituted as well. Macro arguments may not be other macros.

Command Line Parsing

The shell splits input lines into words at blanks and tabs. The following exceptions (parser metacharacters) are considered separate words:

& - ampersand;
; - semicolon;
> - greater-than sign;
{ - left brace;
} - right brace;
% - percent sign.

These characters have special meaning to the shell and are described else- where.

Input/Output

The standard output of a command may be redirected with the following syntax: > name. The file is used as standard output. If the file does not exist then it is created; if the file exists, it is appended to. The entire output of the sequence redirected is sent to the file. There is a limit on the number of open files. It is not suggested that redirection be nested in a loop.

Background

Any sequence of commands may be backgrounded by using the & character. These commands will be executed using a fork and exec call. They will work on the current state of the data space but will not modify the copy you have. The copy will begin execution immediately and return a prompt to the user without waiting for the copy to finish.

EXAMPLES

foo
execute command foo with no parameters.

foo val=1.0 file=name
execute command foo with parameter string val=1.0 file=name.

foo; bar
execute command foo followed by command bar

foo > name
execute command foo and sends it output into file name.

foo; bar > name
execute commands foo and bar and send their output to file name.

foo &
execute command foo in the background.

BUGS

Numeric expressions are handled by an ad hoc parser, separate and different from the shell yacc parser. If a complicated expression gives unexpected results, parenthesize.