Go to: Synopsis. Return value. MEL examples.

Synopsis

alias <aliasName> <commandName> [ arg_1 ... arg_n ] or { list-of-statements }

alias is undoable, NOT queryable, and NOT editable.

MEL aliases don't work exactly like csh aliases. When MEL sees the use of an alias, it doesn't replace the alias name with the text of what it is aliased with and rescan that. It can't do that. It isn't a command line interpreter like csh is. When MEL sees an alias command, it enters the name into the same procedure table with the regular user written MEL procedures and it keeps a pointer to the argument list passed to it (in the case of the first syntax). When someone uses name in a script, it is processed just like a procedure call. You cannot pass arguments to an alias specified as a statement list.

MEL is an interpreter in the sense that it generates a data structure instead of real machine code. Instead of having your machine execute the output, MEL executes it by interpreting the data structure it generated for your code. Shell interpreters execute input as it is being read in. This allows them to do text replacement on the fly. Fortunately MEL has procedures which make up for any functionality that is missing from its own version of aliases.

Special Notes:

  1. You can nest aliases.
  2. You can't use variables in aliases. This is because MEL isn't a command line interpreter. If you were to alias to something which used to a local variable, MEL wouldn't be able to detect when the access of that variable was out of scope. It is difficult (read: expensive) for MEL to detect these sorts of errors, so user beware.
  3. Aliases have the same scope as the procedures/commands which they alias. If you alias a local procedure, the alias will become unavailable when the local procedure goes out of scope.
  4. "alias" is a directive and not a command. The alias is created when the script is read, not when it is actually executed. So, you cannot put an "alias" directive in an if statement have it created or not based on the code path taken. The alias will already have been created by the time the code is executed. To create an alias conditionally, it would have to be embedded in an "eval" directive so that it is compiled at runtime.

Return value

None

MEL examples

alias s sphere -r;
s 2.2;  // creates a sphere of radius 2.2.
alias s2 s 2;  // nested alias: sphere -r 2.
alias es s -esw;
es 90;  // syntax error: sphere -r -esw
alias jj { select -all; delete; };