diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-10-15 11:43:11 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-10-15 11:43:11 +0300 |
commit | 6f373546792c2befaa2d9d0fffb12fda80320042 (patch) | |
tree | 20be35d4d79b4eacf2fedab8574f6b33c8bdad1f | |
parent | d7a6deaeca178a15c600fbc13262aca29fb39753 (diff) | |
parent | 74ee0dcab17240a1626b77ed998b07f0f6560a48 (diff) | |
download | egawk-6f373546792c2befaa2d9d0fffb12fda80320042.tar.gz egawk-6f373546792c2befaa2d9d0fffb12fda80320042.tar.bz2 egawk-6f373546792c2befaa2d9d0fffb12fda80320042.zip |
Merge branch 'gawk-4.1-stable'
-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 05b7585e..3cdba352 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 6ca2e807..fd79adb9 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -2872,17 +2872,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 @@ -2890,15 +2890,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/).) @@ -2906,15 +2904,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 @@ -2946,6 +2952,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 @@ -34389,513 +34404,513 @@ Node: Other Arguments130967 Node: Naming Standard Input133928 Node: Environment Variables135021 Node: AWKPATH Variable135579 -Ref: AWKPATH Variable-Footnote-1138431 -Ref: AWKPATH Variable-Footnote-2138476 -Node: AWKLIBPATH Variable138736 -Node: Other Environment Variables139495 -Node: Exit Status142986 -Node: Include Files143661 -Node: Loading Shared Libraries147249 -Node: Obsolete148676 -Node: Undocumented149373 -Node: Invoking Summary149640 -Node: Regexp151306 -Node: Regexp Usage152765 -Node: Escape Sequences154798 -Node: Regexp Operators160898 -Ref: Regexp Operators-Footnote-1168332 -Ref: Regexp Operators-Footnote-2168479 -Node: Bracket Expressions168577 -Ref: table-char-classes170594 -Node: Leftmost Longest173534 -Node: Computed Regexps174836 -Node: GNU Regexp Operators178233 -Node: Case-sensitivity181935 -Ref: Case-sensitivity-Footnote-1184825 -Ref: Case-sensitivity-Footnote-2185060 -Node: Regexp Summary185168 -Node: Reading Files186637 -Node: Records188731 -Node: awk split records189463 -Node: gawk split records194377 -Ref: gawk split records-Footnote-1198916 -Node: Fields198953 -Ref: Fields-Footnote-1201751 -Node: Nonconstant Fields201837 -Ref: Nonconstant Fields-Footnote-1204073 -Node: Changing Fields204275 -Node: Field Separators210207 -Node: Default Field Splitting212911 -Node: Regexp Field Splitting214028 -Node: Single Character Fields217378 -Node: Command Line Field Separator218437 -Node: Full Line Fields221649 -Ref: Full Line Fields-Footnote-1222157 -Node: Field Splitting Summary222203 -Ref: Field Splitting Summary-Footnote-1225334 -Node: Constant Size225435 -Node: Splitting By Content230041 -Ref: Splitting By Content-Footnote-1234114 -Node: Multiple Line234154 -Ref: Multiple Line-Footnote-1240043 -Node: Getline240222 -Node: Plain Getline242433 -Node: Getline/Variable245073 -Node: Getline/File246220 -Node: Getline/Variable/File247604 -Ref: Getline/Variable/File-Footnote-1249205 -Node: Getline/Pipe249292 -Node: Getline/Variable/Pipe251975 -Node: Getline/Coprocess253106 -Node: Getline/Variable/Coprocess254358 -Node: Getline Notes255097 -Node: Getline Summary257889 -Ref: table-getline-variants258301 -Node: Read Timeout259130 -Ref: Read Timeout-Footnote-1262944 -Node: Command-line directories263002 -Node: Input Summary263906 -Node: Input Exercises267158 -Node: Printing267886 -Node: Print269663 -Node: Print Examples271120 -Node: Output Separators273899 -Node: OFMT275917 -Node: Printf277271 -Node: Basic Printf278056 -Node: Control Letters279627 -Node: Format Modifiers283611 -Node: Printf Examples289618 -Node: Redirection292100 -Node: Special FD298939 -Ref: Special FD-Footnote-1302096 -Node: Special Files302170 -Node: Other Inherited Files302786 -Node: Special Network303786 -Node: Special Caveats304647 -Node: Close Files And Pipes305598 -Ref: Close Files And Pipes-Footnote-1312777 -Ref: Close Files And Pipes-Footnote-2312925 -Node: Output Summary313075 -Node: Output Exercises314071 -Node: Expressions314751 -Node: Values315936 -Node: Constants316612 -Node: Scalar Constants317292 -Ref: Scalar Constants-Footnote-1318151 -Node: Nondecimal-numbers318401 -Node: Regexp Constants321401 -Node: Using Constant Regexps321926 -Node: Variables325064 -Node: Using Variables325719 -Node: Assignment Options327629 -Node: Conversion329504 -Node: Strings And Numbers330028 -Ref: Strings And Numbers-Footnote-1333092 -Node: Locale influences conversions333201 -Ref: table-locale-affects335946 -Node: All Operators336534 -Node: Arithmetic Ops337164 -Node: Concatenation339669 -Ref: Concatenation-Footnote-1342488 -Node: Assignment Ops342594 -Ref: table-assign-ops347577 -Node: Increment Ops348855 -Node: Truth Values and Conditions352293 -Node: Truth Values353376 -Node: Typing and Comparison354425 -Node: Variable Typing355218 -Node: Comparison Operators358870 -Ref: table-relational-ops359280 -Node: POSIX String Comparison362795 -Ref: POSIX String Comparison-Footnote-1363867 -Node: Boolean Ops364005 -Ref: Boolean Ops-Footnote-1368484 -Node: Conditional Exp368575 -Node: Function Calls370302 -Node: Precedence374182 -Node: Locales377850 -Node: Expressions Summary379481 -Node: Patterns and Actions382055 -Node: Pattern Overview383175 -Node: Regexp Patterns384854 -Node: Expression Patterns385397 -Node: Ranges389177 -Node: BEGIN/END392283 -Node: Using BEGIN/END393045 -Ref: Using BEGIN/END-Footnote-1395782 -Node: I/O And BEGIN/END395888 -Node: BEGINFILE/ENDFILE398202 -Node: Empty401103 -Node: Using Shell Variables401420 -Node: Action Overview403696 -Node: Statements406023 -Node: If Statement407871 -Node: While Statement409369 -Node: Do Statement411397 -Node: For Statement412539 -Node: Switch Statement415694 -Node: Break Statement418082 -Node: Continue Statement420123 -Node: Next Statement421948 -Node: Nextfile Statement424328 -Node: Exit Statement426958 -Node: Built-in Variables429361 -Node: User-modified430494 -Ref: User-modified-Footnote-1438174 -Node: Auto-set438236 -Ref: Auto-set-Footnote-1451603 -Ref: Auto-set-Footnote-2451808 -Node: ARGC and ARGV451864 -Node: Pattern Action Summary456068 -Node: Arrays458495 -Node: Array Basics459824 -Node: Array Intro460668 -Ref: figure-array-elements462632 -Ref: Array Intro-Footnote-1465156 -Node: Reference to Elements465284 -Node: Assigning Elements467734 -Node: Array Example468225 -Node: Scanning an Array469983 -Node: Controlling Scanning472999 -Ref: Controlling Scanning-Footnote-1478188 -Node: Numeric Array Subscripts478504 -Node: Uninitialized Subscripts480689 -Node: Delete482306 -Ref: Delete-Footnote-1485050 -Node: Multidimensional485107 -Node: Multiscanning488202 -Node: Arrays of Arrays489791 -Node: Arrays Summary494552 -Node: Functions496657 -Node: Built-in497530 -Node: Calling Built-in498608 -Node: Numeric Functions500596 -Ref: Numeric Functions-Footnote-1505420 -Ref: Numeric Functions-Footnote-2505777 -Ref: Numeric Functions-Footnote-3505825 -Node: String Functions506094 -Ref: String Functions-Footnote-1529566 -Ref: String Functions-Footnote-2529695 -Ref: String Functions-Footnote-3529943 -Node: Gory Details530030 -Ref: table-sub-escapes531811 -Ref: table-sub-proposed533331 -Ref: table-posix-sub534695 -Ref: table-gensub-escapes536235 -Ref: Gory Details-Footnote-1537067 -Node: I/O Functions537218 -Ref: I/O Functions-Footnote-1544319 -Node: Time Functions544466 -Ref: Time Functions-Footnote-1554935 -Ref: Time Functions-Footnote-2555003 -Ref: Time Functions-Footnote-3555161 -Ref: Time Functions-Footnote-4555272 -Ref: Time Functions-Footnote-5555384 -Ref: Time Functions-Footnote-6555611 -Node: Bitwise Functions555877 -Ref: table-bitwise-ops556439 -Ref: Bitwise Functions-Footnote-1560747 -Node: Type Functions560916 -Node: I18N Functions562065 -Node: User-defined563710 -Node: Definition Syntax564514 -Ref: Definition Syntax-Footnote-1569920 -Node: Function Example569989 -Ref: Function Example-Footnote-1572906 -Node: Function Caveats572928 -Node: Calling A Function573446 -Node: Variable Scope574401 -Node: Pass By Value/Reference577389 -Node: Return Statement580899 -Node: Dynamic Typing583883 -Node: Indirect Calls584812 -Ref: Indirect Calls-Footnote-1596116 -Node: Functions Summary596244 -Node: Library Functions598943 -Ref: Library Functions-Footnote-1602561 -Ref: Library Functions-Footnote-2602704 -Node: Library Names602875 -Ref: Library Names-Footnote-1606335 -Ref: Library Names-Footnote-2606555 -Node: General Functions606641 -Node: Strtonum Function607744 -Node: Assert Function610764 -Node: Round Function614088 -Node: Cliff Random Function615629 -Node: Ordinal Functions616645 -Ref: Ordinal Functions-Footnote-1619710 -Ref: Ordinal Functions-Footnote-2619962 -Node: Join Function620173 -Ref: Join Function-Footnote-1621944 -Node: Getlocaltime Function622144 -Node: Readfile Function625885 -Node: Shell Quoting627855 -Node: Data File Management629256 -Node: Filetrans Function629888 -Node: Rewind Function633947 -Node: File Checking635332 -Ref: File Checking-Footnote-1636660 -Node: Empty Files636861 -Node: Ignoring Assigns638840 -Node: Getopt Function640391 -Ref: Getopt Function-Footnote-1651851 -Node: Passwd Functions652054 -Ref: Passwd Functions-Footnote-1660905 -Node: Group Functions660993 -Ref: Group Functions-Footnote-1668896 -Node: Walking Arrays669109 -Node: Library Functions Summary670712 -Node: Library Exercises672113 -Node: Sample Programs673393 -Node: Running Examples674163 -Node: Clones674891 -Node: Cut Program676115 -Node: Egrep Program685845 -Ref: Egrep Program-Footnote-1693349 -Node: Id Program693459 -Node: Split Program697103 -Ref: Split Program-Footnote-1700549 -Node: Tee Program700677 -Node: Uniq Program703464 -Node: Wc Program710885 -Ref: Wc Program-Footnote-1715133 -Node: Miscellaneous Programs715225 -Node: Dupword Program716438 -Node: Alarm Program718469 -Node: Translate Program723273 -Ref: Translate Program-Footnote-1727837 -Node: Labels Program728107 -Ref: Labels Program-Footnote-1731456 -Node: Word Sorting731540 -Node: History Sorting735610 -Node: Extract Program737446 -Node: Simple Sed744978 -Node: Igawk Program748040 -Ref: Igawk Program-Footnote-1762366 -Ref: Igawk Program-Footnote-2762567 -Ref: Igawk Program-Footnote-3762689 -Node: Anagram Program762804 -Node: Signature Program765866 -Node: Programs Summary767113 -Node: Programs Exercises768306 -Ref: Programs Exercises-Footnote-1772437 -Node: Advanced Features772528 -Node: Nondecimal Data774476 -Node: Array Sorting776066 -Node: Controlling Array Traversal776763 -Ref: Controlling Array Traversal-Footnote-1785094 -Node: Array Sorting Functions785212 -Ref: Array Sorting Functions-Footnote-1789104 -Node: Two-way I/O789298 -Ref: Two-way I/O-Footnote-1794242 -Ref: Two-way I/O-Footnote-2794428 -Node: TCP/IP Networking794510 -Node: Profiling797382 -Node: Advanced Features Summary804935 -Node: Internationalization806868 -Node: I18N and L10N808348 -Node: Explaining gettext809034 -Ref: Explaining gettext-Footnote-1814063 -Ref: Explaining gettext-Footnote-2814247 -Node: Programmer i18n814412 -Ref: Programmer i18n-Footnote-1819278 -Node: Translator i18n819327 -Node: String Extraction820121 -Ref: String Extraction-Footnote-1821252 -Node: Printf Ordering821338 -Ref: Printf Ordering-Footnote-1824124 -Node: I18N Portability824188 -Ref: I18N Portability-Footnote-1826637 -Node: I18N Example826700 -Ref: I18N Example-Footnote-1829500 -Node: Gawk I18N829572 -Node: I18N Summary830210 -Node: Debugger831549 -Node: Debugging832571 -Node: Debugging Concepts833012 -Node: Debugging Terms834869 -Node: Awk Debugging837444 -Node: Sample Debugging Session838336 -Node: Debugger Invocation838856 -Node: Finding The Bug840240 -Node: List of Debugger Commands846715 -Node: Breakpoint Control848047 -Node: Debugger Execution Control851739 -Node: Viewing And Changing Data855103 -Node: Execution Stack858468 -Node: Debugger Info860106 -Node: Miscellaneous Debugger Commands864123 -Node: Readline Support869315 -Node: Limitations870207 -Node: Debugging Summary872304 -Node: Arbitrary Precision Arithmetic873472 -Node: Computer Arithmetic874888 -Ref: table-numeric-ranges878489 -Ref: Computer Arithmetic-Footnote-1879348 -Node: Math Definitions879405 -Ref: table-ieee-formats882692 -Ref: Math Definitions-Footnote-1883296 -Node: MPFR features883401 -Node: FP Math Caution885072 -Ref: FP Math Caution-Footnote-1886122 -Node: Inexactness of computations886491 -Node: Inexact representation887439 -Node: Comparing FP Values888794 -Node: Errors accumulate889867 -Node: Getting Accuracy891300 -Node: Try To Round893959 -Node: Setting precision894858 -Ref: table-predefined-precision-strings895542 -Node: Setting the rounding mode897336 -Ref: table-gawk-rounding-modes897700 -Ref: Setting the rounding mode-Footnote-1901154 -Node: Arbitrary Precision Integers901333 -Ref: Arbitrary Precision Integers-Footnote-1906237 -Node: POSIX Floating Point Problems906386 -Ref: POSIX Floating Point Problems-Footnote-1910262 -Node: Floating point summary910300 -Node: Dynamic Extensions912492 -Node: Extension Intro914044 -Node: Plugin License915310 -Node: Extension Mechanism Outline916107 -Ref: figure-load-extension916535 -Ref: figure-register-new-function918015 -Ref: figure-call-new-function919019 -Node: Extension API Description921005 -Node: Extension API Functions Introduction922455 -Node: General Data Types927291 -Ref: General Data Types-Footnote-1932978 -Node: Memory Allocation Functions933277 -Ref: Memory Allocation Functions-Footnote-1936107 -Node: Constructor Functions936203 -Node: Registration Functions937937 -Node: Extension Functions938622 -Node: Exit Callback Functions940918 -Node: Extension Version String942166 -Node: Input Parsers942816 -Node: Output Wrappers952631 -Node: Two-way processors957147 -Node: Printing Messages959351 -Ref: Printing Messages-Footnote-1960428 -Node: Updating `ERRNO'960580 -Node: Requesting Values961320 -Ref: table-value-types-returned962048 -Node: Accessing Parameters963006 -Node: Symbol Table Access964237 -Node: Symbol table by name964751 -Node: Symbol table by cookie966731 -Ref: Symbol table by cookie-Footnote-1970870 -Node: Cached values970933 -Ref: Cached values-Footnote-1974437 -Node: Array Manipulation974528 -Ref: Array Manipulation-Footnote-1975626 -Node: Array Data Types975665 -Ref: Array Data Types-Footnote-1978322 -Node: Array Functions978414 -Node: Flattening Arrays982268 -Node: Creating Arrays989155 -Node: Extension API Variables993922 -Node: Extension Versioning994558 -Node: Extension API Informational Variables996459 -Node: Extension API Boilerplate997547 -Node: Finding Extensions1001363 -Node: Extension Example1001923 -Node: Internal File Description1002695 -Node: Internal File Ops1006762 -Ref: Internal File Ops-Footnote-11018420 -Node: Using Internal File Ops1018560 -Ref: Using Internal File Ops-Footnote-11020943 -Node: Extension Samples1021216 -Node: Extension Sample File Functions1022740 -Node: Extension Sample Fnmatch1030342 -Node: Extension Sample Fork1031824 -Node: Extension Sample Inplace1033037 -Node: Extension Sample Ord1034712 -Node: Extension Sample Readdir1035548 -Ref: table-readdir-file-types1036404 -Node: Extension Sample Revout1037215 -Node: Extension Sample Rev2way1037806 -Node: Extension Sample Read write array1038547 -Node: Extension Sample Readfile1040486 -Node: Extension Sample Time1041581 -Node: Extension Sample API Tests1042930 -Node: gawkextlib1043421 -Node: Extension summary1046071 -Node: Extension Exercises1049753 -Node: Language History1050475 -Node: V7/SVR3.11052132 -Node: SVR41054313 -Node: POSIX1055758 -Node: BTL1057147 -Node: POSIX/GNU1057881 -Node: Feature History1063510 -Node: Common Extensions1076601 -Node: Ranges and Locales1077925 -Ref: Ranges and Locales-Footnote-11082564 -Ref: Ranges and Locales-Footnote-21082591 -Ref: Ranges and Locales-Footnote-31082825 -Node: Contributors1083046 -Node: History summary1088586 -Node: Installation1089955 -Node: Gawk Distribution1090911 -Node: Getting1091395 -Node: Extracting1092219 -Node: Distribution contents1093861 -Node: Unix Installation1099631 -Node: Quick Installation1100248 -Node: Additional Configuration Options1102679 -Node: Configuration Philosophy1104419 -Node: Non-Unix Installation1106770 -Node: PC Installation1107228 -Node: PC Binary Installation1108554 -Node: PC Compiling1110402 -Ref: PC Compiling-Footnote-11113423 -Node: PC Testing1113528 -Node: PC Using1114704 -Node: Cygwin1118819 -Node: MSYS1119642 -Node: VMS Installation1120140 -Node: VMS Compilation1120932 -Ref: VMS Compilation-Footnote-11122154 -Node: VMS Dynamic Extensions1122212 -Node: VMS Installation Details1123896 -Node: VMS Running1126148 -Node: VMS GNV1128989 -Node: VMS Old Gawk1129723 -Node: Bugs1130193 -Node: Other Versions1134097 -Node: Installation summary1140310 -Node: Notes1141366 -Node: Compatibility Mode1142231 -Node: Additions1143013 -Node: Accessing The Source1143938 -Node: Adding Code1145374 -Node: New Ports1151546 -Node: Derived Files1156028 -Ref: Derived Files-Footnote-11161503 -Ref: Derived Files-Footnote-21161537 -Ref: Derived Files-Footnote-31162133 -Node: Future Extensions1162247 -Node: Implementation Limitations1162853 -Node: Extension Design1164101 -Node: Old Extension Problems1165255 -Ref: Old Extension Problems-Footnote-11166772 -Node: Extension New Mechanism Goals1166829 -Ref: Extension New Mechanism Goals-Footnote-11170189 -Node: Extension Other Design Decisions1170378 -Node: Extension Future Growth1172486 -Node: Old Extension Mechanism1173322 -Node: Notes summary1175084 -Node: Basic Concepts1176270 -Node: Basic High Level1176951 -Ref: figure-general-flow1177223 -Ref: figure-process-flow1177822 -Ref: Basic High Level-Footnote-11181051 -Node: Basic Data Typing1181236 -Node: Glossary1184564 -Node: Copying1209722 -Node: GNU Free Documentation License1247278 -Node: Index1272414 +Ref: AWKPATH Variable-Footnote-1138879 +Ref: AWKPATH Variable-Footnote-2138924 +Node: AWKLIBPATH Variable139184 +Node: Other Environment Variables140327 +Node: Exit Status143818 +Node: Include Files144493 +Node: Loading Shared Libraries148081 +Node: Obsolete149508 +Node: Undocumented150205 +Node: Invoking Summary150472 +Node: Regexp152138 +Node: Regexp Usage153597 +Node: Escape Sequences155630 +Node: Regexp Operators161730 +Ref: Regexp Operators-Footnote-1169164 +Ref: Regexp Operators-Footnote-2169311 +Node: Bracket Expressions169409 +Ref: table-char-classes171426 +Node: Leftmost Longest174366 +Node: Computed Regexps175668 +Node: GNU Regexp Operators179065 +Node: Case-sensitivity182767 +Ref: Case-sensitivity-Footnote-1185657 +Ref: Case-sensitivity-Footnote-2185892 +Node: Regexp Summary186000 +Node: Reading Files187469 +Node: Records189563 +Node: awk split records190295 +Node: gawk split records195209 +Ref: gawk split records-Footnote-1199748 +Node: Fields199785 +Ref: Fields-Footnote-1202583 +Node: Nonconstant Fields202669 +Ref: Nonconstant Fields-Footnote-1204905 +Node: Changing Fields205107 +Node: Field Separators211039 +Node: Default Field Splitting213743 +Node: Regexp Field Splitting214860 +Node: Single Character Fields218210 +Node: Command Line Field Separator219269 +Node: Full Line Fields222481 +Ref: Full Line Fields-Footnote-1222989 +Node: Field Splitting Summary223035 +Ref: Field Splitting Summary-Footnote-1226166 +Node: Constant Size226267 +Node: Splitting By Content230873 +Ref: Splitting By Content-Footnote-1234946 +Node: Multiple Line234986 +Ref: Multiple Line-Footnote-1240875 +Node: Getline241054 +Node: Plain Getline243265 +Node: Getline/Variable245905 +Node: Getline/File247052 +Node: Getline/Variable/File248436 +Ref: Getline/Variable/File-Footnote-1250037 +Node: Getline/Pipe250124 +Node: Getline/Variable/Pipe252807 +Node: Getline/Coprocess253938 +Node: Getline/Variable/Coprocess255190 +Node: Getline Notes255929 +Node: Getline Summary258721 +Ref: table-getline-variants259133 +Node: Read Timeout259962 +Ref: Read Timeout-Footnote-1263776 +Node: Command-line directories263834 +Node: Input Summary264738 +Node: Input Exercises267990 +Node: Printing268718 +Node: Print270495 +Node: Print Examples271952 +Node: Output Separators274731 +Node: OFMT276749 +Node: Printf278103 +Node: Basic Printf278888 +Node: Control Letters280459 +Node: Format Modifiers284443 +Node: Printf Examples290450 +Node: Redirection292932 +Node: Special FD299771 +Ref: Special FD-Footnote-1302928 +Node: Special Files303002 +Node: Other Inherited Files303618 +Node: Special Network304618 +Node: Special Caveats305479 +Node: Close Files And Pipes306430 +Ref: Close Files And Pipes-Footnote-1313609 +Ref: Close Files And Pipes-Footnote-2313757 +Node: Output Summary313907 +Node: Output Exercises314903 +Node: Expressions315583 +Node: Values316768 +Node: Constants317444 +Node: Scalar Constants318124 +Ref: Scalar Constants-Footnote-1318983 +Node: Nondecimal-numbers319233 +Node: Regexp Constants322233 +Node: Using Constant Regexps322758 +Node: Variables325896 +Node: Using Variables326551 +Node: Assignment Options328461 +Node: Conversion330336 +Node: Strings And Numbers330860 +Ref: Strings And Numbers-Footnote-1333924 +Node: Locale influences conversions334033 +Ref: table-locale-affects336778 +Node: All Operators337366 +Node: Arithmetic Ops337996 +Node: Concatenation340501 +Ref: Concatenation-Footnote-1343320 +Node: Assignment Ops343426 +Ref: table-assign-ops348409 +Node: Increment Ops349687 +Node: Truth Values and Conditions353125 +Node: Truth Values354208 +Node: Typing and Comparison355257 +Node: Variable Typing356050 +Node: Comparison Operators359702 +Ref: table-relational-ops360112 +Node: POSIX String Comparison363627 +Ref: POSIX String Comparison-Footnote-1364699 +Node: Boolean Ops364837 +Ref: Boolean Ops-Footnote-1369316 +Node: Conditional Exp369407 +Node: Function Calls371134 +Node: Precedence375014 +Node: Locales378682 +Node: Expressions Summary380313 +Node: Patterns and Actions382887 +Node: Pattern Overview384007 +Node: Regexp Patterns385686 +Node: Expression Patterns386229 +Node: Ranges390009 +Node: BEGIN/END393115 +Node: Using BEGIN/END393877 +Ref: Using BEGIN/END-Footnote-1396614 +Node: I/O And BEGIN/END396720 +Node: BEGINFILE/ENDFILE399034 +Node: Empty401935 +Node: Using Shell Variables402252 +Node: Action Overview404528 +Node: Statements406855 +Node: If Statement408703 +Node: While Statement410201 +Node: Do Statement412229 +Node: For Statement413371 +Node: Switch Statement416526 +Node: Break Statement418914 +Node: Continue Statement420955 +Node: Next Statement422780 +Node: Nextfile Statement425160 +Node: Exit Statement427790 +Node: Built-in Variables430193 +Node: User-modified431326 +Ref: User-modified-Footnote-1439006 +Node: Auto-set439068 +Ref: Auto-set-Footnote-1452435 +Ref: Auto-set-Footnote-2452640 +Node: ARGC and ARGV452696 +Node: Pattern Action Summary456900 +Node: Arrays459327 +Node: Array Basics460656 +Node: Array Intro461500 +Ref: figure-array-elements463464 +Ref: Array Intro-Footnote-1465988 +Node: Reference to Elements466116 +Node: Assigning Elements468566 +Node: Array Example469057 +Node: Scanning an Array470815 +Node: Controlling Scanning473831 +Ref: Controlling Scanning-Footnote-1479020 +Node: Numeric Array Subscripts479336 +Node: Uninitialized Subscripts481521 +Node: Delete483138 +Ref: Delete-Footnote-1485882 +Node: Multidimensional485939 +Node: Multiscanning489034 +Node: Arrays of Arrays490623 +Node: Arrays Summary495384 +Node: Functions497489 +Node: Built-in498362 +Node: Calling Built-in499440 +Node: Numeric Functions501428 +Ref: Numeric Functions-Footnote-1506252 +Ref: Numeric Functions-Footnote-2506609 +Ref: Numeric Functions-Footnote-3506657 +Node: String Functions506926 +Ref: String Functions-Footnote-1530398 +Ref: String Functions-Footnote-2530527 +Ref: String Functions-Footnote-3530775 +Node: Gory Details530862 +Ref: table-sub-escapes532643 +Ref: table-sub-proposed534163 +Ref: table-posix-sub535527 +Ref: table-gensub-escapes537067 +Ref: Gory Details-Footnote-1537899 +Node: I/O Functions538050 +Ref: I/O Functions-Footnote-1545151 +Node: Time Functions545298 +Ref: Time Functions-Footnote-1555767 +Ref: Time Functions-Footnote-2555835 +Ref: Time Functions-Footnote-3555993 +Ref: Time Functions-Footnote-4556104 +Ref: Time Functions-Footnote-5556216 +Ref: Time Functions-Footnote-6556443 +Node: Bitwise Functions556709 +Ref: table-bitwise-ops557271 +Ref: Bitwise Functions-Footnote-1561579 +Node: Type Functions561748 +Node: I18N Functions562897 +Node: User-defined564542 +Node: Definition Syntax565346 +Ref: Definition Syntax-Footnote-1570752 +Node: Function Example570821 +Ref: Function Example-Footnote-1573738 +Node: Function Caveats573760 +Node: Calling A Function574278 +Node: Variable Scope575233 +Node: Pass By Value/Reference578221 +Node: Return Statement581731 +Node: Dynamic Typing584715 +Node: Indirect Calls585644 +Ref: Indirect Calls-Footnote-1596948 +Node: Functions Summary597076 +Node: Library Functions599775 +Ref: Library Functions-Footnote-1603393 +Ref: Library Functions-Footnote-2603536 +Node: Library Names603707 +Ref: Library Names-Footnote-1607167 +Ref: Library Names-Footnote-2607387 +Node: General Functions607473 +Node: Strtonum Function608576 +Node: Assert Function611596 +Node: Round Function614920 +Node: Cliff Random Function616461 +Node: Ordinal Functions617477 +Ref: Ordinal Functions-Footnote-1620542 +Ref: Ordinal Functions-Footnote-2620794 +Node: Join Function621005 +Ref: Join Function-Footnote-1622776 +Node: Getlocaltime Function622976 +Node: Readfile Function626717 +Node: Shell Quoting628687 +Node: Data File Management630088 +Node: Filetrans Function630720 +Node: Rewind Function634779 +Node: File Checking636164 +Ref: File Checking-Footnote-1637492 +Node: Empty Files637693 +Node: Ignoring Assigns639672 +Node: Getopt Function641223 +Ref: Getopt Function-Footnote-1652683 +Node: Passwd Functions652886 +Ref: Passwd Functions-Footnote-1661737 +Node: Group Functions661825 +Ref: Group Functions-Footnote-1669728 +Node: Walking Arrays669941 +Node: Library Functions Summary671544 +Node: Library Exercises672945 +Node: Sample Programs674225 +Node: Running Examples674995 +Node: Clones675723 +Node: Cut Program676947 +Node: Egrep Program686677 +Ref: Egrep Program-Footnote-1694181 +Node: Id Program694291 +Node: Split Program697935 +Ref: Split Program-Footnote-1701381 +Node: Tee Program701509 +Node: Uniq Program704296 +Node: Wc Program711717 +Ref: Wc Program-Footnote-1715965 +Node: Miscellaneous Programs716057 +Node: Dupword Program717270 +Node: Alarm Program719301 +Node: Translate Program724105 +Ref: Translate Program-Footnote-1728669 +Node: Labels Program728939 +Ref: Labels Program-Footnote-1732288 +Node: Word Sorting732372 +Node: History Sorting736442 +Node: Extract Program738278 +Node: Simple Sed745810 +Node: Igawk Program748872 +Ref: Igawk Program-Footnote-1763198 +Ref: Igawk Program-Footnote-2763399 +Ref: Igawk Program-Footnote-3763521 +Node: Anagram Program763636 +Node: Signature Program766698 +Node: Programs Summary767945 +Node: Programs Exercises769138 +Ref: Programs Exercises-Footnote-1773269 +Node: Advanced Features773360 +Node: Nondecimal Data775308 +Node: Array Sorting776898 +Node: Controlling Array Traversal777595 +Ref: Controlling Array Traversal-Footnote-1785926 +Node: Array Sorting Functions786044 +Ref: Array Sorting Functions-Footnote-1789936 +Node: Two-way I/O790130 +Ref: Two-way I/O-Footnote-1795074 +Ref: Two-way I/O-Footnote-2795260 +Node: TCP/IP Networking795342 +Node: Profiling798214 +Node: Advanced Features Summary805767 +Node: Internationalization807700 +Node: I18N and L10N809180 +Node: Explaining gettext809866 +Ref: Explaining gettext-Footnote-1814895 +Ref: Explaining gettext-Footnote-2815079 +Node: Programmer i18n815244 +Ref: Programmer i18n-Footnote-1820110 +Node: Translator i18n820159 +Node: String Extraction820953 +Ref: String Extraction-Footnote-1822084 +Node: Printf Ordering822170 +Ref: Printf Ordering-Footnote-1824956 +Node: I18N Portability825020 +Ref: I18N Portability-Footnote-1827469 +Node: I18N Example827532 +Ref: I18N Example-Footnote-1830332 +Node: Gawk I18N830404 +Node: I18N Summary831042 +Node: Debugger832381 +Node: Debugging833403 +Node: Debugging Concepts833844 +Node: Debugging Terms835701 +Node: Awk Debugging838276 +Node: Sample Debugging Session839168 +Node: Debugger Invocation839688 +Node: Finding The Bug841072 +Node: List of Debugger Commands847547 +Node: Breakpoint Control848879 +Node: Debugger Execution Control852571 +Node: Viewing And Changing Data855935 +Node: Execution Stack859300 +Node: Debugger Info860938 +Node: Miscellaneous Debugger Commands864955 +Node: Readline Support870147 +Node: Limitations871039 +Node: Debugging Summary873136 +Node: Arbitrary Precision Arithmetic874304 +Node: Computer Arithmetic875720 +Ref: table-numeric-ranges879321 +Ref: Computer Arithmetic-Footnote-1880180 +Node: Math Definitions880237 +Ref: table-ieee-formats883524 +Ref: Math Definitions-Footnote-1884128 +Node: MPFR features884233 +Node: FP Math Caution885904 +Ref: FP Math Caution-Footnote-1886954 +Node: Inexactness of computations887323 +Node: Inexact representation888271 +Node: Comparing FP Values889626 +Node: Errors accumulate890699 +Node: Getting Accuracy892132 +Node: Try To Round894791 +Node: Setting precision895690 +Ref: table-predefined-precision-strings896374 +Node: Setting the rounding mode898168 +Ref: table-gawk-rounding-modes898532 +Ref: Setting the rounding mode-Footnote-1901986 +Node: Arbitrary Precision Integers902165 +Ref: Arbitrary Precision Integers-Footnote-1907069 +Node: POSIX Floating Point Problems907218 +Ref: POSIX Floating Point Problems-Footnote-1911094 +Node: Floating point summary911132 +Node: Dynamic Extensions913324 +Node: Extension Intro914876 +Node: Plugin License916142 +Node: Extension Mechanism Outline916939 +Ref: figure-load-extension917367 +Ref: figure-register-new-function918847 +Ref: figure-call-new-function919851 +Node: Extension API Description921837 +Node: Extension API Functions Introduction923287 +Node: General Data Types928123 +Ref: General Data Types-Footnote-1933810 +Node: Memory Allocation Functions934109 +Ref: Memory Allocation Functions-Footnote-1936939 +Node: Constructor Functions937035 +Node: Registration Functions938769 +Node: Extension Functions939454 +Node: Exit Callback Functions941750 +Node: Extension Version String942998 +Node: Input Parsers943648 +Node: Output Wrappers953463 +Node: Two-way processors957979 +Node: Printing Messages960183 +Ref: Printing Messages-Footnote-1961260 +Node: Updating `ERRNO'961412 +Node: Requesting Values962152 +Ref: table-value-types-returned962880 +Node: Accessing Parameters963838 +Node: Symbol Table Access965069 +Node: Symbol table by name965583 +Node: Symbol table by cookie967563 +Ref: Symbol table by cookie-Footnote-1971702 +Node: Cached values971765 +Ref: Cached values-Footnote-1975269 +Node: Array Manipulation975360 +Ref: Array Manipulation-Footnote-1976458 +Node: Array Data Types976497 +Ref: Array Data Types-Footnote-1979154 +Node: Array Functions979246 +Node: Flattening Arrays983100 +Node: Creating Arrays989987 +Node: Extension API Variables994754 +Node: Extension Versioning995390 +Node: Extension API Informational Variables997291 +Node: Extension API Boilerplate998379 +Node: Finding Extensions1002195 +Node: Extension Example1002755 +Node: Internal File Description1003527 +Node: Internal File Ops1007594 +Ref: Internal File Ops-Footnote-11019252 +Node: Using Internal File Ops1019392 +Ref: Using Internal File Ops-Footnote-11021775 +Node: Extension Samples1022048 +Node: Extension Sample File Functions1023572 +Node: Extension Sample Fnmatch1031174 +Node: Extension Sample Fork1032656 +Node: Extension Sample Inplace1033869 +Node: Extension Sample Ord1035544 +Node: Extension Sample Readdir1036380 +Ref: table-readdir-file-types1037236 +Node: Extension Sample Revout1038047 +Node: Extension Sample Rev2way1038638 +Node: Extension Sample Read write array1039379 +Node: Extension Sample Readfile1041318 +Node: Extension Sample Time1042413 +Node: Extension Sample API Tests1043762 +Node: gawkextlib1044253 +Node: Extension summary1046903 +Node: Extension Exercises1050585 +Node: Language History1051307 +Node: V7/SVR3.11052964 +Node: SVR41055145 +Node: POSIX1056590 +Node: BTL1057979 +Node: POSIX/GNU1058713 +Node: Feature History1064342 +Node: Common Extensions1077433 +Node: Ranges and Locales1078757 +Ref: Ranges and Locales-Footnote-11083396 +Ref: Ranges and Locales-Footnote-21083423 +Ref: Ranges and Locales-Footnote-31083657 +Node: Contributors1083878 +Node: History summary1089418 +Node: Installation1090787 +Node: Gawk Distribution1091743 +Node: Getting1092227 +Node: Extracting1093051 +Node: Distribution contents1094693 +Node: Unix Installation1100463 +Node: Quick Installation1101080 +Node: Additional Configuration Options1103511 +Node: Configuration Philosophy1105251 +Node: Non-Unix Installation1107602 +Node: PC Installation1108060 +Node: PC Binary Installation1109386 +Node: PC Compiling1111234 +Ref: PC Compiling-Footnote-11114255 +Node: PC Testing1114360 +Node: PC Using1115536 +Node: Cygwin1119651 +Node: MSYS1120474 +Node: VMS Installation1120972 +Node: VMS Compilation1121764 +Ref: VMS Compilation-Footnote-11122986 +Node: VMS Dynamic Extensions1123044 +Node: VMS Installation Details1124728 +Node: VMS Running1126980 +Node: VMS GNV1129821 +Node: VMS Old Gawk1130555 +Node: Bugs1131025 +Node: Other Versions1134929 +Node: Installation summary1141142 +Node: Notes1142198 +Node: Compatibility Mode1143063 +Node: Additions1143845 +Node: Accessing The Source1144770 +Node: Adding Code1146206 +Node: New Ports1152378 +Node: Derived Files1156860 +Ref: Derived Files-Footnote-11162335 +Ref: Derived Files-Footnote-21162369 +Ref: Derived Files-Footnote-31162965 +Node: Future Extensions1163079 +Node: Implementation Limitations1163685 +Node: Extension Design1164933 +Node: Old Extension Problems1166087 +Ref: Old Extension Problems-Footnote-11167604 +Node: Extension New Mechanism Goals1167661 +Ref: Extension New Mechanism Goals-Footnote-11171021 +Node: Extension Other Design Decisions1171210 +Node: Extension Future Growth1173318 +Node: Old Extension Mechanism1174154 +Node: Notes summary1175916 +Node: Basic Concepts1177102 +Node: Basic High Level1177783 +Ref: figure-general-flow1178055 +Ref: figure-process-flow1178654 +Ref: Basic High Level-Footnote-11181883 +Node: Basic Data Typing1182068 +Node: Glossary1185396 +Node: Copying1210554 +Node: GNU Free Documentation License1248110 +Node: Index1273246 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 1453b145..eca4b23d 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -4333,30 +4333,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 @@ -4364,7 +4360,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. @@ -4372,7 +4368,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. @@ -4384,19 +4380,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 @@ -4420,6 +4427,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 @@ -4624,9 +4640,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. @@ -4634,7 +4650,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 @@ -37771,8 +37787,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 66e6b0e0..88021c2f 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -4244,30 +4244,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 @@ -4275,7 +4271,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. @@ -4283,7 +4279,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. @@ -4295,19 +4291,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 @@ -4331,6 +4338,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 @@ -4535,9 +4551,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. @@ -4545,7 +4561,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 @@ -36881,8 +36897,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); @@ -1066,18 +1066,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); } @@ -1124,6 +1129,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); |