Special variables reserved by murex
murex reserves a few special variables which cannot be assigned via set
nor let
.
The following is a list of reserved variables, their data type, and its usage:
SELF
(json)This returns meta information about the running scope.
A ‘scope’ in murex is a collection of code blocks to which variables and config are persistent within. In murex, a variable declared inside an if
or foreach
block will be persistent outside of their blocks as long as you’re still inside the same function.
Please see scoping document (link below) for more information on scoping.
» function example { out $SELF }
» example
{
"Parent": 11357,
"Scope": 11357,
"TTY": true,
"Method": false,
"Not": false,
"Background": false,
"Module": "murex"
}
This is the function ID of the parent function that created the scope. In some instances this will be the same value as scope FID. However if in doubt then please using Scope instead.
The scope value here returns the function ID of the top level function in the scope.
A boolean value as to whether STDOUT is a TTY (ie are we printing to the terminal (TTY) or a pipe?)
A boolean value to describe whether the current scope is a method (ie being called mid-way or at the end of a pipeline).
A boolean value which represents whether the function was called with a bang- prefix or not.
A boolean value to identify whether the current scope is running in the background for foreground.
This will be the module string for the current scope.
ARGS
(json)This returns a JSON array of the command name and parameters within a given scope.
Unlike $PARAMS
, $ARGS
includes the function name.
» function example { out $ARGS }
» example abc 1 2 3
[
"example",
"abc",
"1",
"2",
"3"
]
PARAMS
(json)This returns a JSON array of the parameters within a given scope.
Unlike $ARGS
, $PARAMS
does not include the function name.
» function example { out $PARAMS }
» example abc 1 2 3
[
"abc",
"1",
"2",
"3"
]
MUREX_EXE
(str)This is very similar to the $SHELL
environmental variable in that it holds the full path to the running shell. The reason for defining a reserved variable is so that the shell path cannot be overridden.
MUREX_ARGS
(json)This is TODO: https://github.com/lmorg/murex/issues/304
HOSTNAME
(str)This returns the hostname of the machine murex is running from.
0
(str)This returns the name of the executable (like $ARGS[0]
)
1
, 2
, 3
… (str)This returns parameter n (like $ARGS[n]
). If there is no parameter n then the variable will not be set thus the upper limit variable is determined by how many parameters are set. For example if you have 19 parameters passed then variables $1
through to $19
(inclusive) will all be set.
@
) Token: Expand values as an array$
) Token: Expand values as a stringconfig
: Query or define murex runtime settingsforeach
: Iterate through an arrayfunction
: Define a function blockif
: Conditional statement to execute different blocks of code depending on the result of the conditionlet
: Evaluate a mathematical function and assign to variable (deprecated)private
: Define a private function blockset
: Define a local variable and set it’s valueswitch
: Blocks of cascading conditionalsThis site's content is rebuilt automatically from murex's source code after each merge to the master
branch. Downloadable murex binaries are also built with the website.
Last built on Mon Feb 13 09:18:06 UTC 2023 against commit f339958f33995895c1d997efcdbb8408d2c8d45f8b5f934.
Current version is which has been verified against 13950 tests cases.