User Tools

Site Tools


alias_command

Synopsis

alias
alias <alias-name>
alias -<alias-name>
alias <alias-name> (<argument-list>) {block}
alias <alias-name> {block}

Forms

In the first form, with no arguments, all your aliases are displayed

In the second form, with one argument, one specific alias is displayed

In the third form, with one argument, prefixed with a hyphen, one specific alias is deleted. This cannot be undone.

In the fourth form, with three arguments, the first being the name of an alias, the second being an arglist, and the third being a block statement; an alias of the specified name is created. The alias may be used as a command in a command statement, or as a function in an expando. Any arguments to the alias will be processed according to the arglist.

The fifth form is similar to the fourth form, but the arglist argument is not included. This behaves exactly the same as if you had specified an argument list of “(…)”.

Alias names

The alias name may contain any character except nul (\0). However, alias names can contain square brackets, which will be canonicalized to dots:

foo[bar][baz]

becomes

foo.bar.baz

It is recommended that you do not begin an alias name with a left parenthesis or a left curly brace because that conflicts with the ircII syntax.

Return value

Aliases are automatically provided with a local variable “FUNCTION_RETURN” the value of which is used as the alias's return value. You can either assign a value directly to it, or use the return command. If the alias is called as a command, then the return value is ignored (of course).

Aliases overrule built in commands

Aliases take precedence over both built-in commands and built-in functions (built-in commands only in EPIC4). You must take special measures to call the built-in command or function if you have overridden it with an alias.

If you need to call a builtin command after defining an alias with the same name, use two slashes:

    //builtincommand args

If you need to call a builtin function after defining an alias with the same name, use two colons before the name:

    ::builtinfunction(args)

Examples

To create an alias that overloads a command, and calls it too:

    alias lusers {
       echo -- User Information for ${[$*] ? [$*] : S}
       //lusers $*
       echo -- End User Information
    }

To create a function that returns the sum of two inputs:

    alias sum {
       @ function_return = [$0] + [$1]
    }

To create an alias that uses the new function:

    alias showsum {
       echo The sum of $0 and $1 is $sum($0 $1)
    }

To use the new /showsum command to compute a sum:

    /showsum 4 5

Using the alias as in the previous example will display the following:

    The sum of 4 and 5 is 9

History

The alias command first appeared in ircII.

#$EPIC: alias_command.txt,v 1.7 2009/08/13 04:25:48 jnelson Exp $

alias_command.txt · Last modified: 2014/04/08 14:40 by sgrubnick