Command History and Aliases
The ObjectScript shell supports an extensive line recall facility, with an option to search previous commands, as well as a facility for defining aliases for commands. These options are not an extension to ObjectScript and cannot be used in routines and methods.
Line Recall Facility
In addition to the up arrow, the ObjectScript shell also supports a more extensive line recall facility, which uses a list of commands stored in the history buffer. It enables you to recall specific previously entered commands.
To activate line recall, type colon (:) followed by one or more characters that unambiguously identify the command.
You can issue a number of special commands that interact with line recall at the command prompt. First, the :? displays a quick help:
:<number> Recall command # <number>
:alias Create/display aliases
:clear Clear history buffer
:history Display command history
:unalias Remove aliases
The :history command produces a numbered list of commands stored in the history buffer. You can use these numbers to recall a particular command, as shown in the following example:
1: zn "%SYS"
2: Do ^SYSLOG
3: write "Hello"," World!"
4: write $J
write "Hello"," World!"
The :alias command creates shortcuts for ObjectScript commands commonly typed at the prompt, and :unalias <name> removes the definition associated with that name. See Creating Aliases.
The :clear command deletes all the contents from the recall buffer, but does not delete ~\.iris_history.
Reverse Incremental Search
Reverse incremental search (RIS) is an additional mode of operation of the ObjectScript shell recall facility. You enter this mode by typing Ctrl+R. In order to use RIS mode, there must be commands stored in the recall buffer. If the buffer is empty, the bell rings and nothing else happens. Two backslash characters after the prompt indicate RIS mode:
The search string appears between the two backslashes, and the matching command, if any, appears to the right. As you type characters in the search string, the system scans the command history buffer in the same direction as typing up-arrow, from most recent to least recent. It stops at the first command that contains the string. Press Enter to execute the command.
For example, if the command W $J is in the recall buffer, after typing the '$' key, the ObjectScript shell might display this:
If you want to find the command W $ZV instead, type the following character, Z:
On operating systems that support ANSI attributes, the matching characters in the recalled command will be displayed with the bold attribute.
You exit the RIS mode when you type:
Enter – selects and immediately executes the command.
Ctrl+G – cancels RIS mode and goes back to the previous prompt without any command.
An editing key, like the left arrow or Ctrl+A – this enters edit mode and allows you to edit the recalled command line.
Up or down arrow – selects the previous or next command relative to the one that had been selected by the search.
You continue in the search mode when you type one of the following:
A non control character – the character is appended to the search string and the system tries to find the previous command that contains the new string.
Ctrl+R – searches for the previous command containing the same search string.
DEL or BS – erases the rightmost character of the search string and takes you back to the corresponding command.
To define a shortcut for issuing a command, enter the :alias command followed by the alternative name you want to assign to the command (the alias) and then the command you want to assign to that alias. For the rest of the session, you can issue the command by invoking the alias, preceded by the : character.
In the example session which follows, the :alias command issued in the first line allows the user to switch to the USER namespace in the second line by simply entering the string :u:
%SYS>:alias u set $namespace="USER"
It is also possible to pass arguments to a command using an alias. As part of the alias definition, include numbered host variables prefixed by the $ character as placeholders for each argument in the command. Then, invoke the alias followed by the values of the arguments in the order indicated by the host variable numbers.
For example, issuing the following command creates a shortcut (load) to load a file at a location which will be provided as the first argument ($1)with flags specified by the second argument ($2):
USER>:alias load Do $System.OBJ.Load("$1","$2")
To use this alias to load a file found at the path /directory/foobar.xml with the c and k flags, you can now simply enter the following:
USER>:load /directory/foobar.xml ck
The placeholder variables in a command can also be part of an ObjectScript expression. For example, the following command uses the $SELECT function to set "ck" as the default second argument when no second argument is provided:
USER>:alias load Do $System.OBJ.Load("$1", $S("$2"="":"ck", 1:"$2"))
To remove an alias definition, enter the command :unalias followed by the alias name. Enter :alias with no arguments to see a list of the aliases defined in the current session.
If you are using a UNIX® or Linux system, you can provide a list of alias definitions which the ObjectScript shell will set automatically at the start of every session. Define these aliases (one per line) in a file named .iris_init in the home directory.