Valid data types are int, float, string, time and
period. int and float are used to store integer and
floating point numbers, string to store character strings, time to
store time values for task scheduling and period to store the period
of recurring tasks. Conversion between data types happens automatically
when it makes sense; when it doesn't, the shell will complain. There
should be a table (Table ) here to show what conversions
take place.
Variables are declared as in C:
type variable_name [ = initializer ];The scope of all variables is global.
blah blah blah blah.
The shell recognizes all C arithmetic expressions valid for the data types
above. It also recognizes function calls. (The shell does not provide
procedural abstraction, so it is not possible to define functions;
you can only call built-in functions (subsection ??) or functions you
have implemented in real C and told AMBUSH about (some other
subsection)).
Expression statements, compound statements, selection statements, atomic statements and schedule statements are supported by the shell. Expression statements are familiar from C: they are of the form
expr;Compound statements are equally familiar:
{The remaining statement types are not found in C or found in modified form. They exist to add concurrency to the AMBUSH shell scripting language. We describe each statement type separately.
statement![]()
statement![]()
...
}
A selection statement has the form
if (expr) statementThis is syntactically identical to an if statement in C, but semantically different. Instead of immediately evaluating the predicate consequent, the shell continuously re-evaluates the predicate and evaluates the consequent once the predicate is met. This allows shell scripts to watch for conditions (tripped power supply, for example) and respond to them once they occur.
The shell also understands C-style if statements, where the consequent is evaluated immediately. These look thus:
immediate if (expr) statementThe C switch selection statement is not supported.
Schedule statements are the heart and soul of AMBUSH. They come in two variants. The first one, the at statement, schedules a task for execution at a specified time:
at (expr) statementexpr should evaluate to a time in the future.
The second type of schedule statement is the every statement, which repeatedly executes a task with a specified period:
every (expr) statementexpr should evaluate to a time period.
The AMBUSH system allows several tasks to be performed concurrently. Frequently a set of instructions needs to be executed as a unit, i.e. no instructions from another tasks can be executed until the entire group of instructions has been processed. Such a group of instructions is called atomic. To create an atomic group in a shell script, you can use an atomic statement:
atomic statementAll the instructions generated by the statement are guaranteed to be executed as a group. (Note that even an expression statement can generate multiple instructions.)
We need lots of built-in functions to have a working system. There should be a chapter (Ch. 8) to list them.