Conditional execution block. If
IFis used without any suffixes (without OPERATOR part) then its argument is considered true as long as it is not empty (for strings) and not zero (for numbers). In any case all of the expressions must leave only one value in the stack.
Operator Arguments Is true if first … the second IS string, string is identical to IS_NOT string, string is different from MATCHES string, pattern matches NOT_MATCHES string, pattern does not match EQ number, number is equal to NE number, number is not equal to LE number, number is lesser then or equal to GE number, number is greater then or equal to LT number, number is lesser then GT number, number is greater then
ELSEsections are optional, there also may be no commands after each of the block headers (
ELSE). Commands after block header are executed if it is the first block header in a sequence whose condition is true. Commands after
ELSEwill be executed if there are no block headers with condition that is true.
Commands after each block header may also start their own subblocks.
Print message with the given level. Given expression may leave more then one value in the stack, in this case the whole stack will be passed to printf meaning that first value will be a format string and the following values are being inserted in this string according to it.
cmd:PRINT:message_level option controls which messages are output and which are not.
Supported levels (in order of significance):
Abort execution. This will abort with a error ID
abortedand message constructed from expr like in PRINT command.
Check whether current hoodospel version matches given one. It is considered matching if current major version number is identical to requested one and the following numbers are less then or equal to current. If some number is missing it is considered to be zero. E.g.
Current Requested Resolution
Fail (major version numbers differ)
Fail (zero is lesser then two)
Fail (two is lesser then three)
Success (one is greater then zero)
Success (missing number is zero)
Success (missing number is zero)
Run shell command. Expression given as a first argument is expected to leave more then one string in stack:
RUN_SHELL ( echo abc )will run command
RUN_SHELL "echo abc"will run command
echo abcwith no arguments (and most likely fail).
This command will fail if launched command exits with code different from zero.
IGNORE_EXIT_CODEprefixes override this behavior: first will make hoodospel expect fail if exit code is different from the one from the prefix argument, first will make hoodospel not fail regardless of exit code.
OUTPUT_TOstring was specified then launched command output will be assigned to given variable.
INPUT_STRINGstring was specified then launched command will receive given string in the stdin.
Change current directory to the given one.
Set given variable value to given value. Expression must leave only one value in the stack. Can also be used to set environment variables, but in this case expression must leave only one string value.
Delete given filesystem object. TYPE may be
EMPTY_DIRECTORY. Expression must leave exactly one string value in the stack.
Copy or move given filesystem object to given location. TYPE may be either
DIRECTORY, other prefixes specify target location:
Prefix Description TO
COPY FILE a TO bcopies file contents to file
COPY FILE a TO_DIRECTORY dcopies file contents to
COPY FILE d/a HEREcopies file contents to file
In all cases expressions must leave exactly one string value in the stack.
Create directory with given name. If
RECURSIVEprefix is given then parent directories are also created if necessary.
Substitute given pattern with given replacement string. Operates on a given variable, result is recorded back into it.
IGNORE_CASEflag makes regex engine ignore case,
REPLACE_ALLmakes hoodospel replace all occurences of a pattern (it replaces only the first by default).
Write given string to given file. When TEMP_SUFFIX expression is given then in place of writing directly to a given file it will write to
TO.TEMP_SUFFIXfile and then rename file that was written to to
Write given file contents to given variable.
Ask user a question. The result is recorded to the given variable. Question is processed in the following order (assuming key is the first value in message stack):
- Check out whether there is answer file in the current directory:
.hoodospel.ans. If there is one then it should have format “key
\tstring”. If there is one and it contains key then RESULT_TO variable is populated with the given answer. This answer is processed according to TYPE.
- Check out whether RESULT_FROM expression is not empty. If it is not it is proccessed according to given TYPE and used to populate RESULT_TO variable.
- Check out whether cmd:QUESTION:use_default option is true. If it is then DEFAULT is used to populate the variable. DEFAULT is processed according to TYPE as well.
- Last, if DEFAULT was not specified and other variants failed user is asked to answer the question. User answer is processed according to TYPE.
Type Description BOOLEAN Transforms “yes”, “y”, “true” and “1” strings to 1 and “no”, “n”, “false” and “0” strings to 0. STRING Takes string unmodified.
If cmd:QUESTION:write_answers option is true then this command also writes answer to