murex Shell Docs

Command Reference: function

Define a function block

Description

function defines a block of code as a function

Usage

function: name { code-block }

!function: command

Examples

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

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

Detail

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 preference for which commands are looked up: 1. Aliases - defined via alias. All aliases are global 2. murex functions - defined via function. All functions are global 3. 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 4. variables (dollar prefixed) - declared via set or let 5. auto-globbing prefix: @g 6. murex builtins 7. external executable files

Synonyms

See Also

This site is rebuilt weekly, the content is automatically generated from murex's source code. Last built on Mon May 25 06:11:51 UTC 2020 against commit aa3f3b7aa3f3b7e471543754fdcaf910d4920cad9112b91. Downloadable murex binaries are also built weekly. Current version is 0.48.0120 BETA which has been verified against 29375 tests.