diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/gawk.1 | 2 | ||||
-rw-r--r-- | doc/gawk.info | 1071 | ||||
-rw-r--r-- | doc/gawk.texi | 74 | ||||
-rw-r--r-- | doc/gawktexi.in | 74 | ||||
-rw-r--r-- | io.c | 45 | ||||
-rw-r--r-- | main.c | 28 |
8 files changed, 674 insertions, 641 deletions
@@ -1,3 +1,19 @@ +2014-10-15 Arnold D. Robbins <arnold@skeeve.com> + + Make sane the handling of AWKPATH and AWKLIBPATH: + + 1. Don't explicitly search "."; it must be in the path either + physically or as null element a la the shell's $PATH + 2. If environment's value was empty, use built-in default value. + 3. Set ENVIRON["AWK*PATH"] to the path used. + + * io.c (path_info): Remove try_cwd member. + (get_cwd): Removed, not needed anymore. + (do_find_source): Don't do explicit check in current directory. + It must come from the AWKPATH or AWKLIBPATH variable. + * main.c (path_environ): If value from environment was empty, + set it to the default. This is how gawk has behaved since 2.10. + 2014-10-13 Arnold D. Robbins <arnold@skeeve.com> * regcomp.c (__re_error_msgid): Make error message for REG_EBRACK diff --git a/doc/ChangeLog b/doc/ChangeLog index da2b7cc0..fe9bea7e 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2014-10-15 Arnold D. Robbins <arnold@skeeve.com> + + * gawk.1: Fix default value for AWKLIBPATH. + * gawktexi.in: Revised text for AWKPATH and AWKLIBPATH. + 2014-10-14 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Add new Foreword from Mike Brennan. @@ -626,7 +626,7 @@ specifies a search path to use when finding source files named with the .B \-l option. If this variable does not exist, the default path is -\fB".:/usr/local/lib/gawk"\fR. +\fB"/usr/local/lib/gawk"\fR. (The actual directory may vary, depending upon how .I gawk was built and installed.) diff --git a/doc/gawk.info b/doc/gawk.info index fd3e19db..00a8adcb 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -2874,17 +2874,17 @@ File: gawk.info, Node: AWKPATH Variable, Next: AWKLIBPATH Variable, Up: Envir The previous minor node described how `awk' program files can be named on the command line with the `-f' option. In most `awk' -implementations, you must supply a precise path name for each program -file, unless the file is in the current directory. But in `gawk', if +implementations, you must supply a precise pathname for each program +file, unless the file is in the current directory. But with `gawk', if the file name supplied to the `-f' or `-i' options does not contain a directory separator `/', then `gawk' searches a list of directories (called the "search path"), one by one, looking for a file with the specified name. The search path is a string consisting of directory names separated by -colons(1). `gawk' gets its search path from the `AWKPATH' environment -variable. If that variable does not exist, `gawk' uses a default path, -`.:/usr/local/share/awk'.(2) +colons.(1) `gawk' gets its search path from the `AWKPATH' environment +variable. If that variable does not exist, or if it has an empty value, +`gawk' uses a default path (described shortly). The search path feature is particularly helpful for building libraries of useful `awk' functions. The library files can be placed @@ -2892,15 +2892,13 @@ in a standard directory in the default path and then specified on the command line with a short file name. Otherwise, you would have to type the full file name for each file. - By using the `-i' option, or the `-e' and `-f' options, your -command-line `awk' programs can use facilities in `awk' library files -(*note Library Functions::). Path searching is not done if `gawk' is -in compatibility mode. This is true for both `--traditional' and -`--posix'. *Note Options::. + By using the `-i' or `-f' options, your command-line `awk' programs +can use facilities in `awk' library files (*note Library Functions::). +Path searching is not done if `gawk' is in compatibility mode. This is +true for both `--traditional' and `--posix'. *Note Options::. If the source code file is not found after the initial search, the -path is searched again after adding the default `.awk' suffix to the -file name. +path is searched again after adding the suffix `.awk' to the file name. `gawk''s path search mechanism is similar to the shell's. (See `The Bourne-Again SHell manual' (http://www.gnu.org/software/bash/manual/).) @@ -2908,15 +2906,23 @@ It treats a null entry in the path as indicating the current directory. (A null entry is indicated by starting or ending the path with a colon or by placing two colons next to each other [`::'].) - NOTE: `gawk' always looks in the current directory _before_ - searching `AWKPATH'. Thus, while you can include the current - directory in the search path, either explicitly or with a null - entry, there is no real reason to do so. + NOTE: To include the current directory in the path, either place + `.' as an entry in the path or write a null entry in the path. - If `AWKPATH' is not defined in the environment, `gawk' places its -default search path into `ENVIRON["AWKPATH"]'. This makes it easy to -determine the actual search path that `gawk' used from within an `awk' -program. + Different past versions of `gawk' would also look explicitly in + the current directory, either before or after the path search. As + of version 4.1.2, this no longer happens, and if you wish to look + in the current directory, you must include `.' either as a separate + entry, or as a null entry in the search path. + + The default value for `AWKPATH' is `.:/usr/local/share/awk'.(2) +Since `.' is included at the beginning, `gawk' searches first in the +current directory and then in `/usr/local/share/awk'. In practice, +this means that you will rarely need to change the value of `AWKPATH'. + + `gawk' places the value of the search path that it used into +`ENVIRON["AWKPATH"]'. This provides access to the actual search path +value from within an `awk' program. While you can change `ENVIRON["AWKPATH"]' within your `awk' program, this has no effect on the running program's behavior. This makes @@ -2948,6 +2954,15 @@ platform. For example, on GNU/Linux systems, the suffix `.so' is used. The search path specified is also used for extensions loaded via the `@load' keyword (*note Loading Shared Libraries::). + If `AWKLIBPATH' does not exist in the environment, or if it has an +empty value, `gawk' uses a default path; this is typically +`/usr/local/lib/gawk', although it can vary depending upon how `gawk' +was built. + + `gawk' places the value of the search path that it used into +`ENVIRON["AWKLIBPATH"]'. This provides access to the actual search path +value from within an `awk' program. + File: gawk.info, Node: Other Environment Variables, Prev: AWKLIBPATH Variable, Up: Environment Variables @@ -34313,513 +34328,513 @@ Node: Other Arguments131096 Node: Naming Standard Input134057 Node: Environment Variables135150 Node: AWKPATH Variable135708 -Ref: AWKPATH Variable-Footnote-1138560 -Ref: AWKPATH Variable-Footnote-2138605 -Node: AWKLIBPATH Variable138865 -Node: Other Environment Variables139624 -Node: Exit Status143344 -Node: Include Files144019 -Node: Loading Shared Libraries147607 -Node: Obsolete149034 -Node: Undocumented149731 -Node: Invoking Summary149998 -Node: Regexp151664 -Node: Regexp Usage153123 -Node: Escape Sequences155156 -Node: Regexp Operators161173 -Ref: Regexp Operators-Footnote-1168607 -Ref: Regexp Operators-Footnote-2168754 -Node: Bracket Expressions168852 -Ref: table-char-classes170869 -Node: Leftmost Longest173809 -Node: Computed Regexps175111 -Node: GNU Regexp Operators178508 -Node: Case-sensitivity182210 -Ref: Case-sensitivity-Footnote-1185100 -Ref: Case-sensitivity-Footnote-2185335 -Node: Regexp Summary185443 -Node: Reading Files186912 -Node: Records189006 -Node: awk split records189738 -Node: gawk split records194652 -Ref: gawk split records-Footnote-1199191 -Node: Fields199228 -Ref: Fields-Footnote-1202026 -Node: Nonconstant Fields202112 -Ref: Nonconstant Fields-Footnote-1204348 -Node: Changing Fields204550 -Node: Field Separators210482 -Node: Default Field Splitting213186 -Node: Regexp Field Splitting214303 -Node: Single Character Fields217653 -Node: Command Line Field Separator218712 -Node: Full Line Fields221924 -Ref: Full Line Fields-Footnote-1222432 -Node: Field Splitting Summary222478 -Ref: Field Splitting Summary-Footnote-1225609 -Node: Constant Size225710 -Node: Splitting By Content230316 -Ref: Splitting By Content-Footnote-1234389 -Node: Multiple Line234429 -Ref: Multiple Line-Footnote-1240318 -Node: Getline240497 -Node: Plain Getline242708 -Node: Getline/Variable245348 -Node: Getline/File246495 -Node: Getline/Variable/File247879 -Ref: Getline/Variable/File-Footnote-1249480 -Node: Getline/Pipe249567 -Node: Getline/Variable/Pipe252250 -Node: Getline/Coprocess253381 -Node: Getline/Variable/Coprocess254633 -Node: Getline Notes255372 -Node: Getline Summary258164 -Ref: table-getline-variants258576 -Node: Read Timeout259405 -Ref: Read Timeout-Footnote-1263219 -Node: Command-line directories263277 -Node: Input Summary264181 -Node: Input Exercises267433 -Node: Printing268161 -Node: Print269938 -Node: Print Examples271395 -Node: Output Separators274174 -Node: OFMT276192 -Node: Printf277546 -Node: Basic Printf278331 -Node: Control Letters279902 -Node: Format Modifiers283886 -Node: Printf Examples289893 -Node: Redirection292375 -Node: Special FD299214 -Ref: Special FD-Footnote-1302371 -Node: Special Files302445 -Node: Other Inherited Files303061 -Node: Special Network304061 -Node: Special Caveats304922 -Node: Close Files And Pipes305873 -Ref: Close Files And Pipes-Footnote-1313052 -Ref: Close Files And Pipes-Footnote-2313200 -Node: Output Summary313350 -Node: Output Exercises314346 -Node: Expressions315026 -Node: Values316211 -Node: Constants316887 -Node: Scalar Constants317567 -Ref: Scalar Constants-Footnote-1318426 -Node: Nondecimal-numbers318676 -Node: Regexp Constants321676 -Node: Using Constant Regexps322201 -Node: Variables325339 -Node: Using Variables325994 -Node: Assignment Options327904 -Node: Conversion329779 -Node: Strings And Numbers330303 -Ref: Strings And Numbers-Footnote-1333367 -Node: Locale influences conversions333476 -Ref: table-locale-affects336221 -Node: All Operators336809 -Node: Arithmetic Ops337439 -Node: Concatenation339944 -Ref: Concatenation-Footnote-1342763 -Node: Assignment Ops342869 -Ref: table-assign-ops347852 -Node: Increment Ops349130 -Node: Truth Values and Conditions352568 -Node: Truth Values353651 -Node: Typing and Comparison354700 -Node: Variable Typing355493 -Node: Comparison Operators359145 -Ref: table-relational-ops359555 -Node: POSIX String Comparison363070 -Ref: POSIX String Comparison-Footnote-1364142 -Node: Boolean Ops364280 -Ref: Boolean Ops-Footnote-1368759 -Node: Conditional Exp368850 -Node: Function Calls370577 -Node: Precedence374457 -Node: Locales378125 -Node: Expressions Summary379756 -Node: Patterns and Actions382330 -Node: Pattern Overview383450 -Node: Regexp Patterns385129 -Node: Expression Patterns385672 -Node: Ranges389452 -Node: BEGIN/END392558 -Node: Using BEGIN/END393320 -Ref: Using BEGIN/END-Footnote-1396057 -Node: I/O And BEGIN/END396163 -Node: BEGINFILE/ENDFILE398477 -Node: Empty401378 -Node: Using Shell Variables401695 -Node: Action Overview403971 -Node: Statements406298 -Node: If Statement408146 -Node: While Statement409644 -Node: Do Statement411672 -Node: For Statement412814 -Node: Switch Statement415969 -Node: Break Statement418357 -Node: Continue Statement420398 -Node: Next Statement422223 -Node: Nextfile Statement424603 -Node: Exit Statement427233 -Node: Built-in Variables429636 -Node: User-modified430769 -Ref: User-modified-Footnote-1438449 -Node: Auto-set438511 -Ref: Auto-set-Footnote-1451541 -Ref: Auto-set-Footnote-2451746 -Node: ARGC and ARGV451802 -Node: Pattern Action Summary456006 -Node: Arrays458433 -Node: Array Basics459762 -Node: Array Intro460606 -Ref: figure-array-elements462570 -Ref: Array Intro-Footnote-1465094 -Node: Reference to Elements465222 -Node: Assigning Elements467672 -Node: Array Example468163 -Node: Scanning an Array469921 -Node: Controlling Scanning472937 -Ref: Controlling Scanning-Footnote-1478126 -Node: Numeric Array Subscripts478442 -Node: Uninitialized Subscripts480627 -Node: Delete482244 -Ref: Delete-Footnote-1484988 -Node: Multidimensional485045 -Node: Multiscanning488140 -Node: Arrays of Arrays489729 -Node: Arrays Summary494490 -Node: Functions496595 -Node: Built-in497468 -Node: Calling Built-in498546 -Node: Numeric Functions500534 -Ref: Numeric Functions-Footnote-1504556 -Ref: Numeric Functions-Footnote-2504913 -Ref: Numeric Functions-Footnote-3504961 -Node: String Functions505230 -Ref: String Functions-Footnote-1528702 -Ref: String Functions-Footnote-2528831 -Ref: String Functions-Footnote-3529079 -Node: Gory Details529166 -Ref: table-sub-escapes530947 -Ref: table-sub-proposed532467 -Ref: table-posix-sub533831 -Ref: table-gensub-escapes535371 -Ref: Gory Details-Footnote-1536203 -Node: I/O Functions536354 -Ref: I/O Functions-Footnote-1543455 -Node: Time Functions543602 -Ref: Time Functions-Footnote-1554071 -Ref: Time Functions-Footnote-2554139 -Ref: Time Functions-Footnote-3554297 -Ref: Time Functions-Footnote-4554408 -Ref: Time Functions-Footnote-5554520 -Ref: Time Functions-Footnote-6554747 -Node: Bitwise Functions555013 -Ref: table-bitwise-ops555575 -Ref: Bitwise Functions-Footnote-1559883 -Node: Type Functions560052 -Node: I18N Functions561201 -Node: User-defined562846 -Node: Definition Syntax563650 -Ref: Definition Syntax-Footnote-1569056 -Node: Function Example569125 -Ref: Function Example-Footnote-1572042 -Node: Function Caveats572064 -Node: Calling A Function572582 -Node: Variable Scope573537 -Node: Pass By Value/Reference576525 -Node: Return Statement580035 -Node: Dynamic Typing583019 -Node: Indirect Calls583948 -Ref: Indirect Calls-Footnote-1595252 -Node: Functions Summary595380 -Node: Library Functions598079 -Ref: Library Functions-Footnote-1601697 -Ref: Library Functions-Footnote-2601840 -Node: Library Names602011 -Ref: Library Names-Footnote-1605471 -Ref: Library Names-Footnote-2605691 -Node: General Functions605777 -Node: Strtonum Function606880 -Node: Assert Function609900 -Node: Round Function613224 -Node: Cliff Random Function614765 -Node: Ordinal Functions615781 -Ref: Ordinal Functions-Footnote-1618846 -Ref: Ordinal Functions-Footnote-2619098 -Node: Join Function619309 -Ref: Join Function-Footnote-1621080 -Node: Getlocaltime Function621280 -Node: Readfile Function625021 -Node: Shell Quoting626991 -Node: Data File Management628392 -Node: Filetrans Function629024 -Node: Rewind Function633083 -Node: File Checking634468 -Ref: File Checking-Footnote-1635796 -Node: Empty Files635997 -Node: Ignoring Assigns637976 -Node: Getopt Function639527 -Ref: Getopt Function-Footnote-1650987 -Node: Passwd Functions651190 -Ref: Passwd Functions-Footnote-1660041 -Node: Group Functions660129 -Ref: Group Functions-Footnote-1668032 -Node: Walking Arrays668245 -Node: Library Functions Summary669848 -Node: Library Exercises671249 -Node: Sample Programs672529 -Node: Running Examples673299 -Node: Clones674027 -Node: Cut Program675251 -Node: Egrep Program684981 -Ref: Egrep Program-Footnote-1692485 -Node: Id Program692595 -Node: Split Program696239 -Ref: Split Program-Footnote-1699685 -Node: Tee Program699813 -Node: Uniq Program702600 -Node: Wc Program710021 -Ref: Wc Program-Footnote-1714269 -Node: Miscellaneous Programs714361 -Node: Dupword Program715574 -Node: Alarm Program717605 -Node: Translate Program722409 -Ref: Translate Program-Footnote-1726973 -Node: Labels Program727243 -Ref: Labels Program-Footnote-1730592 -Node: Word Sorting730676 -Node: History Sorting734746 -Node: Extract Program736582 -Node: Simple Sed744114 -Node: Igawk Program747176 -Ref: Igawk Program-Footnote-1761502 -Ref: Igawk Program-Footnote-2761703 -Ref: Igawk Program-Footnote-3761825 -Node: Anagram Program761940 -Node: Signature Program765002 -Node: Programs Summary766249 -Node: Programs Exercises767442 -Ref: Programs Exercises-Footnote-1771573 -Node: Advanced Features771664 -Node: Nondecimal Data773612 -Node: Array Sorting775202 -Node: Controlling Array Traversal775899 -Ref: Controlling Array Traversal-Footnote-1784230 -Node: Array Sorting Functions784348 -Ref: Array Sorting Functions-Footnote-1788240 -Node: Two-way I/O788434 -Ref: Two-way I/O-Footnote-1793378 -Ref: Two-way I/O-Footnote-2793564 -Node: TCP/IP Networking793646 -Node: Profiling796518 -Node: Advanced Features Summary804062 -Node: Internationalization805995 -Node: I18N and L10N807475 -Node: Explaining gettext808161 -Ref: Explaining gettext-Footnote-1813190 -Ref: Explaining gettext-Footnote-2813374 -Node: Programmer i18n813539 -Ref: Programmer i18n-Footnote-1818405 -Node: Translator i18n818454 -Node: String Extraction819248 -Ref: String Extraction-Footnote-1820379 -Node: Printf Ordering820465 -Ref: Printf Ordering-Footnote-1823251 -Node: I18N Portability823315 -Ref: I18N Portability-Footnote-1825764 -Node: I18N Example825827 -Ref: I18N Example-Footnote-1828627 -Node: Gawk I18N828699 -Node: I18N Summary829337 -Node: Debugger830676 -Node: Debugging831698 -Node: Debugging Concepts832139 -Node: Debugging Terms833996 -Node: Awk Debugging836571 -Node: Sample Debugging Session837463 -Node: Debugger Invocation837983 -Node: Finding The Bug839367 -Node: List of Debugger Commands845842 -Node: Breakpoint Control847174 -Node: Debugger Execution Control850866 -Node: Viewing And Changing Data854230 -Node: Execution Stack857595 -Node: Debugger Info859233 -Node: Miscellaneous Debugger Commands863250 -Node: Readline Support868442 -Node: Limitations869334 -Node: Debugging Summary871431 -Node: Arbitrary Precision Arithmetic872599 -Node: Computer Arithmetic874015 -Ref: table-numeric-ranges877616 -Ref: Computer Arithmetic-Footnote-1878475 -Node: Math Definitions878532 -Ref: table-ieee-formats881819 -Ref: Math Definitions-Footnote-1882423 -Node: MPFR features882528 -Node: FP Math Caution884199 -Ref: FP Math Caution-Footnote-1885249 -Node: Inexactness of computations885618 -Node: Inexact representation886566 -Node: Comparing FP Values887921 -Node: Errors accumulate888994 -Node: Getting Accuracy890427 -Node: Try To Round893086 -Node: Setting precision893985 -Ref: table-predefined-precision-strings894669 -Node: Setting the rounding mode896463 -Ref: table-gawk-rounding-modes896827 -Ref: Setting the rounding mode-Footnote-1900281 -Node: Arbitrary Precision Integers900460 -Ref: Arbitrary Precision Integers-Footnote-1903451 -Node: POSIX Floating Point Problems903600 -Ref: POSIX Floating Point Problems-Footnote-1907476 -Node: Floating point summary907514 -Node: Dynamic Extensions909706 -Node: Extension Intro911258 -Node: Plugin License912524 -Node: Extension Mechanism Outline913321 -Ref: figure-load-extension913749 -Ref: figure-register-new-function915229 -Ref: figure-call-new-function916233 -Node: Extension API Description918219 -Node: Extension API Functions Introduction919669 -Node: General Data Types924505 -Ref: General Data Types-Footnote-1930192 -Node: Memory Allocation Functions930491 -Ref: Memory Allocation Functions-Footnote-1933321 -Node: Constructor Functions933417 -Node: Registration Functions935151 -Node: Extension Functions935836 -Node: Exit Callback Functions938132 -Node: Extension Version String939380 -Node: Input Parsers940030 -Node: Output Wrappers949845 -Node: Two-way processors954361 -Node: Printing Messages956565 -Ref: Printing Messages-Footnote-1957642 -Node: Updating `ERRNO'957794 -Node: Requesting Values958534 -Ref: table-value-types-returned959262 -Node: Accessing Parameters960220 -Node: Symbol Table Access961451 -Node: Symbol table by name961965 -Node: Symbol table by cookie963945 -Ref: Symbol table by cookie-Footnote-1968084 -Node: Cached values968147 -Ref: Cached values-Footnote-1971651 -Node: Array Manipulation971742 -Ref: Array Manipulation-Footnote-1972840 -Node: Array Data Types972879 -Ref: Array Data Types-Footnote-1975536 -Node: Array Functions975628 -Node: Flattening Arrays979482 -Node: Creating Arrays986369 -Node: Extension API Variables991136 -Node: Extension Versioning991772 -Node: Extension API Informational Variables993673 -Node: Extension API Boilerplate994761 -Node: Finding Extensions998577 -Node: Extension Example999137 -Node: Internal File Description999909 -Node: Internal File Ops1003976 -Ref: Internal File Ops-Footnote-11015634 -Node: Using Internal File Ops1015774 -Ref: Using Internal File Ops-Footnote-11018157 -Node: Extension Samples1018430 -Node: Extension Sample File Functions1019954 -Node: Extension Sample Fnmatch1027556 -Node: Extension Sample Fork1029038 -Node: Extension Sample Inplace1030251 -Node: Extension Sample Ord1031926 -Node: Extension Sample Readdir1032762 -Ref: table-readdir-file-types1033618 -Node: Extension Sample Revout1034429 -Node: Extension Sample Rev2way1035020 -Node: Extension Sample Read write array1035761 -Node: Extension Sample Readfile1037700 -Node: Extension Sample Time1038795 -Node: Extension Sample API Tests1040144 -Node: gawkextlib1040635 -Node: Extension summary1043285 -Node: Extension Exercises1046967 -Node: Language History1047689 -Node: V7/SVR3.11049346 -Node: SVR41051527 -Node: POSIX1052972 -Node: BTL1054361 -Node: POSIX/GNU1055095 -Node: Feature History1060664 -Node: Common Extensions1073755 -Node: Ranges and Locales1075079 -Ref: Ranges and Locales-Footnote-11079718 -Ref: Ranges and Locales-Footnote-21079745 -Ref: Ranges and Locales-Footnote-31079979 -Node: Contributors1080200 -Node: History summary1085740 -Node: Installation1087109 -Node: Gawk Distribution1088065 -Node: Getting1088549 -Node: Extracting1089373 -Node: Distribution contents1091015 -Node: Unix Installation1096732 -Node: Quick Installation1097349 -Node: Additional Configuration Options1099780 -Node: Configuration Philosophy1101520 -Node: Non-Unix Installation1103871 -Node: PC Installation1104329 -Node: PC Binary Installation1105655 -Node: PC Compiling1107503 -Ref: PC Compiling-Footnote-11110524 -Node: PC Testing1110629 -Node: PC Using1111805 -Node: Cygwin1115920 -Node: MSYS1116743 -Node: VMS Installation1117241 -Node: VMS Compilation1118033 -Ref: VMS Compilation-Footnote-11119255 -Node: VMS Dynamic Extensions1119313 -Node: VMS Installation Details1120997 -Node: VMS Running1123249 -Node: VMS GNV1126090 -Node: VMS Old Gawk1126824 -Node: Bugs1127294 -Node: Other Versions1131198 -Node: Installation summary1137411 -Node: Notes1138467 -Node: Compatibility Mode1139332 -Node: Additions1140114 -Node: Accessing The Source1141039 -Node: Adding Code1142475 -Node: New Ports1148647 -Node: Derived Files1153129 -Ref: Derived Files-Footnote-11158604 -Ref: Derived Files-Footnote-21158638 -Ref: Derived Files-Footnote-31159234 -Node: Future Extensions1159348 -Node: Implementation Limitations1159954 -Node: Extension Design1161202 -Node: Old Extension Problems1162356 -Ref: Old Extension Problems-Footnote-11163873 -Node: Extension New Mechanism Goals1163930 -Ref: Extension New Mechanism Goals-Footnote-11167290 -Node: Extension Other Design Decisions1167479 -Node: Extension Future Growth1169587 -Node: Old Extension Mechanism1170423 -Node: Notes summary1172185 -Node: Basic Concepts1173371 -Node: Basic High Level1174052 -Ref: figure-general-flow1174324 -Ref: figure-process-flow1174923 -Ref: Basic High Level-Footnote-11178152 -Node: Basic Data Typing1178337 -Node: Glossary1181665 -Node: Copying1206823 -Node: GNU Free Documentation License1244379 -Node: Index1269515 +Ref: AWKPATH Variable-Footnote-1139008 +Ref: AWKPATH Variable-Footnote-2139053 +Node: AWKLIBPATH Variable139313 +Node: Other Environment Variables140456 +Node: Exit Status144176 +Node: Include Files144851 +Node: Loading Shared Libraries148439 +Node: Obsolete149866 +Node: Undocumented150563 +Node: Invoking Summary150830 +Node: Regexp152496 +Node: Regexp Usage153955 +Node: Escape Sequences155988 +Node: Regexp Operators162005 +Ref: Regexp Operators-Footnote-1169439 +Ref: Regexp Operators-Footnote-2169586 +Node: Bracket Expressions169684 +Ref: table-char-classes171701 +Node: Leftmost Longest174641 +Node: Computed Regexps175943 +Node: GNU Regexp Operators179340 +Node: Case-sensitivity183042 +Ref: Case-sensitivity-Footnote-1185932 +Ref: Case-sensitivity-Footnote-2186167 +Node: Regexp Summary186275 +Node: Reading Files187744 +Node: Records189838 +Node: awk split records190570 +Node: gawk split records195484 +Ref: gawk split records-Footnote-1200023 +Node: Fields200060 +Ref: Fields-Footnote-1202858 +Node: Nonconstant Fields202944 +Ref: Nonconstant Fields-Footnote-1205180 +Node: Changing Fields205382 +Node: Field Separators211314 +Node: Default Field Splitting214018 +Node: Regexp Field Splitting215135 +Node: Single Character Fields218485 +Node: Command Line Field Separator219544 +Node: Full Line Fields222756 +Ref: Full Line Fields-Footnote-1223264 +Node: Field Splitting Summary223310 +Ref: Field Splitting Summary-Footnote-1226441 +Node: Constant Size226542 +Node: Splitting By Content231148 +Ref: Splitting By Content-Footnote-1235221 +Node: Multiple Line235261 +Ref: Multiple Line-Footnote-1241150 +Node: Getline241329 +Node: Plain Getline243540 +Node: Getline/Variable246180 +Node: Getline/File247327 +Node: Getline/Variable/File248711 +Ref: Getline/Variable/File-Footnote-1250312 +Node: Getline/Pipe250399 +Node: Getline/Variable/Pipe253082 +Node: Getline/Coprocess254213 +Node: Getline/Variable/Coprocess255465 +Node: Getline Notes256204 +Node: Getline Summary258996 +Ref: table-getline-variants259408 +Node: Read Timeout260237 +Ref: Read Timeout-Footnote-1264051 +Node: Command-line directories264109 +Node: Input Summary265013 +Node: Input Exercises268265 +Node: Printing268993 +Node: Print270770 +Node: Print Examples272227 +Node: Output Separators275006 +Node: OFMT277024 +Node: Printf278378 +Node: Basic Printf279163 +Node: Control Letters280734 +Node: Format Modifiers284718 +Node: Printf Examples290725 +Node: Redirection293207 +Node: Special FD300046 +Ref: Special FD-Footnote-1303203 +Node: Special Files303277 +Node: Other Inherited Files303893 +Node: Special Network304893 +Node: Special Caveats305754 +Node: Close Files And Pipes306705 +Ref: Close Files And Pipes-Footnote-1313884 +Ref: Close Files And Pipes-Footnote-2314032 +Node: Output Summary314182 +Node: Output Exercises315178 +Node: Expressions315858 +Node: Values317043 +Node: Constants317719 +Node: Scalar Constants318399 +Ref: Scalar Constants-Footnote-1319258 +Node: Nondecimal-numbers319508 +Node: Regexp Constants322508 +Node: Using Constant Regexps323033 +Node: Variables326171 +Node: Using Variables326826 +Node: Assignment Options328736 +Node: Conversion330611 +Node: Strings And Numbers331135 +Ref: Strings And Numbers-Footnote-1334199 +Node: Locale influences conversions334308 +Ref: table-locale-affects337053 +Node: All Operators337641 +Node: Arithmetic Ops338271 +Node: Concatenation340776 +Ref: Concatenation-Footnote-1343595 +Node: Assignment Ops343701 +Ref: table-assign-ops348684 +Node: Increment Ops349962 +Node: Truth Values and Conditions353400 +Node: Truth Values354483 +Node: Typing and Comparison355532 +Node: Variable Typing356325 +Node: Comparison Operators359977 +Ref: table-relational-ops360387 +Node: POSIX String Comparison363902 +Ref: POSIX String Comparison-Footnote-1364974 +Node: Boolean Ops365112 +Ref: Boolean Ops-Footnote-1369591 +Node: Conditional Exp369682 +Node: Function Calls371409 +Node: Precedence375289 +Node: Locales378957 +Node: Expressions Summary380588 +Node: Patterns and Actions383162 +Node: Pattern Overview384282 +Node: Regexp Patterns385961 +Node: Expression Patterns386504 +Node: Ranges390284 +Node: BEGIN/END393390 +Node: Using BEGIN/END394152 +Ref: Using BEGIN/END-Footnote-1396889 +Node: I/O And BEGIN/END396995 +Node: BEGINFILE/ENDFILE399309 +Node: Empty402210 +Node: Using Shell Variables402527 +Node: Action Overview404803 +Node: Statements407130 +Node: If Statement408978 +Node: While Statement410476 +Node: Do Statement412504 +Node: For Statement413646 +Node: Switch Statement416801 +Node: Break Statement419189 +Node: Continue Statement421230 +Node: Next Statement423055 +Node: Nextfile Statement425435 +Node: Exit Statement428065 +Node: Built-in Variables430468 +Node: User-modified431601 +Ref: User-modified-Footnote-1439281 +Node: Auto-set439343 +Ref: Auto-set-Footnote-1452373 +Ref: Auto-set-Footnote-2452578 +Node: ARGC and ARGV452634 +Node: Pattern Action Summary456838 +Node: Arrays459265 +Node: Array Basics460594 +Node: Array Intro461438 +Ref: figure-array-elements463402 +Ref: Array Intro-Footnote-1465926 +Node: Reference to Elements466054 +Node: Assigning Elements468504 +Node: Array Example468995 +Node: Scanning an Array470753 +Node: Controlling Scanning473769 +Ref: Controlling Scanning-Footnote-1478958 +Node: Numeric Array Subscripts479274 +Node: Uninitialized Subscripts481459 +Node: Delete483076 +Ref: Delete-Footnote-1485820 +Node: Multidimensional485877 +Node: Multiscanning488972 +Node: Arrays of Arrays490561 +Node: Arrays Summary495322 +Node: Functions497427 +Node: Built-in498300 +Node: Calling Built-in499378 +Node: Numeric Functions501366 +Ref: Numeric Functions-Footnote-1505388 +Ref: Numeric Functions-Footnote-2505745 +Ref: Numeric Functions-Footnote-3505793 +Node: String Functions506062 +Ref: String Functions-Footnote-1529534 +Ref: String Functions-Footnote-2529663 +Ref: String Functions-Footnote-3529911 +Node: Gory Details529998 +Ref: table-sub-escapes531779 +Ref: table-sub-proposed533299 +Ref: table-posix-sub534663 +Ref: table-gensub-escapes536203 +Ref: Gory Details-Footnote-1537035 +Node: I/O Functions537186 +Ref: I/O Functions-Footnote-1544287 +Node: Time Functions544434 +Ref: Time Functions-Footnote-1554903 +Ref: Time Functions-Footnote-2554971 +Ref: Time Functions-Footnote-3555129 +Ref: Time Functions-Footnote-4555240 +Ref: Time Functions-Footnote-5555352 +Ref: Time Functions-Footnote-6555579 +Node: Bitwise Functions555845 +Ref: table-bitwise-ops556407 +Ref: Bitwise Functions-Footnote-1560715 +Node: Type Functions560884 +Node: I18N Functions562033 +Node: User-defined563678 +Node: Definition Syntax564482 +Ref: Definition Syntax-Footnote-1569888 +Node: Function Example569957 +Ref: Function Example-Footnote-1572874 +Node: Function Caveats572896 +Node: Calling A Function573414 +Node: Variable Scope574369 +Node: Pass By Value/Reference577357 +Node: Return Statement580867 +Node: Dynamic Typing583851 +Node: Indirect Calls584780 +Ref: Indirect Calls-Footnote-1596084 +Node: Functions Summary596212 +Node: Library Functions598911 +Ref: Library Functions-Footnote-1602529 +Ref: Library Functions-Footnote-2602672 +Node: Library Names602843 +Ref: Library Names-Footnote-1606303 +Ref: Library Names-Footnote-2606523 +Node: General Functions606609 +Node: Strtonum Function607712 +Node: Assert Function610732 +Node: Round Function614056 +Node: Cliff Random Function615597 +Node: Ordinal Functions616613 +Ref: Ordinal Functions-Footnote-1619678 +Ref: Ordinal Functions-Footnote-2619930 +Node: Join Function620141 +Ref: Join Function-Footnote-1621912 +Node: Getlocaltime Function622112 +Node: Readfile Function625853 +Node: Shell Quoting627823 +Node: Data File Management629224 +Node: Filetrans Function629856 +Node: Rewind Function633915 +Node: File Checking635300 +Ref: File Checking-Footnote-1636628 +Node: Empty Files636829 +Node: Ignoring Assigns638808 +Node: Getopt Function640359 +Ref: Getopt Function-Footnote-1651819 +Node: Passwd Functions652022 +Ref: Passwd Functions-Footnote-1660873 +Node: Group Functions660961 +Ref: Group Functions-Footnote-1668864 +Node: Walking Arrays669077 +Node: Library Functions Summary670680 +Node: Library Exercises672081 +Node: Sample Programs673361 +Node: Running Examples674131 +Node: Clones674859 +Node: Cut Program676083 +Node: Egrep Program685813 +Ref: Egrep Program-Footnote-1693317 +Node: Id Program693427 +Node: Split Program697071 +Ref: Split Program-Footnote-1700517 +Node: Tee Program700645 +Node: Uniq Program703432 +Node: Wc Program710853 +Ref: Wc Program-Footnote-1715101 +Node: Miscellaneous Programs715193 +Node: Dupword Program716406 +Node: Alarm Program718437 +Node: Translate Program723241 +Ref: Translate Program-Footnote-1727805 +Node: Labels Program728075 +Ref: Labels Program-Footnote-1731424 +Node: Word Sorting731508 +Node: History Sorting735578 +Node: Extract Program737414 +Node: Simple Sed744946 +Node: Igawk Program748008 +Ref: Igawk Program-Footnote-1762334 +Ref: Igawk Program-Footnote-2762535 +Ref: Igawk Program-Footnote-3762657 +Node: Anagram Program762772 +Node: Signature Program765834 +Node: Programs Summary767081 +Node: Programs Exercises768274 +Ref: Programs Exercises-Footnote-1772405 +Node: Advanced Features772496 +Node: Nondecimal Data774444 +Node: Array Sorting776034 +Node: Controlling Array Traversal776731 +Ref: Controlling Array Traversal-Footnote-1785062 +Node: Array Sorting Functions785180 +Ref: Array Sorting Functions-Footnote-1789072 +Node: Two-way I/O789266 +Ref: Two-way I/O-Footnote-1794210 +Ref: Two-way I/O-Footnote-2794396 +Node: TCP/IP Networking794478 +Node: Profiling797350 +Node: Advanced Features Summary804894 +Node: Internationalization806827 +Node: I18N and L10N808307 +Node: Explaining gettext808993 +Ref: Explaining gettext-Footnote-1814022 +Ref: Explaining gettext-Footnote-2814206 +Node: Programmer i18n814371 +Ref: Programmer i18n-Footnote-1819237 +Node: Translator i18n819286 +Node: String Extraction820080 +Ref: String Extraction-Footnote-1821211 +Node: Printf Ordering821297 +Ref: Printf Ordering-Footnote-1824083 +Node: I18N Portability824147 +Ref: I18N Portability-Footnote-1826596 +Node: I18N Example826659 +Ref: I18N Example-Footnote-1829459 +Node: Gawk I18N829531 +Node: I18N Summary830169 +Node: Debugger831508 +Node: Debugging832530 +Node: Debugging Concepts832971 +Node: Debugging Terms834828 +Node: Awk Debugging837403 +Node: Sample Debugging Session838295 +Node: Debugger Invocation838815 +Node: Finding The Bug840199 +Node: List of Debugger Commands846674 +Node: Breakpoint Control848006 +Node: Debugger Execution Control851698 +Node: Viewing And Changing Data855062 +Node: Execution Stack858427 +Node: Debugger Info860065 +Node: Miscellaneous Debugger Commands864082 +Node: Readline Support869274 +Node: Limitations870166 +Node: Debugging Summary872263 +Node: Arbitrary Precision Arithmetic873431 +Node: Computer Arithmetic874847 +Ref: table-numeric-ranges878448 +Ref: Computer Arithmetic-Footnote-1879307 +Node: Math Definitions879364 +Ref: table-ieee-formats882651 +Ref: Math Definitions-Footnote-1883255 +Node: MPFR features883360 +Node: FP Math Caution885031 +Ref: FP Math Caution-Footnote-1886081 +Node: Inexactness of computations886450 +Node: Inexact representation887398 +Node: Comparing FP Values888753 +Node: Errors accumulate889826 +Node: Getting Accuracy891259 +Node: Try To Round893918 +Node: Setting precision894817 +Ref: table-predefined-precision-strings895501 +Node: Setting the rounding mode897295 +Ref: table-gawk-rounding-modes897659 +Ref: Setting the rounding mode-Footnote-1901113 +Node: Arbitrary Precision Integers901292 +Ref: Arbitrary Precision Integers-Footnote-1904283 +Node: POSIX Floating Point Problems904432 +Ref: POSIX Floating Point Problems-Footnote-1908308 +Node: Floating point summary908346 +Node: Dynamic Extensions910538 +Node: Extension Intro912090 +Node: Plugin License913356 +Node: Extension Mechanism Outline914153 +Ref: figure-load-extension914581 +Ref: figure-register-new-function916061 +Ref: figure-call-new-function917065 +Node: Extension API Description919051 +Node: Extension API Functions Introduction920501 +Node: General Data Types925337 +Ref: General Data Types-Footnote-1931024 +Node: Memory Allocation Functions931323 +Ref: Memory Allocation Functions-Footnote-1934153 +Node: Constructor Functions934249 +Node: Registration Functions935983 +Node: Extension Functions936668 +Node: Exit Callback Functions938964 +Node: Extension Version String940212 +Node: Input Parsers940862 +Node: Output Wrappers950677 +Node: Two-way processors955193 +Node: Printing Messages957397 +Ref: Printing Messages-Footnote-1958474 +Node: Updating `ERRNO'958626 +Node: Requesting Values959366 +Ref: table-value-types-returned960094 +Node: Accessing Parameters961052 +Node: Symbol Table Access962283 +Node: Symbol table by name962797 +Node: Symbol table by cookie964777 +Ref: Symbol table by cookie-Footnote-1968916 +Node: Cached values968979 +Ref: Cached values-Footnote-1972483 +Node: Array Manipulation972574 +Ref: Array Manipulation-Footnote-1973672 +Node: Array Data Types973711 +Ref: Array Data Types-Footnote-1976368 +Node: Array Functions976460 +Node: Flattening Arrays980314 +Node: Creating Arrays987201 +Node: Extension API Variables991968 +Node: Extension Versioning992604 +Node: Extension API Informational Variables994505 +Node: Extension API Boilerplate995593 +Node: Finding Extensions999409 +Node: Extension Example999969 +Node: Internal File Description1000741 +Node: Internal File Ops1004808 +Ref: Internal File Ops-Footnote-11016466 +Node: Using Internal File Ops1016606 +Ref: Using Internal File Ops-Footnote-11018989 +Node: Extension Samples1019262 +Node: Extension Sample File Functions1020786 +Node: Extension Sample Fnmatch1028388 +Node: Extension Sample Fork1029870 +Node: Extension Sample Inplace1031083 +Node: Extension Sample Ord1032758 +Node: Extension Sample Readdir1033594 +Ref: table-readdir-file-types1034450 +Node: Extension Sample Revout1035261 +Node: Extension Sample Rev2way1035852 +Node: Extension Sample Read write array1036593 +Node: Extension Sample Readfile1038532 +Node: Extension Sample Time1039627 +Node: Extension Sample API Tests1040976 +Node: gawkextlib1041467 +Node: Extension summary1044117 +Node: Extension Exercises1047799 +Node: Language History1048521 +Node: V7/SVR3.11050178 +Node: SVR41052359 +Node: POSIX1053804 +Node: BTL1055193 +Node: POSIX/GNU1055927 +Node: Feature History1061496 +Node: Common Extensions1074587 +Node: Ranges and Locales1075911 +Ref: Ranges and Locales-Footnote-11080550 +Ref: Ranges and Locales-Footnote-21080577 +Ref: Ranges and Locales-Footnote-31080811 +Node: Contributors1081032 +Node: History summary1086572 +Node: Installation1087941 +Node: Gawk Distribution1088897 +Node: Getting1089381 +Node: Extracting1090205 +Node: Distribution contents1091847 +Node: Unix Installation1097564 +Node: Quick Installation1098181 +Node: Additional Configuration Options1100612 +Node: Configuration Philosophy1102352 +Node: Non-Unix Installation1104703 +Node: PC Installation1105161 +Node: PC Binary Installation1106487 +Node: PC Compiling1108335 +Ref: PC Compiling-Footnote-11111356 +Node: PC Testing1111461 +Node: PC Using1112637 +Node: Cygwin1116752 +Node: MSYS1117575 +Node: VMS Installation1118073 +Node: VMS Compilation1118865 +Ref: VMS Compilation-Footnote-11120087 +Node: VMS Dynamic Extensions1120145 +Node: VMS Installation Details1121829 +Node: VMS Running1124081 +Node: VMS GNV1126922 +Node: VMS Old Gawk1127656 +Node: Bugs1128126 +Node: Other Versions1132030 +Node: Installation summary1138243 +Node: Notes1139299 +Node: Compatibility Mode1140164 +Node: Additions1140946 +Node: Accessing The Source1141871 +Node: Adding Code1143307 +Node: New Ports1149479 +Node: Derived Files1153961 +Ref: Derived Files-Footnote-11159436 +Ref: Derived Files-Footnote-21159470 +Ref: Derived Files-Footnote-31160066 +Node: Future Extensions1160180 +Node: Implementation Limitations1160786 +Node: Extension Design1162034 +Node: Old Extension Problems1163188 +Ref: Old Extension Problems-Footnote-11164705 +Node: Extension New Mechanism Goals1164762 +Ref: Extension New Mechanism Goals-Footnote-11168122 +Node: Extension Other Design Decisions1168311 +Node: Extension Future Growth1170419 +Node: Old Extension Mechanism1171255 +Node: Notes summary1173017 +Node: Basic Concepts1174203 +Node: Basic High Level1174884 +Ref: figure-general-flow1175156 +Ref: figure-process-flow1175755 +Ref: Basic High Level-Footnote-11178984 +Node: Basic Data Typing1179169 +Node: Glossary1182497 +Node: Copying1207655 +Node: GNU Free Documentation License1245211 +Node: Index1270347 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 4cb6a781..543c9bba 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -4335,30 +4335,26 @@ behaves. @cindex @env{AWKPATH} environment variable @cindex directories, searching for source files @cindex search paths, for source files -@cindex differences in @command{awk} and @command{gawk}, @code{AWKPATH} environment variable +@cindex differences in @command{awk} and @command{gawk}, @env{AWKPATH} environment variable @ifinfo The previous @value{SECTION} described how @command{awk} program files can be named on the command line with the @option{-f} option. @end ifinfo In most @command{awk} -implementations, you must supply a precise path name for each program +implementations, you must supply a precise pathname for each program file, unless the file is in the current directory. -But in @command{gawk}, if the @value{FN} supplied to the @option{-f} +But with @command{gawk}, if the @value{FN} supplied to the @option{-f} or @option{-i} options does not contain a directory separator @samp{/}, then @command{gawk} searches a list of directories (called the @dfn{search path}), one by one, looking for a file with the specified name. The search path is a string consisting of directory names -separated by colons@footnote{Semicolons on MS-Windows and MS-DOS.}. @command{gawk} gets its search path from the +separated by colons.@footnote{Semicolons on MS-Windows and MS-DOS.} +@command{gawk} gets its search path from the @env{AWKPATH} environment variable. If that variable does not exist, -@command{gawk} uses a default path, -@samp{.:/usr/local/share/awk}.@footnote{Your version of @command{gawk} -may use a different directory; it -will depend upon how @command{gawk} was built and installed. The actual -directory is the value of @code{$(datadir)} generated when -@command{gawk} was configured. You probably don't need to worry about this, -though.} +or if it has an empty value, +@command{gawk} uses a default path (described shortly). The search path feature is particularly helpful for building libraries of useful @command{awk} functions. The library files can be placed in a @@ -4366,7 +4362,7 @@ standard directory in the default path and then specified on the command line with a short @value{FN}. Otherwise, you would have to type the full @value{FN} for each file. -By using the @option{-i} option, or the @option{-e} and @option{-f} options, your command-line +By using the @option{-i} or @option{-f} options, your command-line @command{awk} programs can use facilities in @command{awk} library files (@pxref{Library Functions}). Path searching is not done if @command{gawk} is in compatibility mode. @@ -4374,7 +4370,7 @@ This is true for both @option{--traditional} and @option{--posix}. @xref{Options}. If the source code file is not found after the initial search, the path is searched -again after adding the default @samp{.awk} suffix to the @value{FN}. +again after adding the suffix @samp{.awk} to the @value{FN}. @command{gawk}'s path search mechanism is similar to the shell's. @@ -4386,19 +4382,30 @@ directory. colon or by placing two colons next to each other [@samp{::}].) @quotation NOTE -@command{gawk} always looks in the current directory @emph{before} -searching @env{AWKPATH}. Thus, while you can include the current directory -in the search path, either explicitly or with a null entry, there is no -real reason to do so. -@c Prior to 4.0, gawk searched the current directory after the -@c path search, but it's not worth documenting it. +To include the current directory in the path, either place @file{.} +as an entry in the path or write a null entry in the path. + +Different past versions of @command{gawk} would also look explicitly in +the current directory, either before or after the path search. As of +@value{PVERSION} 4.1.2, this no longer happens, and if you wish to look +in the current directory, you must include @file{.} either as a separate +entry, or as a null entry in the search path. @end quotation -If @env{AWKPATH} is not defined in the -environment, @command{gawk} places its default search path into -@code{ENVIRON["AWKPATH"]}. This makes it easy to determine -the actual search path that @command{gawk} used -from within an @command{awk} program. +The default value for @env{AWKPATH} is +@samp{.:/usr/local/share/awk}.@footnote{Your version of @command{gawk} +may use a different directory; it +will depend upon how @command{gawk} was built and installed. The actual +directory is the value of @code{$(datadir)} generated when +@command{gawk} was configured. You probably don't need to worry about this, +though.} Since @file{.} is included at the beginning, @command{gawk} +searches first in the current directory and then in @file{/usr/local/share/awk}. +In practice, this means that you will rarely need to change the +value of @env{AWKPATH}. + +@command{gawk} places the value of the search path that it used into +@code{ENVIRON["AWKPATH"]}. This provides access to the actual search +path value from within an @command{awk} program. While you can change @code{ENVIRON["AWKPATH"]} within your @command{awk} program, this has no effect on the running program's behavior. This makes @@ -4422,6 +4429,15 @@ the platform. For example, on GNU/Linux systems, the suffix @samp{.so} is used. The search path specified is also used for extensions loaded via the @code{@@load} keyword (@pxref{Loading Shared Libraries}). +If @env{AWKLIBPATH} does not exist in the environment, or if it has +an empty value, @command{gawk} uses a default path; this +is typically @samp{/usr/local/lib/gawk}, although it can vary depending +upon how @command{gawk} was built. + +@command{gawk} places the value of the search path that it used into +@code{ENVIRON["AWKLIBPATH"]}. This provides access to the actual search +path value from within an @command{awk} program. + @node Other Environment Variables @subsection Other Environment Variables @@ -4634,9 +4650,9 @@ or: @end example @noindent -are valid. The @code{AWKPATH} environment variable can be of great +are valid. The @env{AWKPATH} environment variable can be of great value when using @code{@@include}. The same rules for the use -of the @code{AWKPATH} variable in command-line file searches +of the @env{AWKPATH} variable in command-line file searches (@pxref{AWKPATH Variable}) apply to @code{@@include} also. @@ -4644,7 +4660,7 @@ This is very helpful in constructing @command{gawk} function libraries. If you have a large script with useful, general purpose @command{awk} functions, you can break it down into library files and put those files in a special directory. You can then include those ``libraries,'' using -either the full pathnames of the files, or by setting the @code{AWKPATH} +either the full pathnames of the files, or by setting the @env{AWKPATH} environment variable accordingly and then using @code{@@include} with just the file part of the full pathname. Of course you can have more than one directory to keep library files; the more complex the working @@ -37638,8 +37654,8 @@ EMX (OS/2 only) supports at least the @samp{|&} operator. @cindex search paths, for source files @cindex @command{gawk}, MS-DOS version of @cindex @command{gawk}, MS-Windows version of -@cindex @code{;} (semicolon), @code{AWKPATH} variable and -@cindex semicolon (@code{;}), @code{AWKPATH} variable and +@cindex @code{;} (semicolon), @env{AWKPATH} variable and +@cindex semicolon (@code{;}), @env{AWKPATH} variable and @cindex @env{AWKPATH} environment variable The MS-DOS and MS-Windows versions of @command{gawk} search for program files as described in @ref{AWKPATH Variable}. However, diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 001dd8b7..2e037a8f 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -4246,30 +4246,26 @@ behaves. @cindex @env{AWKPATH} environment variable @cindex directories, searching for source files @cindex search paths, for source files -@cindex differences in @command{awk} and @command{gawk}, @code{AWKPATH} environment variable +@cindex differences in @command{awk} and @command{gawk}, @env{AWKPATH} environment variable @ifinfo The previous @value{SECTION} described how @command{awk} program files can be named on the command line with the @option{-f} option. @end ifinfo In most @command{awk} -implementations, you must supply a precise path name for each program +implementations, you must supply a precise pathname for each program file, unless the file is in the current directory. -But in @command{gawk}, if the @value{FN} supplied to the @option{-f} +But with @command{gawk}, if the @value{FN} supplied to the @option{-f} or @option{-i} options does not contain a directory separator @samp{/}, then @command{gawk} searches a list of directories (called the @dfn{search path}), one by one, looking for a file with the specified name. The search path is a string consisting of directory names -separated by colons@footnote{Semicolons on MS-Windows and MS-DOS.}. @command{gawk} gets its search path from the +separated by colons.@footnote{Semicolons on MS-Windows and MS-DOS.} +@command{gawk} gets its search path from the @env{AWKPATH} environment variable. If that variable does not exist, -@command{gawk} uses a default path, -@samp{.:/usr/local/share/awk}.@footnote{Your version of @command{gawk} -may use a different directory; it -will depend upon how @command{gawk} was built and installed. The actual -directory is the value of @code{$(datadir)} generated when -@command{gawk} was configured. You probably don't need to worry about this, -though.} +or if it has an empty value, +@command{gawk} uses a default path (described shortly). The search path feature is particularly helpful for building libraries of useful @command{awk} functions. The library files can be placed in a @@ -4277,7 +4273,7 @@ standard directory in the default path and then specified on the command line with a short @value{FN}. Otherwise, you would have to type the full @value{FN} for each file. -By using the @option{-i} option, or the @option{-e} and @option{-f} options, your command-line +By using the @option{-i} or @option{-f} options, your command-line @command{awk} programs can use facilities in @command{awk} library files (@pxref{Library Functions}). Path searching is not done if @command{gawk} is in compatibility mode. @@ -4285,7 +4281,7 @@ This is true for both @option{--traditional} and @option{--posix}. @xref{Options}. If the source code file is not found after the initial search, the path is searched -again after adding the default @samp{.awk} suffix to the @value{FN}. +again after adding the suffix @samp{.awk} to the @value{FN}. @command{gawk}'s path search mechanism is similar to the shell's. @@ -4297,19 +4293,30 @@ directory. colon or by placing two colons next to each other [@samp{::}].) @quotation NOTE -@command{gawk} always looks in the current directory @emph{before} -searching @env{AWKPATH}. Thus, while you can include the current directory -in the search path, either explicitly or with a null entry, there is no -real reason to do so. -@c Prior to 4.0, gawk searched the current directory after the -@c path search, but it's not worth documenting it. +To include the current directory in the path, either place @file{.} +as an entry in the path or write a null entry in the path. + +Different past versions of @command{gawk} would also look explicitly in +the current directory, either before or after the path search. As of +@value{PVERSION} 4.1.2, this no longer happens, and if you wish to look +in the current directory, you must include @file{.} either as a separate +entry, or as a null entry in the search path. @end quotation -If @env{AWKPATH} is not defined in the -environment, @command{gawk} places its default search path into -@code{ENVIRON["AWKPATH"]}. This makes it easy to determine -the actual search path that @command{gawk} used -from within an @command{awk} program. +The default value for @env{AWKPATH} is +@samp{.:/usr/local/share/awk}.@footnote{Your version of @command{gawk} +may use a different directory; it +will depend upon how @command{gawk} was built and installed. The actual +directory is the value of @code{$(datadir)} generated when +@command{gawk} was configured. You probably don't need to worry about this, +though.} Since @file{.} is included at the beginning, @command{gawk} +searches first in the current directory and then in @file{/usr/local/share/awk}. +In practice, this means that you will rarely need to change the +value of @env{AWKPATH}. + +@command{gawk} places the value of the search path that it used into +@code{ENVIRON["AWKPATH"]}. This provides access to the actual search +path value from within an @command{awk} program. While you can change @code{ENVIRON["AWKPATH"]} within your @command{awk} program, this has no effect on the running program's behavior. This makes @@ -4333,6 +4340,15 @@ the platform. For example, on GNU/Linux systems, the suffix @samp{.so} is used. The search path specified is also used for extensions loaded via the @code{@@load} keyword (@pxref{Loading Shared Libraries}). +If @env{AWKLIBPATH} does not exist in the environment, or if it has +an empty value, @command{gawk} uses a default path; this +is typically @samp{/usr/local/lib/gawk}, although it can vary depending +upon how @command{gawk} was built. + +@command{gawk} places the value of the search path that it used into +@code{ENVIRON["AWKLIBPATH"]}. This provides access to the actual search +path value from within an @command{awk} program. + @node Other Environment Variables @subsection Other Environment Variables @@ -4545,9 +4561,9 @@ or: @end example @noindent -are valid. The @code{AWKPATH} environment variable can be of great +are valid. The @env{AWKPATH} environment variable can be of great value when using @code{@@include}. The same rules for the use -of the @code{AWKPATH} variable in command-line file searches +of the @env{AWKPATH} variable in command-line file searches (@pxref{AWKPATH Variable}) apply to @code{@@include} also. @@ -4555,7 +4571,7 @@ This is very helpful in constructing @command{gawk} function libraries. If you have a large script with useful, general purpose @command{awk} functions, you can break it down into library files and put those files in a special directory. You can then include those ``libraries,'' using -either the full pathnames of the files, or by setting the @code{AWKPATH} +either the full pathnames of the files, or by setting the @env{AWKPATH} environment variable accordingly and then using @code{@@include} with just the file part of the full pathname. Of course you can have more than one directory to keep library files; the more complex the working @@ -36732,8 +36748,8 @@ EMX (OS/2 only) supports at least the @samp{|&} operator. @cindex search paths, for source files @cindex @command{gawk}, MS-DOS version of @cindex @command{gawk}, MS-Windows version of -@cindex @code{;} (semicolon), @code{AWKPATH} variable and -@cindex semicolon (@code{;}), @code{AWKPATH} variable and +@cindex @code{;} (semicolon), @env{AWKPATH} variable and +@cindex semicolon (@code{;}), @env{AWKPATH} variable and @cindex @env{AWKPATH} environment variable The MS-DOS and MS-Windows versions of @command{gawk} search for program files as described in @ref{AWKPATH Variable}. However, @@ -2505,7 +2505,6 @@ do_getline(int into_variable, IOBUF *iop) typedef struct { const char *envname; char **dfltp; /* pointer to address of default path */ - char try_cwd; /* always search current directory? */ char **awkpath; /* array containing library search paths */ int max_pathlen; /* length of the longest item in awkpath */ } path_info; @@ -2513,13 +2512,11 @@ typedef struct { static path_info pi_awkpath = { /* envname */ "AWKPATH", /* dfltp */ & defpath, - /* try_cwd */ true, }; static path_info pi_awklibpath = { /* envname */ "AWKLIBPATH", /* dfltp */ & deflibpath, - /* try_cwd */ false, }; /* init_awkpath --- split path(=$AWKPATH) into components */ @@ -2577,30 +2574,6 @@ init_awkpath(path_info *pi) #undef INC_PATH } -/* get_cwd -- get current working directory */ - -static char * -get_cwd () -{ -#define BSIZE 100 - char *buf; - size_t bsize = BSIZE; - - emalloc(buf, char *, bsize * sizeof(char), "get_cwd"); - while (true) { - if (getcwd(buf, bsize) == buf) - return buf; - if (errno != ERANGE) { - efree(buf); - return NULL; - } - bsize *= 2; - erealloc(buf, char *, bsize * sizeof(char), "get_cwd"); - } -#undef BSIZE -} - - /* do_find_source --- search $AWKPATH for file, return NULL if not found */ static char * @@ -2622,24 +2595,6 @@ do_find_source(const char *src, struct stat *stb, int *errcode, path_info *pi) return NULL; } - /* try current directory before $AWKPATH search */ - if (pi->try_cwd && stat(src, stb) == 0) { - path = get_cwd(); - if (path == NULL) { - *errcode = errno; - return NULL; - } - erealloc(path, char *, strlen(path) + strlen(src) + 2, "do_find_source"); -#ifdef VMS - if (strcspn(path,">]:") == strlen(path)) - strcat(path, "/"); -#else - strcat(path, "/"); -#endif - strcat(path, src); - return path; - } - if (pi->awkpath == NULL) init_awkpath(pi); @@ -1078,18 +1078,23 @@ path_environ(const char *pname, const char *dflt) NODE *tmp; tmp = make_string(pname, strlen(pname)); - if (! in_array(ENVIRON_node, tmp)) { - /* - * On VMS, environ[] only holds a subset of what getenv() can - * find, so look AWKPATH up before resorting to default path. - */ - val = getenv(pname); - if (val == NULL) - val = dflt; - aptr = assoc_lookup(ENVIRON_node, tmp); + /* + * On VMS, environ[] only holds a subset of what getenv() can + * find, so look AWKPATH up before resorting to default path. + */ + val = getenv(pname); + if (val == NULL || *val == '\0') + val = dflt; + aptr = assoc_lookup(ENVIRON_node, tmp); + /* + * If original value was the empty string, set it to + * the default value. + */ + if ((*aptr)->stlen == 0) { unref(*aptr); *aptr = make_string(val, strlen(val)); } + unref(tmp); } @@ -1136,6 +1141,11 @@ load_environ() /* * Put AWKPATH and AWKLIBPATH into ENVIRON if not already there. * This allows querying it from within awk programs. + * + * October 2014: + * If their values are "", override with the default values; + * since 2.10 AWKPATH used default value if environment's + * value was "". */ path_environ("AWKPATH", defpath); path_environ("AWKLIBPATH", deflibpath); |