diff options
-rw-r--r-- | doc/ChangeLog | 4 | ||||
-rw-r--r-- | doc/gawk.info | 1191 | ||||
-rw-r--r-- | doc/gawk.texi | 92 | ||||
-rw-r--r-- | doc/gawktexi.in | 92 |
4 files changed, 820 insertions, 559 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index e6b14381..d49a77db 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,9 @@ 2014-12-24 Arnold D. Robbins <arnold@skeeve.com> + * gawktexi.in: Start documenting nonfatal output. + +2014-12-24 Arnold D. Robbins <arnold@skeeve.com> + * gawktexi.in: Add one more paragraph to new foreword. * gawktexi.in: Fix exponentiation in TeX mode. Thanks to Marco Curreli by way of Antonio Giovanni. diff --git a/doc/gawk.info b/doc/gawk.info index 37494e64..92495978 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -246,6 +246,7 @@ entitled "GNU Free Documentation License". * Special Caveats:: Things to watch out for. * Close Files And Pipes:: Closing Input and Output Files and Pipes. +* Nonfatal:: Enabling Nonfatal Output. * Output Summary:: Output summary. * Output Exercises:: Exercises. * Values:: Constants, Variables, and Regular @@ -6119,6 +6120,7 @@ function. `gawk' allows access to inherited file descriptors. * Close Files And Pipes:: Closing Input and Output Files and Pipes. +* Nonfatal:: Enabling Nonfatal Output. * Output Summary:: Output summary. * Output Exercises:: Exercises. @@ -7032,7 +7034,7 @@ that `gawk' provides: behavior. -File: gawk.info, Node: Close Files And Pipes, Next: Output Summary, Prev: Special Files, Up: Printing +File: gawk.info, Node: Close Files And Pipes, Next: Nonfatal, Prev: Special Files, Up: Printing 5.9 Closing Input and Output Redirections ========================================= @@ -7201,9 +7203,56 @@ call. See the system manual pages for information on how to decode this value. -File: gawk.info, Node: Output Summary, Next: Output Exercises, Prev: Close Files And Pipes, Up: Printing +File: gawk.info, Node: Nonfatal, Next: Output Summary, Prev: Close Files And Pipes, Up: Printing -5.10 Summary +5.10 Enabling Nonfatal Output +============================= + +This minor node describes a `gawk'-specific feature. + + In standard `awk', output with `print' or `printf' to a nonexistent +file, or some other I/O error (such as filling up the disk) is a fatal +error. + + $ gawk 'BEGIN { print "hi" > "/no/such/file" }' + error--> gawk: cmd. line:1: fatal: can't redirect to `/no/such/file' (No such file or directory) + + `gawk' makes it possible to detect that an error has occurred, +allowing you to possibly recover from the error, or at least print an +error message of your choosing before exiting. You can do this in one +of two ways: + + * For all output files, by assigning any value to + `PROCINFO["nonfatal"]'. + + * On a per-file basis, by assigning any value to `PROCINFO[FILENAME, + "nonfatal"]'. Here, FILENAME is the name of the file to which you + wish output to be nonfatal. + + Once you have enabled nonfatal output, you must check `ERRNO' after +every relevant `print' or `printf' statement to see if something went +wrong. It is also a good idea to initialize `ERRNO' to zero before +attempting the output. For example: + + $ gawk ' + > BEGIN { + > PROCINFO["nonfatal"] = 1 + > ERRNO = 0 + > print "hi" > "/no/such/file" + > if (ERRNO) { + > print("Output failed:", ERRNO) > "/dev/stderr" + > exit 1 + > } + > }' + error--> Output failed: No such file or directory + + Here, `gawk' did not produce a fatal error; instead it let the `awk' +program code detect the problem and handle it. + + +File: gawk.info, Node: Output Summary, Next: Output Exercises, Prev: Nonfatal, Up: Printing + +5.11 Summary ============ * The `print' statement prints comma-separated expressions. Each @@ -7225,11 +7274,16 @@ File: gawk.info, Node: Output Summary, Next: Output Exercises, Prev: Close Fi For coprocesses, it is possible to close only one direction of the communications. + * Normally errors with `print' or `printf' are fatal. `gawk' lets + you make output errors be nonfatal either for all files or on a + per-file basis. You must then check for errors after every + relevant output statement. + File: gawk.info, Node: Output Exercises, Prev: Output Summary, Up: Printing -5.11 Exercises +5.12 Exercises ============== 1. Rewrite the program: @@ -26931,6 +26985,24 @@ in POSIX `awk', in the order they were added to `gawk'. Dynamic Extensions::). + Version *FIXME* XXXX introduced the following changes: + + * Changes to `ENVIRON' are reflected into `gawk''s environment and + that of programs that it runs. *Note Auto-set::. + + * The `--pretty-print' option no longer runs the `awk' program too. + FIXME: Add xref. + + * The `igawk' program and its manual page are no longer installed + when `gawk' is built. FIXME: Add xref. + + * The `div()' function. FIXME: Add xref. + + * The maximum number of hexdecimal digits in `\x' escapes is now two. + FIXME: Add xref. + + * Nonfatal output with `print' and `printf'. *Note Nonfatal::. + File: gawk.info, Node: Common Extensions, Next: Ranges and Locales, Prev: Feature History, Up: Language History @@ -34453,560 +34525,561 @@ Index Tag Table: Node: Top1204 -Node: Foreword342225 -Node: Foreword446667 -Node: Preface48189 -Ref: Preface-Footnote-151060 -Ref: Preface-Footnote-251167 -Ref: Preface-Footnote-351400 -Node: History51542 -Node: Names53888 -Ref: Names-Footnote-154982 -Node: This Manual55128 -Ref: This Manual-Footnote-161615 -Node: Conventions61715 -Node: Manual History64053 -Ref: Manual History-Footnote-167035 -Ref: Manual History-Footnote-267076 -Node: How To Contribute67150 -Node: Acknowledgments68279 -Node: Getting Started73084 -Node: Running gawk75517 -Node: One-shot76707 -Node: Read Terminal77955 -Node: Long79982 -Node: Executable Scripts81498 -Ref: Executable Scripts-Footnote-184287 -Node: Comments84390 -Node: Quoting86872 -Node: DOS Quoting92396 -Node: Sample Data Files93071 -Node: Very Simple95666 -Node: Two Rules100564 -Node: More Complex102450 -Node: Statements/Lines105312 -Ref: Statements/Lines-Footnote-1109767 -Node: Other Features110032 -Node: When110963 -Ref: When-Footnote-1112717 -Node: Intro Summary112782 -Node: Invoking Gawk113665 -Node: Command Line115179 -Node: Options115977 -Ref: Options-Footnote-1131781 -Ref: Options-Footnote-2132010 -Node: Other Arguments132035 -Node: Naming Standard Input134983 -Node: Environment Variables136076 -Node: AWKPATH Variable136634 -Ref: AWKPATH Variable-Footnote-1140047 -Ref: AWKPATH Variable-Footnote-2140092 -Node: AWKLIBPATH Variable140352 -Node: Other Environment Variables141608 -Node: Exit Status145096 -Node: Include Files145772 -Node: Loading Shared Libraries149369 -Node: Obsolete150796 -Node: Undocumented151493 -Node: Invoking Summary151760 -Node: Regexp153424 -Node: Regexp Usage154878 -Node: Escape Sequences156915 -Node: Regexp Operators163156 -Ref: Regexp Operators-Footnote-1170582 -Ref: Regexp Operators-Footnote-2170729 -Node: Bracket Expressions170827 -Ref: table-char-classes172842 -Node: Leftmost Longest175766 -Node: Computed Regexps177068 -Node: GNU Regexp Operators180465 -Node: Case-sensitivity184138 -Ref: Case-sensitivity-Footnote-1187023 -Ref: Case-sensitivity-Footnote-2187258 -Node: Regexp Summary187366 -Node: Reading Files188833 -Node: Records190927 -Node: awk split records191660 -Node: gawk split records196575 -Ref: gawk split records-Footnote-1201119 -Node: Fields201156 -Ref: Fields-Footnote-1203932 -Node: Nonconstant Fields204018 -Ref: Nonconstant Fields-Footnote-1206261 -Node: Changing Fields206465 -Node: Field Separators212394 -Node: Default Field Splitting215099 -Node: Regexp Field Splitting216216 -Node: Single Character Fields219566 -Node: Command Line Field Separator220625 -Node: Full Line Fields223837 -Ref: Full Line Fields-Footnote-1225354 -Ref: Full Line Fields-Footnote-2225400 -Node: Field Splitting Summary225501 -Node: Constant Size227575 -Node: Splitting By Content232164 -Ref: Splitting By Content-Footnote-1236158 -Node: Multiple Line236321 -Ref: Multiple Line-Footnote-1242207 -Node: Getline242386 -Node: Plain Getline244598 -Node: Getline/Variable247238 -Node: Getline/File248386 -Node: Getline/Variable/File249770 -Ref: Getline/Variable/File-Footnote-1251373 -Node: Getline/Pipe251460 -Node: Getline/Variable/Pipe254143 -Node: Getline/Coprocess255274 -Node: Getline/Variable/Coprocess256526 -Node: Getline Notes257265 -Node: Getline Summary260057 -Ref: table-getline-variants260469 -Node: Read Timeout261298 -Ref: Read Timeout-Footnote-1265123 -Node: Command-line directories265181 -Node: Input Summary266086 -Node: Input Exercises269387 -Node: Printing270115 -Node: Print271892 -Node: Print Examples273349 -Node: Output Separators276128 -Node: OFMT278146 -Node: Printf279500 -Node: Basic Printf280285 -Node: Control Letters281855 -Node: Format Modifiers285838 -Node: Printf Examples291847 -Node: Redirection294333 -Node: Special FD301174 -Ref: Special FD-Footnote-1304334 -Node: Special Files304408 -Node: Other Inherited Files305025 -Node: Special Network306025 -Node: Special Caveats306887 -Node: Close Files And Pipes307838 -Ref: Close Files And Pipes-Footnote-1315020 -Ref: Close Files And Pipes-Footnote-2315168 -Node: Output Summary315318 -Node: Output Exercises316316 -Node: Expressions316996 -Node: Values318181 -Node: Constants318859 -Node: Scalar Constants319550 -Ref: Scalar Constants-Footnote-1320409 -Node: Nondecimal-numbers320659 -Node: Regexp Constants323677 -Node: Using Constant Regexps324202 -Node: Variables327345 -Node: Using Variables328000 -Node: Assignment Options329911 -Node: Conversion331786 -Node: Strings And Numbers332310 -Ref: Strings And Numbers-Footnote-1335375 -Node: Locale influences conversions335484 -Ref: table-locale-affects338231 -Node: All Operators338819 -Node: Arithmetic Ops339449 -Node: Concatenation341954 -Ref: Concatenation-Footnote-1344773 -Node: Assignment Ops344879 -Ref: table-assign-ops349858 -Node: Increment Ops351130 -Node: Truth Values and Conditions354568 -Node: Truth Values355653 -Node: Typing and Comparison356702 -Node: Variable Typing357512 -Node: Comparison Operators361165 -Ref: table-relational-ops361575 -Node: POSIX String Comparison365070 -Ref: POSIX String Comparison-Footnote-1366142 -Node: Boolean Ops366280 -Ref: Boolean Ops-Footnote-1370759 -Node: Conditional Exp370850 -Node: Function Calls372577 -Node: Precedence376457 -Node: Locales380118 -Node: Expressions Summary381750 -Node: Patterns and Actions384310 -Node: Pattern Overview385430 -Node: Regexp Patterns387109 -Node: Expression Patterns387652 -Node: Ranges391362 -Node: BEGIN/END394468 -Node: Using BEGIN/END395229 -Ref: Using BEGIN/END-Footnote-1397963 -Node: I/O And BEGIN/END398069 -Node: BEGINFILE/ENDFILE400383 -Node: Empty403284 -Node: Using Shell Variables403601 -Node: Action Overview405874 -Node: Statements408200 -Node: If Statement410048 -Node: While Statement411543 -Node: Do Statement413572 -Node: For Statement414716 -Node: Switch Statement417873 -Node: Break Statement420255 -Node: Continue Statement422296 -Node: Next Statement424123 -Node: Nextfile Statement426504 -Node: Exit Statement429134 -Node: Built-in Variables431537 -Node: User-modified432670 -Ref: User-modified-Footnote-1440351 -Node: Auto-set440413 -Ref: Auto-set-Footnote-1454105 -Ref: Auto-set-Footnote-2454310 -Node: ARGC and ARGV454366 -Node: Pattern Action Summary458584 -Node: Arrays461011 -Node: Array Basics462340 -Node: Array Intro463184 -Ref: figure-array-elements465148 -Ref: Array Intro-Footnote-1467674 -Node: Reference to Elements467802 -Node: Assigning Elements470254 -Node: Array Example470745 -Node: Scanning an Array472503 -Node: Controlling Scanning475519 -Ref: Controlling Scanning-Footnote-1480715 -Node: Numeric Array Subscripts481031 -Node: Uninitialized Subscripts483216 -Node: Delete484833 -Ref: Delete-Footnote-1487576 -Node: Multidimensional487633 -Node: Multiscanning490730 -Node: Arrays of Arrays492319 -Node: Arrays Summary497078 -Node: Functions499170 -Node: Built-in500069 -Node: Calling Built-in501147 -Node: Numeric Functions503138 -Ref: Numeric Functions-Footnote-1507957 -Ref: Numeric Functions-Footnote-2508314 -Ref: Numeric Functions-Footnote-3508362 -Node: String Functions508634 -Ref: String Functions-Footnote-1532109 -Ref: String Functions-Footnote-2532238 -Ref: String Functions-Footnote-3532486 -Node: Gory Details532573 -Ref: table-sub-escapes534354 -Ref: table-sub-proposed535874 -Ref: table-posix-sub537238 -Ref: table-gensub-escapes538774 -Ref: Gory Details-Footnote-1539606 -Node: I/O Functions539757 -Ref: I/O Functions-Footnote-1546975 -Node: Time Functions547122 -Ref: Time Functions-Footnote-1557610 -Ref: Time Functions-Footnote-2557678 -Ref: Time Functions-Footnote-3557836 -Ref: Time Functions-Footnote-4557947 -Ref: Time Functions-Footnote-5558059 -Ref: Time Functions-Footnote-6558286 -Node: Bitwise Functions558552 -Ref: table-bitwise-ops559114 -Ref: Bitwise Functions-Footnote-1563423 -Node: Type Functions563592 -Node: I18N Functions564743 -Node: User-defined566388 -Node: Definition Syntax567193 -Ref: Definition Syntax-Footnote-1572600 -Node: Function Example572671 -Ref: Function Example-Footnote-1575590 -Node: Function Caveats575612 -Node: Calling A Function576130 -Node: Variable Scope577088 -Node: Pass By Value/Reference580076 -Node: Return Statement583571 -Node: Dynamic Typing586552 -Node: Indirect Calls587481 -Ref: Indirect Calls-Footnote-1598783 -Node: Functions Summary598911 -Node: Library Functions601613 -Ref: Library Functions-Footnote-1605222 -Ref: Library Functions-Footnote-2605365 -Node: Library Names605536 -Ref: Library Names-Footnote-1608990 -Ref: Library Names-Footnote-2609213 -Node: General Functions609299 -Node: Strtonum Function610402 -Node: Assert Function613424 -Node: Round Function616748 -Node: Cliff Random Function618289 -Node: Ordinal Functions619305 -Ref: Ordinal Functions-Footnote-1622368 -Ref: Ordinal Functions-Footnote-2622620 -Node: Join Function622831 -Ref: Join Function-Footnote-1624600 -Node: Getlocaltime Function624800 -Node: Readfile Function628544 -Node: Shell Quoting630514 -Node: Data File Management631915 -Node: Filetrans Function632547 -Node: Rewind Function636603 -Node: File Checking637990 -Ref: File Checking-Footnote-1639322 -Node: Empty Files639523 -Node: Ignoring Assigns641502 -Node: Getopt Function643053 -Ref: Getopt Function-Footnote-1654515 -Node: Passwd Functions654715 -Ref: Passwd Functions-Footnote-1663552 -Node: Group Functions663640 -Ref: Group Functions-Footnote-1671534 -Node: Walking Arrays671747 -Node: Library Functions Summary673350 -Node: Library Exercises674751 -Node: Sample Programs676031 -Node: Running Examples676801 -Node: Clones677529 -Node: Cut Program678753 -Node: Egrep Program688472 -Ref: Egrep Program-Footnote-1695970 -Node: Id Program696080 -Node: Split Program699725 -Ref: Split Program-Footnote-1703173 -Node: Tee Program703301 -Node: Uniq Program706090 -Node: Wc Program713509 -Ref: Wc Program-Footnote-1717759 -Node: Miscellaneous Programs717853 -Node: Dupword Program719066 -Node: Alarm Program721097 -Node: Translate Program725901 -Ref: Translate Program-Footnote-1730466 -Node: Labels Program730736 -Ref: Labels Program-Footnote-1734087 -Node: Word Sorting734171 -Node: History Sorting738242 -Node: Extract Program740078 -Node: Simple Sed747603 -Node: Igawk Program750671 -Ref: Igawk Program-Footnote-1764995 -Ref: Igawk Program-Footnote-2765196 -Ref: Igawk Program-Footnote-3765318 -Node: Anagram Program765433 -Node: Signature Program768490 -Node: Programs Summary769737 -Node: Programs Exercises770930 -Ref: Programs Exercises-Footnote-1775061 -Node: Advanced Features775152 -Node: Nondecimal Data777100 -Node: Array Sorting778690 -Node: Controlling Array Traversal779387 -Ref: Controlling Array Traversal-Footnote-1787720 -Node: Array Sorting Functions787838 -Ref: Array Sorting Functions-Footnote-1791727 -Node: Two-way I/O791923 -Ref: Two-way I/O-Footnote-1796868 -Ref: Two-way I/O-Footnote-2797054 -Node: TCP/IP Networking797136 -Node: Profiling800009 -Node: Advanced Features Summary808286 -Node: Internationalization810219 -Node: I18N and L10N811699 -Node: Explaining gettext812385 -Ref: Explaining gettext-Footnote-1817410 -Ref: Explaining gettext-Footnote-2817594 -Node: Programmer i18n817759 -Ref: Programmer i18n-Footnote-1822625 -Node: Translator i18n822674 -Node: String Extraction823468 -Ref: String Extraction-Footnote-1824599 -Node: Printf Ordering824685 -Ref: Printf Ordering-Footnote-1827471 -Node: I18N Portability827535 -Ref: I18N Portability-Footnote-1829990 -Node: I18N Example830053 -Ref: I18N Example-Footnote-1832856 -Node: Gawk I18N832928 -Node: I18N Summary833566 -Node: Debugger834905 -Node: Debugging835927 -Node: Debugging Concepts836368 -Node: Debugging Terms838221 -Node: Awk Debugging840793 -Node: Sample Debugging Session841687 -Node: Debugger Invocation842207 -Node: Finding The Bug843591 -Node: List of Debugger Commands850066 -Node: Breakpoint Control851399 -Node: Debugger Execution Control855095 -Node: Viewing And Changing Data858459 -Node: Execution Stack861837 -Node: Debugger Info863474 -Node: Miscellaneous Debugger Commands867491 -Node: Readline Support872520 -Node: Limitations873412 -Node: Debugging Summary875526 -Node: Arbitrary Precision Arithmetic876694 -Node: Computer Arithmetic878110 -Ref: table-numeric-ranges881708 -Ref: Computer Arithmetic-Footnote-1882567 -Node: Math Definitions882624 -Ref: table-ieee-formats885912 -Ref: Math Definitions-Footnote-1886516 -Node: MPFR features886621 -Node: FP Math Caution888292 -Ref: FP Math Caution-Footnote-1889342 -Node: Inexactness of computations889711 -Node: Inexact representation890670 -Node: Comparing FP Values892027 -Node: Errors accumulate893109 -Node: Getting Accuracy894542 -Node: Try To Round897204 -Node: Setting precision898103 -Ref: table-predefined-precision-strings898787 -Node: Setting the rounding mode900576 -Ref: table-gawk-rounding-modes900940 -Ref: Setting the rounding mode-Footnote-1904395 -Node: Arbitrary Precision Integers904574 -Ref: Arbitrary Precision Integers-Footnote-1909473 -Node: POSIX Floating Point Problems909622 -Ref: POSIX Floating Point Problems-Footnote-1913495 -Node: Floating point summary913533 -Node: Dynamic Extensions915727 -Node: Extension Intro917279 -Node: Plugin License918545 -Node: Extension Mechanism Outline919342 -Ref: figure-load-extension919770 -Ref: figure-register-new-function921250 -Ref: figure-call-new-function922254 -Node: Extension API Description924240 -Node: Extension API Functions Introduction925690 -Node: General Data Types930514 -Ref: General Data Types-Footnote-1936253 -Node: Memory Allocation Functions936552 -Ref: Memory Allocation Functions-Footnote-1939391 -Node: Constructor Functions939487 -Node: Registration Functions941221 -Node: Extension Functions941906 -Node: Exit Callback Functions944203 -Node: Extension Version String945451 -Node: Input Parsers946116 -Node: Output Wrappers955995 -Node: Two-way processors960510 -Node: Printing Messages962714 -Ref: Printing Messages-Footnote-1963790 -Node: Updating `ERRNO'963942 -Node: Requesting Values964682 -Ref: table-value-types-returned965410 -Node: Accessing Parameters966367 -Node: Symbol Table Access967598 -Node: Symbol table by name968112 -Node: Symbol table by cookie970093 -Ref: Symbol table by cookie-Footnote-1974237 -Node: Cached values974300 -Ref: Cached values-Footnote-1977799 -Node: Array Manipulation977890 -Ref: Array Manipulation-Footnote-1978988 -Node: Array Data Types979025 -Ref: Array Data Types-Footnote-1981680 -Node: Array Functions981772 -Node: Flattening Arrays985626 -Node: Creating Arrays992518 -Node: Extension API Variables997289 -Node: Extension Versioning997925 -Node: Extension API Informational Variables999826 -Node: Extension API Boilerplate1000891 -Node: Finding Extensions1004700 -Node: Extension Example1005260 -Node: Internal File Description1006032 -Node: Internal File Ops1010099 -Ref: Internal File Ops-Footnote-11021769 -Node: Using Internal File Ops1021909 -Ref: Using Internal File Ops-Footnote-11024292 -Node: Extension Samples1024565 -Node: Extension Sample File Functions1026091 -Node: Extension Sample Fnmatch1033729 -Node: Extension Sample Fork1035220 -Node: Extension Sample Inplace1036435 -Node: Extension Sample Ord1038110 -Node: Extension Sample Readdir1038946 -Ref: table-readdir-file-types1039822 -Node: Extension Sample Revout1040633 -Node: Extension Sample Rev2way1041223 -Node: Extension Sample Read write array1041963 -Node: Extension Sample Readfile1043903 -Node: Extension Sample Time1044998 -Node: Extension Sample API Tests1046347 -Node: gawkextlib1046838 -Node: Extension summary1049496 -Node: Extension Exercises1053185 -Node: Language History1053907 -Node: V7/SVR3.11055563 -Node: SVR41057744 -Node: POSIX1059189 -Node: BTL1060578 -Node: POSIX/GNU1061312 -Node: Feature History1066936 -Node: Common Extensions1080034 -Node: Ranges and Locales1081358 -Ref: Ranges and Locales-Footnote-11085976 -Ref: Ranges and Locales-Footnote-21086003 -Ref: Ranges and Locales-Footnote-31086237 -Node: Contributors1086458 -Node: History summary1091999 -Node: Installation1093369 -Node: Gawk Distribution1094315 -Node: Getting1094799 -Node: Extracting1095622 -Node: Distribution contents1097257 -Node: Unix Installation1103322 -Node: Quick Installation1104005 -Node: Shell Startup Files1106416 -Node: Additional Configuration Options1107495 -Node: Configuration Philosophy1109234 -Node: Non-Unix Installation1111603 -Node: PC Installation1112061 -Node: PC Binary Installation1113380 -Node: PC Compiling1115228 -Ref: PC Compiling-Footnote-11118249 -Node: PC Testing1118358 -Node: PC Using1119534 -Node: Cygwin1123649 -Node: MSYS1124472 -Node: VMS Installation1124972 -Node: VMS Compilation1125764 -Ref: VMS Compilation-Footnote-11126986 -Node: VMS Dynamic Extensions1127044 -Node: VMS Installation Details1128728 -Node: VMS Running1130980 -Node: VMS GNV1133816 -Node: VMS Old Gawk1134550 -Node: Bugs1135020 -Node: Other Versions1138903 -Node: Installation summary1145331 -Node: Notes1146387 -Node: Compatibility Mode1147252 -Node: Additions1148034 -Node: Accessing The Source1148959 -Node: Adding Code1150395 -Node: New Ports1156560 -Node: Derived Files1161042 -Ref: Derived Files-Footnote-11166517 -Ref: Derived Files-Footnote-21166551 -Ref: Derived Files-Footnote-31167147 -Node: Future Extensions1167261 -Node: Implementation Limitations1167867 -Node: Extension Design1169115 -Node: Old Extension Problems1170269 -Ref: Old Extension Problems-Footnote-11171786 -Node: Extension New Mechanism Goals1171843 -Ref: Extension New Mechanism Goals-Footnote-11175203 -Node: Extension Other Design Decisions1175392 -Node: Extension Future Growth1177500 -Node: Old Extension Mechanism1178336 -Node: Notes summary1180098 -Node: Basic Concepts1181284 -Node: Basic High Level1181965 -Ref: figure-general-flow1182237 -Ref: figure-process-flow1182836 -Ref: Basic High Level-Footnote-11186065 -Node: Basic Data Typing1186250 -Node: Glossary1189578 -Node: Copying1214736 -Node: GNU Free Documentation License1252292 -Node: Index1277428 +Node: Foreword342291 +Node: Foreword446733 +Node: Preface48255 +Ref: Preface-Footnote-151126 +Ref: Preface-Footnote-251233 +Ref: Preface-Footnote-351466 +Node: History51608 +Node: Names53954 +Ref: Names-Footnote-155048 +Node: This Manual55194 +Ref: This Manual-Footnote-161681 +Node: Conventions61781 +Node: Manual History64119 +Ref: Manual History-Footnote-167101 +Ref: Manual History-Footnote-267142 +Node: How To Contribute67216 +Node: Acknowledgments68345 +Node: Getting Started73150 +Node: Running gawk75583 +Node: One-shot76773 +Node: Read Terminal78021 +Node: Long80048 +Node: Executable Scripts81564 +Ref: Executable Scripts-Footnote-184353 +Node: Comments84456 +Node: Quoting86938 +Node: DOS Quoting92462 +Node: Sample Data Files93137 +Node: Very Simple95732 +Node: Two Rules100630 +Node: More Complex102516 +Node: Statements/Lines105378 +Ref: Statements/Lines-Footnote-1109833 +Node: Other Features110098 +Node: When111029 +Ref: When-Footnote-1112783 +Node: Intro Summary112848 +Node: Invoking Gawk113731 +Node: Command Line115245 +Node: Options116043 +Ref: Options-Footnote-1131847 +Ref: Options-Footnote-2132076 +Node: Other Arguments132101 +Node: Naming Standard Input135049 +Node: Environment Variables136142 +Node: AWKPATH Variable136700 +Ref: AWKPATH Variable-Footnote-1140113 +Ref: AWKPATH Variable-Footnote-2140158 +Node: AWKLIBPATH Variable140418 +Node: Other Environment Variables141674 +Node: Exit Status145162 +Node: Include Files145838 +Node: Loading Shared Libraries149435 +Node: Obsolete150862 +Node: Undocumented151559 +Node: Invoking Summary151826 +Node: Regexp153490 +Node: Regexp Usage154944 +Node: Escape Sequences156981 +Node: Regexp Operators163222 +Ref: Regexp Operators-Footnote-1170648 +Ref: Regexp Operators-Footnote-2170795 +Node: Bracket Expressions170893 +Ref: table-char-classes172908 +Node: Leftmost Longest175832 +Node: Computed Regexps177134 +Node: GNU Regexp Operators180531 +Node: Case-sensitivity184204 +Ref: Case-sensitivity-Footnote-1187089 +Ref: Case-sensitivity-Footnote-2187324 +Node: Regexp Summary187432 +Node: Reading Files188899 +Node: Records190993 +Node: awk split records191726 +Node: gawk split records196641 +Ref: gawk split records-Footnote-1201185 +Node: Fields201222 +Ref: Fields-Footnote-1203998 +Node: Nonconstant Fields204084 +Ref: Nonconstant Fields-Footnote-1206327 +Node: Changing Fields206531 +Node: Field Separators212460 +Node: Default Field Splitting215165 +Node: Regexp Field Splitting216282 +Node: Single Character Fields219632 +Node: Command Line Field Separator220691 +Node: Full Line Fields223903 +Ref: Full Line Fields-Footnote-1225420 +Ref: Full Line Fields-Footnote-2225466 +Node: Field Splitting Summary225567 +Node: Constant Size227641 +Node: Splitting By Content232230 +Ref: Splitting By Content-Footnote-1236224 +Node: Multiple Line236387 +Ref: Multiple Line-Footnote-1242273 +Node: Getline242452 +Node: Plain Getline244664 +Node: Getline/Variable247304 +Node: Getline/File248452 +Node: Getline/Variable/File249836 +Ref: Getline/Variable/File-Footnote-1251439 +Node: Getline/Pipe251526 +Node: Getline/Variable/Pipe254209 +Node: Getline/Coprocess255340 +Node: Getline/Variable/Coprocess256592 +Node: Getline Notes257331 +Node: Getline Summary260123 +Ref: table-getline-variants260535 +Node: Read Timeout261364 +Ref: Read Timeout-Footnote-1265189 +Node: Command-line directories265247 +Node: Input Summary266152 +Node: Input Exercises269453 +Node: Printing270181 +Node: Print272016 +Node: Print Examples273473 +Node: Output Separators276252 +Node: OFMT278270 +Node: Printf279624 +Node: Basic Printf280409 +Node: Control Letters281979 +Node: Format Modifiers285962 +Node: Printf Examples291971 +Node: Redirection294457 +Node: Special FD301298 +Ref: Special FD-Footnote-1304458 +Node: Special Files304532 +Node: Other Inherited Files305149 +Node: Special Network306149 +Node: Special Caveats307011 +Node: Close Files And Pipes307962 +Ref: Close Files And Pipes-Footnote-1315138 +Ref: Close Files And Pipes-Footnote-2315286 +Node: Nonfatal315436 +Node: Output Summary317122 +Node: Output Exercises318343 +Node: Expressions319023 +Node: Values320208 +Node: Constants320886 +Node: Scalar Constants321577 +Ref: Scalar Constants-Footnote-1322436 +Node: Nondecimal-numbers322686 +Node: Regexp Constants325704 +Node: Using Constant Regexps326229 +Node: Variables329372 +Node: Using Variables330027 +Node: Assignment Options331938 +Node: Conversion333813 +Node: Strings And Numbers334337 +Ref: Strings And Numbers-Footnote-1337402 +Node: Locale influences conversions337511 +Ref: table-locale-affects340258 +Node: All Operators340846 +Node: Arithmetic Ops341476 +Node: Concatenation343981 +Ref: Concatenation-Footnote-1346800 +Node: Assignment Ops346906 +Ref: table-assign-ops351885 +Node: Increment Ops353157 +Node: Truth Values and Conditions356595 +Node: Truth Values357680 +Node: Typing and Comparison358729 +Node: Variable Typing359539 +Node: Comparison Operators363192 +Ref: table-relational-ops363602 +Node: POSIX String Comparison367097 +Ref: POSIX String Comparison-Footnote-1368169 +Node: Boolean Ops368307 +Ref: Boolean Ops-Footnote-1372786 +Node: Conditional Exp372877 +Node: Function Calls374604 +Node: Precedence378484 +Node: Locales382145 +Node: Expressions Summary383777 +Node: Patterns and Actions386337 +Node: Pattern Overview387457 +Node: Regexp Patterns389136 +Node: Expression Patterns389679 +Node: Ranges393389 +Node: BEGIN/END396495 +Node: Using BEGIN/END397256 +Ref: Using BEGIN/END-Footnote-1399990 +Node: I/O And BEGIN/END400096 +Node: BEGINFILE/ENDFILE402410 +Node: Empty405311 +Node: Using Shell Variables405628 +Node: Action Overview407901 +Node: Statements410227 +Node: If Statement412075 +Node: While Statement413570 +Node: Do Statement415599 +Node: For Statement416743 +Node: Switch Statement419900 +Node: Break Statement422282 +Node: Continue Statement424323 +Node: Next Statement426150 +Node: Nextfile Statement428531 +Node: Exit Statement431161 +Node: Built-in Variables433564 +Node: User-modified434697 +Ref: User-modified-Footnote-1442378 +Node: Auto-set442440 +Ref: Auto-set-Footnote-1456132 +Ref: Auto-set-Footnote-2456337 +Node: ARGC and ARGV456393 +Node: Pattern Action Summary460611 +Node: Arrays463038 +Node: Array Basics464367 +Node: Array Intro465211 +Ref: figure-array-elements467175 +Ref: Array Intro-Footnote-1469701 +Node: Reference to Elements469829 +Node: Assigning Elements472281 +Node: Array Example472772 +Node: Scanning an Array474530 +Node: Controlling Scanning477546 +Ref: Controlling Scanning-Footnote-1482742 +Node: Numeric Array Subscripts483058 +Node: Uninitialized Subscripts485243 +Node: Delete486860 +Ref: Delete-Footnote-1489603 +Node: Multidimensional489660 +Node: Multiscanning492757 +Node: Arrays of Arrays494346 +Node: Arrays Summary499105 +Node: Functions501197 +Node: Built-in502096 +Node: Calling Built-in503174 +Node: Numeric Functions505165 +Ref: Numeric Functions-Footnote-1509984 +Ref: Numeric Functions-Footnote-2510341 +Ref: Numeric Functions-Footnote-3510389 +Node: String Functions510661 +Ref: String Functions-Footnote-1534136 +Ref: String Functions-Footnote-2534265 +Ref: String Functions-Footnote-3534513 +Node: Gory Details534600 +Ref: table-sub-escapes536381 +Ref: table-sub-proposed537901 +Ref: table-posix-sub539265 +Ref: table-gensub-escapes540801 +Ref: Gory Details-Footnote-1541633 +Node: I/O Functions541784 +Ref: I/O Functions-Footnote-1549002 +Node: Time Functions549149 +Ref: Time Functions-Footnote-1559637 +Ref: Time Functions-Footnote-2559705 +Ref: Time Functions-Footnote-3559863 +Ref: Time Functions-Footnote-4559974 +Ref: Time Functions-Footnote-5560086 +Ref: Time Functions-Footnote-6560313 +Node: Bitwise Functions560579 +Ref: table-bitwise-ops561141 +Ref: Bitwise Functions-Footnote-1565450 +Node: Type Functions565619 +Node: I18N Functions566770 +Node: User-defined568415 +Node: Definition Syntax569220 +Ref: Definition Syntax-Footnote-1574627 +Node: Function Example574698 +Ref: Function Example-Footnote-1577617 +Node: Function Caveats577639 +Node: Calling A Function578157 +Node: Variable Scope579115 +Node: Pass By Value/Reference582103 +Node: Return Statement585598 +Node: Dynamic Typing588579 +Node: Indirect Calls589508 +Ref: Indirect Calls-Footnote-1600810 +Node: Functions Summary600938 +Node: Library Functions603640 +Ref: Library Functions-Footnote-1607249 +Ref: Library Functions-Footnote-2607392 +Node: Library Names607563 +Ref: Library Names-Footnote-1611017 +Ref: Library Names-Footnote-2611240 +Node: General Functions611326 +Node: Strtonum Function612429 +Node: Assert Function615451 +Node: Round Function618775 +Node: Cliff Random Function620316 +Node: Ordinal Functions621332 +Ref: Ordinal Functions-Footnote-1624395 +Ref: Ordinal Functions-Footnote-2624647 +Node: Join Function624858 +Ref: Join Function-Footnote-1626627 +Node: Getlocaltime Function626827 +Node: Readfile Function630571 +Node: Shell Quoting632541 +Node: Data File Management633942 +Node: Filetrans Function634574 +Node: Rewind Function638630 +Node: File Checking640017 +Ref: File Checking-Footnote-1641349 +Node: Empty Files641550 +Node: Ignoring Assigns643529 +Node: Getopt Function645080 +Ref: Getopt Function-Footnote-1656542 +Node: Passwd Functions656742 +Ref: Passwd Functions-Footnote-1665579 +Node: Group Functions665667 +Ref: Group Functions-Footnote-1673561 +Node: Walking Arrays673774 +Node: Library Functions Summary675377 +Node: Library Exercises676778 +Node: Sample Programs678058 +Node: Running Examples678828 +Node: Clones679556 +Node: Cut Program680780 +Node: Egrep Program690499 +Ref: Egrep Program-Footnote-1697997 +Node: Id Program698107 +Node: Split Program701752 +Ref: Split Program-Footnote-1705200 +Node: Tee Program705328 +Node: Uniq Program708117 +Node: Wc Program715536 +Ref: Wc Program-Footnote-1719786 +Node: Miscellaneous Programs719880 +Node: Dupword Program721093 +Node: Alarm Program723124 +Node: Translate Program727928 +Ref: Translate Program-Footnote-1732493 +Node: Labels Program732763 +Ref: Labels Program-Footnote-1736114 +Node: Word Sorting736198 +Node: History Sorting740269 +Node: Extract Program742105 +Node: Simple Sed749630 +Node: Igawk Program752698 +Ref: Igawk Program-Footnote-1767022 +Ref: Igawk Program-Footnote-2767223 +Ref: Igawk Program-Footnote-3767345 +Node: Anagram Program767460 +Node: Signature Program770517 +Node: Programs Summary771764 +Node: Programs Exercises772957 +Ref: Programs Exercises-Footnote-1777088 +Node: Advanced Features777179 +Node: Nondecimal Data779127 +Node: Array Sorting780717 +Node: Controlling Array Traversal781414 +Ref: Controlling Array Traversal-Footnote-1789747 +Node: Array Sorting Functions789865 +Ref: Array Sorting Functions-Footnote-1793754 +Node: Two-way I/O793950 +Ref: Two-way I/O-Footnote-1798895 +Ref: Two-way I/O-Footnote-2799081 +Node: TCP/IP Networking799163 +Node: Profiling802036 +Node: Advanced Features Summary810313 +Node: Internationalization812246 +Node: I18N and L10N813726 +Node: Explaining gettext814412 +Ref: Explaining gettext-Footnote-1819437 +Ref: Explaining gettext-Footnote-2819621 +Node: Programmer i18n819786 +Ref: Programmer i18n-Footnote-1824652 +Node: Translator i18n824701 +Node: String Extraction825495 +Ref: String Extraction-Footnote-1826626 +Node: Printf Ordering826712 +Ref: Printf Ordering-Footnote-1829498 +Node: I18N Portability829562 +Ref: I18N Portability-Footnote-1832017 +Node: I18N Example832080 +Ref: I18N Example-Footnote-1834883 +Node: Gawk I18N834955 +Node: I18N Summary835593 +Node: Debugger836932 +Node: Debugging837954 +Node: Debugging Concepts838395 +Node: Debugging Terms840248 +Node: Awk Debugging842820 +Node: Sample Debugging Session843714 +Node: Debugger Invocation844234 +Node: Finding The Bug845618 +Node: List of Debugger Commands852093 +Node: Breakpoint Control853426 +Node: Debugger Execution Control857122 +Node: Viewing And Changing Data860486 +Node: Execution Stack863864 +Node: Debugger Info865501 +Node: Miscellaneous Debugger Commands869518 +Node: Readline Support874547 +Node: Limitations875439 +Node: Debugging Summary877553 +Node: Arbitrary Precision Arithmetic878721 +Node: Computer Arithmetic880137 +Ref: table-numeric-ranges883735 +Ref: Computer Arithmetic-Footnote-1884594 +Node: Math Definitions884651 +Ref: table-ieee-formats887939 +Ref: Math Definitions-Footnote-1888543 +Node: MPFR features888648 +Node: FP Math Caution890319 +Ref: FP Math Caution-Footnote-1891369 +Node: Inexactness of computations891738 +Node: Inexact representation892697 +Node: Comparing FP Values894054 +Node: Errors accumulate895136 +Node: Getting Accuracy896569 +Node: Try To Round899231 +Node: Setting precision900130 +Ref: table-predefined-precision-strings900814 +Node: Setting the rounding mode902603 +Ref: table-gawk-rounding-modes902967 +Ref: Setting the rounding mode-Footnote-1906422 +Node: Arbitrary Precision Integers906601 +Ref: Arbitrary Precision Integers-Footnote-1911500 +Node: POSIX Floating Point Problems911649 +Ref: POSIX Floating Point Problems-Footnote-1915522 +Node: Floating point summary915560 +Node: Dynamic Extensions917754 +Node: Extension Intro919306 +Node: Plugin License920572 +Node: Extension Mechanism Outline921369 +Ref: figure-load-extension921797 +Ref: figure-register-new-function923277 +Ref: figure-call-new-function924281 +Node: Extension API Description926267 +Node: Extension API Functions Introduction927717 +Node: General Data Types932541 +Ref: General Data Types-Footnote-1938280 +Node: Memory Allocation Functions938579 +Ref: Memory Allocation Functions-Footnote-1941418 +Node: Constructor Functions941514 +Node: Registration Functions943248 +Node: Extension Functions943933 +Node: Exit Callback Functions946230 +Node: Extension Version String947478 +Node: Input Parsers948143 +Node: Output Wrappers958022 +Node: Two-way processors962537 +Node: Printing Messages964741 +Ref: Printing Messages-Footnote-1965817 +Node: Updating `ERRNO'965969 +Node: Requesting Values966709 +Ref: table-value-types-returned967437 +Node: Accessing Parameters968394 +Node: Symbol Table Access969625 +Node: Symbol table by name970139 +Node: Symbol table by cookie972120 +Ref: Symbol table by cookie-Footnote-1976264 +Node: Cached values976327 +Ref: Cached values-Footnote-1979826 +Node: Array Manipulation979917 +Ref: Array Manipulation-Footnote-1981015 +Node: Array Data Types981052 +Ref: Array Data Types-Footnote-1983707 +Node: Array Functions983799 +Node: Flattening Arrays987653 +Node: Creating Arrays994545 +Node: Extension API Variables999316 +Node: Extension Versioning999952 +Node: Extension API Informational Variables1001853 +Node: Extension API Boilerplate1002918 +Node: Finding Extensions1006727 +Node: Extension Example1007287 +Node: Internal File Description1008059 +Node: Internal File Ops1012126 +Ref: Internal File Ops-Footnote-11023796 +Node: Using Internal File Ops1023936 +Ref: Using Internal File Ops-Footnote-11026319 +Node: Extension Samples1026592 +Node: Extension Sample File Functions1028118 +Node: Extension Sample Fnmatch1035756 +Node: Extension Sample Fork1037247 +Node: Extension Sample Inplace1038462 +Node: Extension Sample Ord1040137 +Node: Extension Sample Readdir1040973 +Ref: table-readdir-file-types1041849 +Node: Extension Sample Revout1042660 +Node: Extension Sample Rev2way1043250 +Node: Extension Sample Read write array1043990 +Node: Extension Sample Readfile1045930 +Node: Extension Sample Time1047025 +Node: Extension Sample API Tests1048374 +Node: gawkextlib1048865 +Node: Extension summary1051523 +Node: Extension Exercises1055212 +Node: Language History1055934 +Node: V7/SVR3.11057590 +Node: SVR41059771 +Node: POSIX1061216 +Node: BTL1062605 +Node: POSIX/GNU1063339 +Node: Feature History1068963 +Node: Common Extensions1082665 +Node: Ranges and Locales1083989 +Ref: Ranges and Locales-Footnote-11088607 +Ref: Ranges and Locales-Footnote-21088634 +Ref: Ranges and Locales-Footnote-31088868 +Node: Contributors1089089 +Node: History summary1094630 +Node: Installation1096000 +Node: Gawk Distribution1096946 +Node: Getting1097430 +Node: Extracting1098253 +Node: Distribution contents1099888 +Node: Unix Installation1105953 +Node: Quick Installation1106636 +Node: Shell Startup Files1109047 +Node: Additional Configuration Options1110126 +Node: Configuration Philosophy1111865 +Node: Non-Unix Installation1114234 +Node: PC Installation1114692 +Node: PC Binary Installation1116011 +Node: PC Compiling1117859 +Ref: PC Compiling-Footnote-11120880 +Node: PC Testing1120989 +Node: PC Using1122165 +Node: Cygwin1126280 +Node: MSYS1127103 +Node: VMS Installation1127603 +Node: VMS Compilation1128395 +Ref: VMS Compilation-Footnote-11129617 +Node: VMS Dynamic Extensions1129675 +Node: VMS Installation Details1131359 +Node: VMS Running1133611 +Node: VMS GNV1136447 +Node: VMS Old Gawk1137181 +Node: Bugs1137651 +Node: Other Versions1141534 +Node: Installation summary1147962 +Node: Notes1149018 +Node: Compatibility Mode1149883 +Node: Additions1150665 +Node: Accessing The Source1151590 +Node: Adding Code1153026 +Node: New Ports1159191 +Node: Derived Files1163673 +Ref: Derived Files-Footnote-11169148 +Ref: Derived Files-Footnote-21169182 +Ref: Derived Files-Footnote-31169778 +Node: Future Extensions1169892 +Node: Implementation Limitations1170498 +Node: Extension Design1171746 +Node: Old Extension Problems1172900 +Ref: Old Extension Problems-Footnote-11174417 +Node: Extension New Mechanism Goals1174474 +Ref: Extension New Mechanism Goals-Footnote-11177834 +Node: Extension Other Design Decisions1178023 +Node: Extension Future Growth1180131 +Node: Old Extension Mechanism1180967 +Node: Notes summary1182729 +Node: Basic Concepts1183915 +Node: Basic High Level1184596 +Ref: figure-general-flow1184868 +Ref: figure-process-flow1185467 +Ref: Basic High Level-Footnote-11188696 +Node: Basic Data Typing1188881 +Node: Glossary1192209 +Node: Copying1217367 +Node: GNU Free Documentation License1254923 +Node: Index1280059 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 1c3c0f78..871c9ea8 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -632,6 +632,7 @@ particular records in a file and perform operations upon them. * Special Caveats:: Things to watch out for. * Close Files And Pipes:: Closing Input and Output Files and Pipes. +* Nonfatal:: Enabling Nonfatal Output. * Output Summary:: Output summary. * Output Exercises:: Exercises. * Values:: Constants, Variables, and Regular @@ -8967,6 +8968,7 @@ and discusses the @code{close()} built-in function. @command{gawk} allows access to inherited file descriptors. * Close Files And Pipes:: Closing Input and Output Files and Pipes. +* Nonfatal:: Enabling Nonfatal Output. * Output Summary:: Output summary. * Output Exercises:: Exercises. @end menu @@ -10484,6 +10486,58 @@ when closing a pipe. @c ENDOFRANGE pc @c ENDOFRANGE cc +@node Nonfatal +@section Enabling Nonfatal Output + +This @value{SECTION} describes a @command{gawk}-specific feature. + +In standard @command{awk}, output with @code{print} or @code{printf} +to a nonexistent file, or some other I/O error (such as filling up the +disk) is a fatal error. + +@example +$ @kbd{gawk 'BEGIN @{ print "hi" > "/no/such/file" @}'} +@error{} gawk: cmd. line:1: fatal: can't redirect to `/no/such/file' (No such file or directory) +@end example + +@command{gawk} makes it possible to detect that an error has +occurred, allowing you to possibly recover from the error, or +at least print an error message of your choosing before exiting. +You can do this in one of two ways: + +@itemize @bullet +@item +For all output files, by assigning any value to @code{PROCINFO["nonfatal"]}. + +@item +On a per-file basis, by assigning any value to +@code{PROCINFO[@var{filename}, "nonfatal"]}. +Here, @var{filename} is the name of the file to which +you wish output to be nonfatal. +@end itemize + +Once you have enabled nonfatal output, you must check @code{ERRNO} +after every relevant @code{print} or @code{printf} statement to +see if something went wrong. It is also a good idea to initialize +@code{ERRNO} to zero before attempting the output. For example: + +@example +$ @kbd{gawk '} +> @kbd{BEGIN @{} +> @kbd{ PROCINFO["nonfatal"] = 1} +> @kbd{ ERRNO = 0} +> @kbd{ print "hi" > "/no/such/file"} +> @kbd{ if (ERRNO) @{} +> @kbd{ print("Output failed:", ERRNO) > "/dev/stderr"} +> @kbd{ exit 1} +> @kbd{ @}} +> @kbd{@}'} +@error{} Output failed: No such file or directory +@end example + +Here, @command{gawk} did not produce a fatal error; instead +it let the @command{awk} program code detect the problem and handle it. + @node Output Summary @section Summary @@ -10512,6 +10566,12 @@ Use @code{close()} to close open file, pipe, and coprocess redirections. For coprocesses, it is possible to close only one direction of the communications. +@item +Normally errors with @code{print} or @code{printf} are fatal. +@command{gawk} lets you make output errors be nonfatal either for +all files or on a per-file basis. You must then check for errors +after every relevant output statement. + @end itemize @c EXCLUDE START @@ -36771,6 +36831,38 @@ The dynamic extension interface was completely redone @end itemize +Version @strong{FIXME} XXXX introduced the following changes: + +@itemize @bullet +@item +Changes to @code{ENVIRON} are reflected into @command{gawk}'s +environment and that of programs that it runs. +@xref{Auto-set}. + +@item +The @option{--pretty-print} option no longer runs the @command{awk} +program too. +FIXME: Add xref. + +@item +The @command{igawk} program and its manual page are no longer +installed when @command{gawk} is built. +FIXME: Add xref. + +@item +The @code{div()} function. +FIXME: Add xref. + +@item +The maximum number of hexdecimal digits in @samp{\x} escapes +is now two. +FIXME: Add xref. + +@item +Nonfatal output with @code{print} and @code{printf}. +@xref{Nonfatal}. +@end itemize + @c XXX ADD MORE STUFF HERE @end ifclear diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 8bdf1a70..abf139a8 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -627,6 +627,7 @@ particular records in a file and perform operations upon them. * Special Caveats:: Things to watch out for. * Close Files And Pipes:: Closing Input and Output Files and Pipes. +* Nonfatal:: Enabling Nonfatal Output. * Output Summary:: Output summary. * Output Exercises:: Exercises. * Values:: Constants, Variables, and Regular @@ -8568,6 +8569,7 @@ and discusses the @code{close()} built-in function. @command{gawk} allows access to inherited file descriptors. * Close Files And Pipes:: Closing Input and Output Files and Pipes. +* Nonfatal:: Enabling Nonfatal Output. * Output Summary:: Output summary. * Output Exercises:: Exercises. @end menu @@ -9981,6 +9983,58 @@ when closing a pipe. @c ENDOFRANGE pc @c ENDOFRANGE cc +@node Nonfatal +@section Enabling Nonfatal Output + +This @value{SECTION} describes a @command{gawk}-specific feature. + +In standard @command{awk}, output with @code{print} or @code{printf} +to a nonexistent file, or some other I/O error (such as filling up the +disk) is a fatal error. + +@example +$ @kbd{gawk 'BEGIN @{ print "hi" > "/no/such/file" @}'} +@error{} gawk: cmd. line:1: fatal: can't redirect to `/no/such/file' (No such file or directory) +@end example + +@command{gawk} makes it possible to detect that an error has +occurred, allowing you to possibly recover from the error, or +at least print an error message of your choosing before exiting. +You can do this in one of two ways: + +@itemize @bullet +@item +For all output files, by assigning any value to @code{PROCINFO["nonfatal"]}. + +@item +On a per-file basis, by assigning any value to +@code{PROCINFO[@var{filename}, "nonfatal"]}. +Here, @var{filename} is the name of the file to which +you wish output to be nonfatal. +@end itemize + +Once you have enabled nonfatal output, you must check @code{ERRNO} +after every relevant @code{print} or @code{printf} statement to +see if something went wrong. It is also a good idea to initialize +@code{ERRNO} to zero before attempting the output. For example: + +@example +$ @kbd{gawk '} +> @kbd{BEGIN @{} +> @kbd{ PROCINFO["nonfatal"] = 1} +> @kbd{ ERRNO = 0} +> @kbd{ print "hi" > "/no/such/file"} +> @kbd{ if (ERRNO) @{} +> @kbd{ print("Output failed:", ERRNO) > "/dev/stderr"} +> @kbd{ exit 1} +> @kbd{ @}} +> @kbd{@}'} +@error{} Output failed: No such file or directory +@end example + +Here, @command{gawk} did not produce a fatal error; instead +it let the @command{awk} program code detect the problem and handle it. + @node Output Summary @section Summary @@ -10009,6 +10063,12 @@ Use @code{close()} to close open file, pipe, and coprocess redirections. For coprocesses, it is possible to close only one direction of the communications. +@item +Normally errors with @code{print} or @code{printf} are fatal. +@command{gawk} lets you make output errors be nonfatal either for +all files or on a per-file basis. You must then check for errors +after every relevant output statement. + @end itemize @c EXCLUDE START @@ -35864,6 +35924,38 @@ The dynamic extension interface was completely redone @end itemize +Version @strong{FIXME} XXXX introduced the following changes: + +@itemize @bullet +@item +Changes to @code{ENVIRON} are reflected into @command{gawk}'s +environment and that of programs that it runs. +@xref{Auto-set}. + +@item +The @option{--pretty-print} option no longer runs the @command{awk} +program too. +FIXME: Add xref. + +@item +The @command{igawk} program and its manual page are no longer +installed when @command{gawk} is built. +FIXME: Add xref. + +@item +The @code{div()} function. +FIXME: Add xref. + +@item +The maximum number of hexdecimal digits in @samp{\x} escapes +is now two. +FIXME: Add xref. + +@item +Nonfatal output with @code{print} and @code{printf}. +@xref{Nonfatal}. +@end itemize + @c XXX ADD MORE STUFF HERE @end ifclear |