murex Shell Docs

Command Reference: function

Define a function block


function defines a block of code as a function


function: name { code-block }

!function: command


» function hw { out "Hello, World!" }
» hw
Hello, World!

» !function hw
» hw
exec: "hw": executable file not found in $PATH


Allowed characters

Function names can only include any characters apart from dollar ($). This is to prevent functions from overwriting variables (see the order of preference below).

Undefining a function

Like all other definable states in murex, you can delete a function with the bang prefix (see the example above).

Order of preference

There is an order of precedence for which commands are looked up: 1. test and pipe functions because they alter the behavior of the compiler 2. Aliases - defined via alias. All aliases are global 3. murex functions - defined via function. All functions are global 4. private functions - defined via private. Private's cannot be global and are scoped only to the module or source that defined them. For example, You cannot call a private function from the interactive command line 5. variables (dollar prefixed) - declared via set or let 6. auto-globbing prefix: @g 7. murex builtins 8. external executable files


See Also

This 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 Tue Jun 22 08:18:17 UTC 2021 against commit 2235c7b2235c7b18f86f1cf214e246b88b0ea193d87fe80.

Current version is 2.2.1100 BETA which has been verified against tests.