gawk: VMS Running

 
 B.3.2.4 Running 'gawk' on VMS
 .............................
 
 Command-line parsing and quoting conventions are significantly different
 on VMS, so examples in this Info file 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), 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 into 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 sets 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' for VMS 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.  SeeRound
 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.
 
    This restriction also applies to running 'gawk' under GNV, as
 redirection is always to a DCL command.
 
    If you are redirecting data to a VMS command or utility, the current
 implementation requires that setting up a VMS foreign command that runs
 a command file before invoking 'gawk'.  (This restriction may be removed
 in a future release of 'gawk' on VMS.)
 
    Without this command file, the input data will also appear prepended
 to the output data.
 
    This also allows simulating POSIX commands that are not found on VMS
 or the use of GNV utilities.
 
    The example below is for 'gawk' redirecting data to the VMS 'sort'
 command.
 
      $ sort = "@device:[dir]vms_gawk_sort.com"
 
    The command file needs to be of the format in the example below.
 
    The first line inhibits the passed input data from also showing up in
 the output.  It must be in the format in the example.
 
    The next line creates a foreign command that overrides the outer
 foreign command which prevents an infinite recursion of command files.
 
    The next to the last command redirects 'sys$input' to be
 'sys$command', in order to pick up the data that is being redirected to
 the command.
 
    The last line runs the actual command.  It must be the last command
 as the data redirected from 'gawk' will be read when the command file
 ends.
 
      $!'f$verify(0,0)'
      $ sort := sort
      $ define/user sys$input sys$command:
      $ sort sys$input: sys$output: