Next: , Previous: , Up: VMS Installation   [Contents][Index]


B.3.2.4 Running gawk on VMS

Command-line parsing and quoting conventions are significantly different on VMS, so examples in this Web page or from other sources often need minor changes. They are minor though, and all awk programs should run correctly.

Here are a couple of trivial tests:

$ gawk -- "BEGIN {print ""Hello, World!""}"
$ gawk -"W" version
! could also be -"W version" or "-W version"

Note that uppercase and mixed-case text must be quoted.

The VMS port of gawk includes a DCL-style interface in addition to the original shell-style interface (see the help entry for details). One side effect of dual command-line parsing is that if there is only a single parameter (as in the quoted string program above), the command becomes ambiguous. To work around this, the normally optional -- flag is required to force Unix-style parsing rather than DCL parsing. If any other dash-type options (or multiple parameters such as data files to process) are present, there is no ambiguity and -- can be omitted.

The exit value is a Unix-style value and is encoded to a VMS exit status value when the program exits.

The VMS severity bits will be set based on the exit value. A failure is indicated by 1 and VMS sets the ERROR status. A fatal error is indicated by 2 and VMS will set the FATAL status. All other values will have the SUCCESS status. The exit value is encoded to comply with VMS coding standards and will have the C_FACILITY_NO of 0x350000 with the constant 0xA000 added to the number shifted over by 3 bits to make room for the severity codes.

To extract the actual gawk exit code from the VMS status use:

unix_status = (vms_status .and. &x7f8) / 8

A C program that uses exec() to call gawk will get the original Unix-style exit value.

Older versions of gawk treated a Unix exit code 0 as 1, a failure as 2, a fatal error as 4, and passed all the other numbers through. This violated the VMS exit status coding requirements.

VAX/VMS floating point uses unbiased rounding. See Round Function.

VMS reports time values in GMT unless one of the SYS$TIMEZONE_RULE or TZ logical names is set. Older versions of VMS, such as VAX/VMS 7.3 do not set these logical names.

The default search path, when looking for awk program files specified by the -f option, is "SYS$DISK:[],AWK_LIBRARY:". The logical name AWKPATH can be used to override this default. The format of AWKPATH is a comma-separated list of directory specifications. When defining it, the value should be quoted so that it retains a single translation and not a multitranslation RMS searchlist.


Next: , Previous: , Up: VMS Installation   [Contents][Index]