Aliases with arguments
The built-in aliases are all simple aliases that do not take any arguments,
but you may define your own that take arguments.
If your alias definition includes the special identifiers $1 or $2 for example,
then when you use the alias,
each instance of $n will be replaced with the nth argument
in the invocation.
For example,
here is an alias to print a section of an array:
debug> alias parray {set $i = $2; \
>while ($i < $3) {print -f"[%d] = %z\n" (int)$i, $1[$i]; set ++$i}}
debug> parray arr 2 4
[2] = 100
[3] = 53
[4] = 11
You may also use the special identifiers $# and $* in an alias.
When the alias is invoked,
$# is replaced with the number of arguments actually given,
and $* is replaced with a list of all the arguments,
separated by spaces.
For example,
you can write an alias to set a breakpoint at the given address,
or, if no arguments are given,
set the breakpoint on the last line displayed:
debug> alias b if ($# > 0) {stop $*} else {stop %list_file@%list_line}
debug> b main
EVENT [1] assigned
debug> b
EVENT [2] assigned
Next topic:
Script command
Previous topic:
Technical tips
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005