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 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

Synonyms

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 Fri Sep 10 15:05:25 UTC 2021 against commit 437c274437c274fded54d82e99d70ea7d2917f332c095dd.

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