21.07.2015 Views

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 11: Running awk and gawk 179Section A.5 [Extensions in gawk Not in POSIX awk], page 260, which summarizesthe extensions. Also see Section C.1 [Downward Compatibility andDebugging], page 284.-W copyright--copyrightPrint the short version of the General Public License and then exit.-W copyleft--copyleftJust like ‘--copyright’. This option may disappear in a future version of gawk.-W dump-variables[=file]--dump-variables[=file]Prints a sorted list of global variables, their types, and final values to file. Ifno file is provided, gawk prints this list to the file named ‘awkvars.out’ in thecurrent directory.Having a list of all global variables is a good way to look for typographicalerrors in your programs. You would also use this option if you have a largeprogram with a lot of functions, and you want to be sure that your functionsdon’t inadvertently use global variables that you meant to be local. (This is aparticularly easy mistake to make with simple variable names like i, j, etc.)-W exec file--exec fileSimilar to ‘-f’, reads awk program text from file. There are two differences.The first is that this option also terminates option processing; anything else onthe command line is passed on directly to the awk program. The second is thatcommand line variable assignments of the form ‘var=value’ are disallowed.This option is particularly necessary for World Wide Web CGI applicationsthat pass arguments through the URL; using this option prevents a malicious(or other) user from passing in options, assignments, or awk source code (via‘--source’) to the CGI application. This option should be used with ‘#!’ scripts(see Section 1.1.4 [Executable awk Programs], page 13), like so:#! /usr/local/bin/gawk --execawk program here ...-W gen-po--gen-po-W help-W usage--help--usageAnalyzes the source program and generates a GNU gettext Portable Object fileon standard output for all string constants that have been marked for translation.See Chapter 9 [Internationalization with gawk], page 160, for informationabout this option.Prints a “usage” message summarizing the short and long style options thatgawk accepts and then exit.

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

Saved successfully!

Ooh no, something went wrong!