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. 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 is rebuilt weekly, the content is automatically generated from murex's source code. Last built on Mon Sep 21 06:11:30 UTC 2020 against commit 2557f7c2557f7cc7535c452c21d89164bd38ed8996f02fd. Downloadable murex binaries are also built weekly. Current version is 0.52.2000 BETA which has been verified against tests.