21.07.2015 Views

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

276 <strong>G<strong>AWK</strong></strong>: <strong>Effective</strong> <strong>AWK</strong> <strong>Programming</strong>or delete the two lines ‘#define __STDC__ 0’ and ‘#define VAXC_BUILTINS’near the end.GNU CEdit ‘vmsbuild.com’ or ‘descrip.mms’; the changes are different from thosefor VAX C V2.x but equally straightforward. No changes to ‘config.h’ areneeded.DEC C Edit ‘vmsbuild.com’ or ‘descrip.mms’ according to their comments. Nochanges to ‘config.h’ are needed.gawk has been tested under VAX/VMS 5.5-1 using VAX C V3.2, and GNU C 1.40 and2.3. It should work without modifications for VMS V4.6 and up.B.3.2.2 Installing gawk on VMSTo install gawk, all you need is a “foreign” command, which is a DCL symbol whose valuebegins with a dollar sign. For example:$ <strong>G<strong>AWK</strong></strong> :== $disk1:[gnubin]<strong>G<strong>AWK</strong></strong>Substitute the actual location of gawk.exe for ‘$disk1:[gnubin]’. The symbol should beplaced in the ‘login.com’ of any user who wants to run gawk, so that it is defined every timethe user logs on. Alternatively, the symbol may be placed in the system-wide ‘sylogin.com’procedure, which allows all users to run gawk.Optionally, the help entry can be loaded into a VMS help library:$ LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]<strong>G<strong>AWK</strong></strong>.HLP(You may want to substitute a site-specific help library rather than the standard VMSlibrary ‘HELPLIB’.) After loading the help text, the command:$ HELP <strong>G<strong>AWK</strong></strong>provides information about both the gawk implementation and the awk programming language.The logical name ‘<strong>AWK</strong>_LIBRARY’ can designate a default location for awk program files.For the ‘-f’ option, if the specified file name has no device or directory path information init, gawk looks in the current directory first, then in the directory specified by the translationof ‘<strong>AWK</strong>_LIBRARY’ if the file is not found. If, after searching in both directories, the file stillis not found, gawk appends the suffix ‘.awk’ to the filename and retries the file search. If‘<strong>AWK</strong>_LIBRARY’ is not defined, that portion of the file search fails benignly.B.3.2.3 Running gawk on VMSCommand-line parsing and quoting conventions are significantly different on VMS, so examplesin this book 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 shellstyleinterface (see the help entry for details). One side effect of dual command-line parsing

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!