HP 3000 Manuals

Command Line Substitutions [ System Debug Reference Manual ] MPE/iX 5.0 Documentation


System Debug Reference Manual

Command Line Substitutions 

Command line scanning proceeds from left to right and is done in two
phases.  The first preprocessing phase scans a command line for the
vertical bar character (|), which introduces the following syntax:

     |expression[:fmtspec][~]

When the command preprocessor recognizes the above syntax, it removes all
the characters associated with it from the command line and replaces them
with text representing the value of the expression.  The expression part
of the substitution syntax may be any valid expression as previously
described in this manual.  In particular, there are no special
restrictions placed on command line substitution expressions.

The optional :fmtspec represents special formatting directives that may
be used to control the formatting of the value of the expression when it
is converted to characters and inserted back into the command line.
Fmtspec is always specified as a string literal and is fully defined by
the W (WRITE) command in chapter 4.

The optional closing tilde (~) character is used to terminate the command
line substitution string when it appears adjacent to text that is not to
participate in the substitution.  The tilde is always removed as part of
the substitution.

During the preprocessing phase, a command line is scanned repeatedly
until no command line substitutions are performed.  Note that, after an
individual substitution is performed, scanning continues after the point
of substitution.  If the substituted text causes another substitution (by
containing a new vertical bar character), it is processed during the next 
scan of the command line.

The special meanings of both the vertical bar and the tilde are cancelled
when they are immediately preceded by the backslash (\) escape character.
After the preprocessing phase of command line scanning is finished, the
escape characters are removed, leaving the following vertical bar or
tilde by itself.  The practice of using the escape character to remove
the special meaning of some other character is known as escaping, and is
often used in string literals, particularly in regular expressions.
Refer to appendix A for a discussion of how patterns and regular
expression can be constructed for use in pattern matching.

Command line substitutions are performed on every command line, including
those which define macros.  If a macro definition is to contain a command
line substitution to be performed when the macro is executed, it should
be escaped to prevent it from being performed when the macro is defined.

Command line substitution is subject to the current state of the
CMDLINESUBS environment variable.  If set to FALSE, command line
substitutions are not performed.

Examples of command line substitutions are listed below:

Assuming the following declarations have been entered,

     var grp   = 'PUB' 
     var acnt  = 'SYS' 
     var cmd   = 'SYMOPEN' 
     var const = $20 
     var n     = $1 

the following examples demonstrate command line substitutions:

     symopen myfile.|grp~.|acnt

becomes

     symopen myfile.PUB.SYS

while

     while n < |const:"#" do {cmd1;cmd2;cmd3}

becomes

     while n < #32 do {cmd1;cmd2;cmd3}

which saves many searches for the constant.  And

     while |n < |const do {cmd1;cmd2;cmd3}

becomes

     while $1 < $20 do {cmd1;cmd2;cmd3}

which will loop infinitely.  Next consider the following:

     $nmdebug > var n "mom" 
     $nmdebug > wl "|n" 
     mom
     $nmdebug > wl "\|n" 
     |n

Note how the presence of the backslash cancels the command line
substitution.



MPE/iX 5.0 Documentation