vc Command

Purpose

Substitutes assigned values for identification keywords.

Syntax

vc [ -a ] [ -t ] [ -s ] [ -cCharacter ] [ Keyword=Value ]...

Description

The vc command copies lines from standard input to standard output. The flags and keywords on the command line and control statements in the input modify the resulting output. The vc command replaces user-declared keywords with the value assigned on the command line. Keywords can be replaced both in text and in control statements.

Control Statements

A control statement is a single line beginning with a control character (the default control character is a : (colon)). Control statements provide conditional processing of the input. The allowable types of control statements are:

:if Condition

Text

Item Description
:end Writes all the lines between the :if statement and the matching :end to standard output only if the condition is true. You can nest :if and :end statements. However, once a condition is false, all remaining nested :if and :end statements are ignored. See the Condition Syntax section for the syntax of conditions and allowable operators.
:dcl Keyword, [Keyword . . . ] Declares specified keywords. All keywords must be declared.
:asg Keyword=Value Assigns the specified value to the specified keyword. An :asg statement takes precedence over keyword assignment on the vc command line. A later :asg statement overrides all earlier assignments of the associated keyword. The keywords that are declared but not assigned Values, have null values.
:: Text Removes the two leading control characters, replaces keywords with their respective values, and then copies the line to standard output.
:on or :off Turns on or off keyword replacement on all lines.
:ctl Character Changes the control character to the Character value.
:msg Message Writes a message to standard error output in the form: Message(n): message
where n is number of the input line on which the message appeared.
:err Message Writes an error message to standard error. The vc command stops processing and returns an exit value of 1. The error message is in the form:
ERROR: message
ERROR: err statement on line n (vc15)

Condition Syntax

The items and statements allowed are:

condition             ::=OR statement
                      ::=NOR statement
OR statement          ::=AND statement
                      ::=AND statement | OR statement
AND statement         ::=expression
                      ::=expression & AND statement
expression            ::=( OR statement )
                      ::=value operator value
operator value        ::= = or != or < or >
                      ::= ASCII string
                      ::= numeric string

The available condition operators and their meanings are:

Item Description
= Equal
!= Not equal
& AND
&| OR
> Greater than
< Less than
( ) Used for logical groupings
NOT May only occur immediately after the if, and when present, inverts the value of the entire condition.

The > and < (greater-than and less-than) operate only on unsigned integer values; for example, 012 > 12 is false. All other operators take strings as modifiers; for example, 012 ! = 12 is true. The precedence of the operators, from highest to lowest precedence, is as follows:

Parentheses can be used to alter the order of precedence.

Values must be separated from operators or parentheses by at least one blank or tab.

Keyword Replacement

A keyword must begin and end with the same control character used in control statements. A keyword may be up to nine alphanumeric characters, where the first character must be alphabetic. Keyword values can be any ASCII string. A numeric keyword Value is an unsigned string of digits. Values cannot contain tabs or spaces.

Flags

Item Description
-a Replaces keywords surrounded by control characters with their assigned value in all text lines (not just those beginning with two control characters).
-cCharacter Uses the Character value as the control character. The Character parameter must specify an ASCII character.
-s Does not display the warning messages normally displayed to standard error.
-t Ignores all characters from the beginning of a line up to and including the first tab character for detecting a control statement. If the vc command finds a control character, it ignores all characters up to and including the tab.

Exit Status

This command returns the following exit values:

Item Description
0 Successful completion.
>0 An error occurred.

Examples

  1. Examples of Keyword=Value assignments are:
    numlines=4
    prog=acctg
    pass4=yes
    The vc command removes all control characters and keywords from input text lines marked with two control characters as it writes the text to standard output.
  2. To prevent a control character from being interpreted, precede it with a backslash, as in the following example:
    ::the :prog: program includes several of the following\:
    The :prog: keyword is replaced by its value, but the \: is passed to standard output as : (colon).

    Input lines beginning with a \ (backslash) followed by a control character are not control lines, and are copied to standard output without the backslash. However, the vc command writes lines beginning with a backslash and no following control character without any changes (including the initial backslash).

File

Item Description
/usr/bin/vc Contains the vc command.