alias
)Create an alias for a command
alias
allows you to create a shortcut or abbreviation
for a longer command.
IMPORTANT: aliases in Murex are not macros and are therefore
different than other shells. if the shortcut requires any dynamics such
as piping
, command sequencing
,
variable evaluations
or scripting
… Prefer the
function
builtin.
alias alias=command parameter parameter
!alias command
Because aliases are parsed into an array of parameters, you cannot put the entire alias within quotes. For example:
# bad :(
» alias hw="out Hello, World!"
» hw
exec "out\\ Hello,\\ World!": executable file not found in $PATH
# good :)
» alias hw=out "Hello, World!"
» hw
Hello, World!
Notice how only the command out "Hello, World!"
is
quoted in alias
the same way you would have done if you’d
run that command “naked” in the command line? This is how
alias
expects it’s parameters and where alias
on Murex differs from alias
in POSIX shells.
To materialize those differences, pay attention to the examples below:
# bad : the following statements generate errors,
# prefer function builtin to implent them
» alias myalias=out "Hello, World!" | wc
» alias myalias=out $myvariable | wc
» alias myalias=out ${vmstat} | wc
» alias myalias=out "hello" && out "world"
» alias myalias=out "hello" ; out "world"
» alias myalias="out hello; out world"
In some ways this makes alias
a little less flexible
than it might otherwise be. However the design of this is to keep
alias
focused on it’s core objective. To implement the
above aliasing, you can use function
instead.
Alias names can only include alpha-numeric characters, hyphen and
underscore. The following regex is used to validate the
alias
’s parameters:
^([-_a-zA-Z0-9]+)=(.*?)$
Like all other definable states in Murex, you can delete an alias with the bang prefix:
» alias hw=out "Hello, World!"
» hw
Hello, World!
» !alias hw
» hw
exec "hw": executable file not found in $PATH
There is an order of precedence for which commands are looked up:
runmode
: this is executed before the rest of the
script. It is invoked by the pre-compiler forking process and is
required to sit at the top of any scripts.test
and pipe
functions also alter the
behavior of the compiler and thus are executed ahead of any
scripts.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 directly
from the interactive command line (however you can force an indirect
call via fexec
).alias
. All aliases are
global.function
. All
functions are global.global
, set
or let
. Also
environmental variables too, declared via export
.You can override this order of precedence via the fexec
and exec
builtins.
alias
!alias
export
): Define an environmental variable and set it’s
valueglobal
): Define a global variable and set it’s
valuemethod
): Define a methods supported data-typesset
):
Define a variable (typically local) and set it’s valueexec
): Runs an executablefexec
): Execute a command or function, bypassing the
usual order of precedence.g
): Glob
pattern matching for file system objects (eg *.txt
)source
): Import Murex code from another file or code
blockprivate
): Define a private function blockfunction
): Define a function blocklet
: Evaluate a
mathematical function and assign to variable (deprecated)This document was generated from builtins/core/structs/function_doc.yaml.
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 Wed Jan 15 23:07:50 UTC 2025 against commit b4c4296b4c429617fd41527ea0efef33c52c15ef2b64972.
Current version is 6.4.2063 (develop) which has been verified against tests cases.