When a script with a declaration block is run, interactively or
from another script, this is what happens in detail:
-
The script declaration is read and checked for errors.
Imported parameters ("
params from
") are resolved
recursively.
-
Actual parameter values are taken from, in order:
-
The supplied arguments, if the script was started from a
shell command, or from run-command-file.
-
CLI variables.
-
Default values from the script declaration.
An error is signalled if a parameter value is missing or has the
wrong type.
-
The current CLI variables, if any, are saved away and replaced with
the script parameters having their initial values as described above.
-
The command part of the script (below the declaration) is executed.
If the script runs another script, this entire algorithm is used
again.
-
CLI variables corresponding to declared result names are
retrieved. An error is signalled for missing results or ones
with the wrong type.
-
The saved CLI variables are restored, throwing away all current
variables except for the declared results, which retain their
values from the executed script.