fix for optimizing issues in sourced files; change to printf documentation to specify valid format characters

This commit is contained in:
Chet Ramey
2023-01-03 09:38:11 -05:00
parent 001918cdec
commit b648a9ab79
23 changed files with 2443 additions and 2209 deletions
+217 -195
View File
@@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 6.8 from
bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.2, 2 December 2022).
Bash shell (version 5.2, 27 December 2022).
This is Edition 5.2, last updated 2 December 2022, of 'The GNU Bash
This is Edition 5.2, last updated 27 December 2022, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.2.
Copyright (C) 1988-2022 Free Software Foundation, Inc.
@@ -27,10 +27,10 @@ Bash Features
*************
This text is a brief description of the features that are present in the
Bash shell (version 5.2, 2 December 2022). The Bash home page is
Bash shell (version 5.2, 27 December 2022). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.2, last updated 2 December 2022, of 'The GNU Bash
This is Edition 5.2, last updated 27 December 2022, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.2.
Bash contains features that appear in other popular shells, and some
@@ -1956,8 +1956,9 @@ omitted, the operator tests only for existence.
If PARAMETER is '@' or '*', the result is LENGTH positional
parameters beginning at OFFSET. A negative OFFSET is taken
relative to one greater than the greatest positional parameter, so
an offset of -1 evaluates to the last positional parameter. It is
an expansion error if LENGTH evaluates to a number less than zero.
an offset of -1 evaluates to the last positional parameter (or 0 if
there are no positional parameters). It is an expansion error if
LENGTH evaluates to a number less than zero.
The following examples illustrate substring expansion using
positional parameters:
@@ -4103,8 +4104,8 @@ standard.
output, character escape sequences, which are converted and copied
to the standard output, and format specifications, each of which
causes printing of the next successive ARGUMENT. In addition to
the standard 'printf(1)' formats, 'printf' interprets the following
extensions:
the standard 'printf(3)' format characters 'csndiouxXeEfFgGaA',
'printf' interprets the following additional format specifiers:
'%b'
Causes 'printf' to expand backslash escape sequences in the
@@ -4131,6 +4132,9 @@ standard.
from (or use that wide a field for) the expanded argument, which
usually contains more characters than the original.
The %n format specifier accepts a corresponding argument that is
treated as a shell variable name.
Arguments to non-string format specifiers are treated as C language
constants, except that a leading plus or minus sign is allowed, and
if the leading character is a single or double quote, the value is
@@ -4140,7 +4144,8 @@ standard.
If the FORMAT requires more ARGUMENTS than are supplied, the extra
format specifications behave as if a zero value or null string, as
appropriate, had been supplied. The return value is zero on
success, non-zero on failure.
success, non-zero if an invalid option is supplied or a write or
assignment error occurs.
'read'
read [-ers] [-a ANAME] [-d DELIM] [-i TEXT] [-n NCHARS]
@@ -4260,24 +4265,30 @@ standard.
command name.
If the '-t' option is used, 'type' prints a single word which is
one of 'alias', 'function', 'builtin', 'file' or 'keyword', if NAME
is an alias, shell function, shell builtin, disk file, or shell
reserved word, respectively. If the NAME is not found, then
nothing is printed, and 'type' returns a failure status.
one of 'alias', 'keyword', 'function', 'builtin', or 'file', if
NAME is an alias, shell reserved word, shell function, shell
builtin, or executable disk file, respectively. If the NAME is not
found, then nothing is printed, and 'type' returns a failure
status.
If the '-p' option is used, 'type' either returns the name of the
disk file that would be executed, or nothing if '-t' would not
return 'file'.
executable file that would be found by searching '$PATH', or
nothing if '-t' would not return 'file'.
The '-P' option forces a path search for each NAME, even if '-t'
would not return 'file'.
If a command is hashed, '-p' and '-P' print the hashed value, which
is not necessarily the file that appears first in '$PATH'.
If a NAME is present in the table of hashed commands, options '-p'
and '-P' print the hashed value, which is not necessarily the file
that appears first in '$PATH'.
If the '-a' option is used, 'type' returns all of the places that
contain an executable named FILE. This includes aliases and
functions, if and only if the '-p' option is not also used.
contain a command named NAME. This includes aliases, reserved
words, functions, and builtins, but the path search options ('-p'
and '-P') can be supplied to restrict the output to executable
files. If '-a' is supplied with '-p', 'type' does not look in the
table of hashed commands, and only performs a 'PATH' search for
NAME.
If the '-f' option is used, 'type' does not attempt to find shell
functions, as with the 'command' builtin.
@@ -7130,12 +7141,17 @@ startup files.
options, redirection errors, variable assignment errors for
assignments preceding the command name, and so on.
25. A non-interactive shell exits with an error status if a variable
25. The 'unset' builtin with the '-v' option specified returns a fatal
error if it attempts to unset a 'readonly' or 'non-unsettable'
variable, or encounters a variable name argument that is an invalid
identifier, which causes a non-interactive shell to exit.
26. A non-interactive shell exits with an error status if a variable
assignment error occurs when no command name follows the assignment
statements. A variable assignment error occurs, for example, when
trying to assign a value to a readonly variable.
26. A non-interactive shell exits with an error status if a variable
27. A non-interactive shell exits with an error status if a variable
assignment error occurs in an assignment statement preceding a
special builtin, but not with any other simple command. For any
other simple command, the shell aborts execution of that command,
@@ -7143,141 +7159,147 @@ startup files.
perform any further processing of the command in which the error
occurred").
27. A non-interactive shell exits with an error status if the
28. A non-interactive shell exits with an error status if the
iteration variable in a 'for' statement or the selection variable
in a 'select' statement is a readonly variable.
28. Non-interactive shells exit if FILENAME in '.' FILENAME is not
29. Non-interactive shells exit if FILENAME in '.' FILENAME is not
found.
29. Non-interactive shells exit if a syntax error in an arithmetic
30. Non-interactive shells exit if a syntax error in an arithmetic
expansion results in an invalid expression.
30. Non-interactive shells exit if a parameter expansion error occurs.
31. Non-interactive shells exit if a parameter expansion error occurs.
31. Non-interactive shells exit if there is a syntax error in a script
32. Non-interactive shells exit if there is a syntax error in a script
read with the '.' or 'source' builtins, or in a string processed by
the 'eval' builtin.
32. While variable indirection is available, it may not be applied to
33. While variable indirection is available, it may not be applied to
the '#' and '?' special parameters.
33. Expanding the '*' special parameter in a pattern context where the
34. Expanding the '*' special parameter in a pattern context where the
expansion is double-quoted does not treat the '$*' as if it were
double-quoted.
34. Assignment statements preceding POSIX special builtins persist in
35. Assignment statements preceding POSIX special builtins persist in
the shell environment after the builtin completes.
35. The 'command' builtin does not prevent builtins that take
36. The 'command' builtin does not prevent builtins that take
assignment statements as arguments from expanding them as
assignment statements; when not in POSIX mode, assignment builtins
lose their assignment statement expansion properties when preceded
by 'command'.
36. The 'bg' builtin uses the required format to describe each job
37. The 'bg' builtin uses the required format to describe each job
placed in the background, which does not include an indication of
whether the job is the current or previous job.
37. The output of 'kill -l' prints all the signal names on a single
38. The output of 'kill -l' prints all the signal names on a single
line, separated by spaces, without the 'SIG' prefix.
38. The 'kill' builtin does not accept signal names with a 'SIG'
39. The 'kill' builtin does not accept signal names with a 'SIG'
prefix.
39. The 'export' and 'readonly' builtin commands display their output
40. The 'export' and 'readonly' builtin commands display their output
in the format required by POSIX.
40. The 'trap' builtin displays signal names without the leading
41. The 'trap' builtin displays signal names without the leading
'SIG'.
41. The 'trap' builtin doesn't check the first argument for a possible
42. The 'trap' builtin doesn't check the first argument for a possible
signal specification and revert the signal handling to the original
disposition if it is, unless that argument consists solely of
digits and is a valid signal number. If users want to reset the
handler for a given signal to the original disposition, they should
use '-' as the first argument.
42. 'trap -p' without arguments displays signals whose dispositions
43. 'trap -p' without arguments displays signals whose dispositions
are set to SIG_DFL and those that were ignored when the shell
started, not just trapped signals.
43. The '.' and 'source' builtins do not search the current directory
44. The '.' and 'source' builtins do not search the current directory
for the filename argument if it is not found by searching 'PATH'.
44. Enabling POSIX mode has the effect of setting the
45. Enabling POSIX mode has the effect of setting the
'inherit_errexit' option, so subshells spawned to execute command
substitutions inherit the value of the '-e' option from the parent
shell. When the 'inherit_errexit' option is not enabled, Bash
clears the '-e' option in such subshells.
45. Enabling POSIX mode has the effect of setting the 'shift_verbose'
46. Enabling POSIX mode has the effect of setting the 'shift_verbose'
option, so numeric arguments to 'shift' that exceed the number of
positional parameters will result in an error message.
46. When the 'alias' builtin displays alias definitions, it does not
47. When the 'alias' builtin displays alias definitions, it does not
display them with a leading 'alias ' unless the '-p' option is
supplied.
47. When the 'set' builtin is invoked without options, it does not
48. When the 'set' builtin is invoked without options, it does not
display shell function names and definitions.
48. When the 'set' builtin is invoked without options, it displays
49. When the 'set' builtin is invoked without options, it displays
variable values without quotes, unless they contain shell
metacharacters, even if the result contains nonprinting characters.
49. When the 'cd' builtin is invoked in logical mode, and the pathname
50. When the 'cd' builtin is invoked in logical mode, and the pathname
constructed from '$PWD' and the directory name supplied as an
argument does not refer to an existing directory, 'cd' will fail
instead of falling back to physical mode.
50. When the 'cd' builtin cannot change a directory because the length
51. When the 'cd' builtin cannot change a directory because the length
of the pathname constructed from '$PWD' and the directory name
supplied as an argument exceeds 'PATH_MAX' when all symbolic links
are expanded, 'cd' will fail instead of attempting to use only the
supplied directory name.
51. The 'pwd' builtin verifies that the value it prints is the same as
52. The 'pwd' builtin verifies that the value it prints is the same as
the current directory, even if it is not asked to check the file
system with the '-P' option.
52. When listing the history, the 'fc' builtin does not include an
53. When listing the history, the 'fc' builtin does not include an
indication of whether or not a history entry has been modified.
53. The default editor used by 'fc' is 'ed'.
54. The default editor used by 'fc' is 'ed'.
54. The 'type' and 'command' builtins will not report a non-executable
55. The 'type' and 'command' builtins will not report a non-executable
file as having been found, though the shell will attempt to execute
such a file if it is the only so-named file found in '$PATH'.
55. The 'vi' editing mode will invoke the 'vi' editor directly when
56. The 'vi' editing mode will invoke the 'vi' editor directly when
the 'v' command is run, instead of checking '$VISUAL' and
'$EDITOR'.
56. When the 'xpg_echo' option is enabled, Bash does not attempt to
57. When the 'xpg_echo' option is enabled, Bash does not attempt to
interpret any arguments to 'echo' as options. Each argument is
displayed, after escape characters are converted.
57. The 'ulimit' builtin uses a block size of 512 bytes for the '-c'
58. The 'ulimit' builtin uses a block size of 512 bytes for the '-c'
and '-f' options.
58. The arrival of 'SIGCHLD' when a trap is set on 'SIGCHLD' does not
59. The arrival of 'SIGCHLD' when a trap is set on 'SIGCHLD' does not
interrupt the 'wait' builtin and cause it to return immediately.
The trap command is run once for each child that exits.
59. The 'read' builtin may be interrupted by a signal for which a trap
60. The 'read' builtin may be interrupted by a signal for which a trap
has been set. If Bash receives a trapped signal while executing
'read', the trap handler executes and 'read' returns an exit status
greater than 128.
60. The 'printf' builtin uses 'double' (via 'strtod') to convert
61. The 'printf' builtin uses 'double' (via 'strtod') to convert
arguments corresponding to floating point conversion specifiers,
instead of 'long double' if it's available. The 'L' length
modifier forces 'printf' to use 'long double' if it's available.
61. Bash removes an exited background process's status from the list
62. Bash removes an exited background process's status from the list
of such statuses after the 'wait' builtin is used to obtain it.
63. A double quote character ('"') is treated specially when it
appears in a backquoted command substitution in the body of a
here-document that undergoes expansion. That means, for example,
that a backslash preceding a double quote character will escape it
and the backslash will be removed.
There is other POSIX behavior that Bash does not implement by default
even when in POSIX mode. Specifically:
@@ -11854,8 +11876,8 @@ D.1 Index of Shell Builtin Commands
(line 69)
* pwd: Bourne Shell Builtins.
(line 212)
* read: Bash Builtins. (line 488)
* readarray: Bash Builtins. (line 585)
* read: Bash Builtins. (line 492)
* readarray: Bash Builtins. (line 589)
* readonly: Bourne Shell Builtins.
(line 222)
* return: Bourne Shell Builtins.
@@ -11864,7 +11886,7 @@ D.1 Index of Shell Builtin Commands
* shift: Bourne Shell Builtins.
(line 262)
* shopt: The Shopt Builtin. (line 9)
* source: Bash Builtins. (line 594)
* source: Bash Builtins. (line 598)
* suspend: Job Control Builtins.
(line 116)
* test: Bourne Shell Builtins.
@@ -11873,12 +11895,12 @@ D.1 Index of Shell Builtin Commands
(line 360)
* trap: Bourne Shell Builtins.
(line 366)
* type: Bash Builtins. (line 599)
* typeset: Bash Builtins. (line 631)
* ulimit: Bash Builtins. (line 637)
* type: Bash Builtins. (line 603)
* typeset: Bash Builtins. (line 641)
* ulimit: Bash Builtins. (line 647)
* umask: Bourne Shell Builtins.
(line 422)
* unalias: Bash Builtins. (line 743)
* unalias: Bash Builtins. (line 753)
* unset: Bourne Shell Builtins.
(line 440)
* wait: Job Control Builtins.
@@ -12544,138 +12566,138 @@ D.5 Concept Index

Tag Table:
Node: Top895
Node: Introduction2813
Node: What is Bash?3029
Node: What is a shell?4143
Node: Definitions6681
Node: Basic Shell Features9632
Node: Shell Syntax10851
Node: Shell Operation11877
Node: Quoting13170
Node: Escape Character14474
Node: Single Quotes14959
Node: Double Quotes15307
Node: ANSI-C Quoting16585
Node: Locale Translation17895
Node: Creating Internationalized Scripts19206
Node: Comments23323
Node: Shell Commands23941
Node: Reserved Words24879
Node: Simple Commands25635
Node: Pipelines26289
Node: Lists29288
Node: Compound Commands31083
Node: Looping Constructs32095
Node: Conditional Constructs34590
Node: Command Grouping49078
Node: Coprocesses50556
Node: GNU Parallel53219
Node: Shell Functions54136
Node: Shell Parameters62021
Node: Positional Parameters66409
Node: Special Parameters67311
Node: Shell Expansions70525
Node: Brace Expansion72652
Node: Tilde Expansion75386
Node: Shell Parameter Expansion78007
Node: Command Substitution96359
Node: Arithmetic Expansion97714
Node: Process Substitution98682
Node: Word Splitting99802
Node: Filename Expansion101746
Node: Pattern Matching104495
Node: Quote Removal109497
Node: Redirections109792
Node: Executing Commands119452
Node: Simple Command Expansion120122
Node: Command Search and Execution122232
Node: Command Execution Environment124610
Node: Environment127645
Node: Exit Status129308
Node: Signals131092
Node: Shell Scripts134541
Node: Shell Builtin Commands137568
Node: Bourne Shell Builtins139606
Node: Bash Builtins161391
Node: Modifying Shell Behavior192247
Node: The Set Builtin192592
Node: The Shopt Builtin203193
Node: Special Builtins219105
Node: Shell Variables220084
Node: Bourne Shell Variables220521
Node: Bash Variables222625
Node: Bash Features255440
Node: Invoking Bash256453
Node: Bash Startup Files262466
Node: Interactive Shells267597
Node: What is an Interactive Shell?268008
Node: Is this Shell Interactive?268657
Node: Interactive Shell Behavior269472
Node: Bash Conditional Expressions273101
Node: Shell Arithmetic277743
Node: Aliases280687
Node: Arrays283300
Node: The Directory Stack289691
Node: Directory Stack Builtins290475
Node: Controlling the Prompt294735
Node: The Restricted Shell297700
Node: Bash POSIX Mode300310
Node: Shell Compatibility Mode312277
Node: Job Control320844
Node: Job Control Basics321304
Node: Job Control Builtins326306
Node: Job Control Variables332101
Node: Command Line Editing333257
Node: Introduction and Notation334928
Node: Readline Interaction336551
Node: Readline Bare Essentials337742
Node: Readline Movement Commands339531
Node: Readline Killing Commands340491
Node: Readline Arguments342412
Node: Searching343456
Node: Readline Init File345642
Node: Readline Init File Syntax346903
Node: Conditional Init Constructs370489
Node: Sample Init File374685
Node: Bindable Readline Commands377809
Node: Commands For Moving379013
Node: Commands For History381064
Node: Commands For Text386058
Node: Commands For Killing389707
Node: Numeric Arguments392740
Node: Commands For Completion393879
Node: Keyboard Macros398070
Node: Miscellaneous Commands398758
Node: Readline vi Mode404703
Node: Programmable Completion405610
Node: Programmable Completion Builtins413390
Node: A Programmable Completion Example424142
Node: Using History Interactively429390
Node: Bash History Facilities430074
Node: Bash History Builtins433079
Node: History Interaction438103
Node: Event Designators441723
Node: Word Designators443077
Node: Modifiers444837
Node: Installing Bash446645
Node: Basic Installation447782
Node: Compilers and Options451504
Node: Compiling For Multiple Architectures452245
Node: Installation Names453937
Node: Specifying the System Type456046
Node: Sharing Defaults456763
Node: Operation Controls457436
Node: Optional Features458394
Node: Reporting Bugs469613
Node: Major Differences From The Bourne Shell470957
Node: GNU Free Documentation License487806
Node: Indexes512983
Node: Builtin Index513437
Node: Reserved Word Index520264
Node: Variable Index522712
Node: Function Index539486
Node: Concept Index553270
Node: Top897
Node: Introduction2817
Node: What is Bash?3033
Node: What is a shell?4147
Node: Definitions6685
Node: Basic Shell Features9636
Node: Shell Syntax10855
Node: Shell Operation11881
Node: Quoting13174
Node: Escape Character14478
Node: Single Quotes14963
Node: Double Quotes15311
Node: ANSI-C Quoting16589
Node: Locale Translation17899
Node: Creating Internationalized Scripts19210
Node: Comments23327
Node: Shell Commands23945
Node: Reserved Words24883
Node: Simple Commands25639
Node: Pipelines26293
Node: Lists29292
Node: Compound Commands31087
Node: Looping Constructs32099
Node: Conditional Constructs34594
Node: Command Grouping49082
Node: Coprocesses50560
Node: GNU Parallel53223
Node: Shell Functions54140
Node: Shell Parameters62025
Node: Positional Parameters66413
Node: Special Parameters67315
Node: Shell Expansions70529
Node: Brace Expansion72656
Node: Tilde Expansion75390
Node: Shell Parameter Expansion78011
Node: Command Substitution96413
Node: Arithmetic Expansion97768
Node: Process Substitution98736
Node: Word Splitting99856
Node: Filename Expansion101800
Node: Pattern Matching104549
Node: Quote Removal109551
Node: Redirections109846
Node: Executing Commands119506
Node: Simple Command Expansion120176
Node: Command Search and Execution122286
Node: Command Execution Environment124664
Node: Environment127699
Node: Exit Status129362
Node: Signals131146
Node: Shell Scripts134595
Node: Shell Builtin Commands137622
Node: Bourne Shell Builtins139660
Node: Bash Builtins161445
Node: Modifying Shell Behavior192836
Node: The Set Builtin193181
Node: The Shopt Builtin203782
Node: Special Builtins219694
Node: Shell Variables220673
Node: Bourne Shell Variables221110
Node: Bash Variables223214
Node: Bash Features256029
Node: Invoking Bash257042
Node: Bash Startup Files263055
Node: Interactive Shells268186
Node: What is an Interactive Shell?268597
Node: Is this Shell Interactive?269246
Node: Interactive Shell Behavior270061
Node: Bash Conditional Expressions273690
Node: Shell Arithmetic278332
Node: Aliases281276
Node: Arrays283889
Node: The Directory Stack290280
Node: Directory Stack Builtins291064
Node: Controlling the Prompt295324
Node: The Restricted Shell298289
Node: Bash POSIX Mode300899
Node: Shell Compatibility Mode313461
Node: Job Control322028
Node: Job Control Basics322488
Node: Job Control Builtins327490
Node: Job Control Variables333285
Node: Command Line Editing334441
Node: Introduction and Notation336112
Node: Readline Interaction337735
Node: Readline Bare Essentials338926
Node: Readline Movement Commands340715
Node: Readline Killing Commands341675
Node: Readline Arguments343596
Node: Searching344640
Node: Readline Init File346826
Node: Readline Init File Syntax348087
Node: Conditional Init Constructs371673
Node: Sample Init File375869
Node: Bindable Readline Commands378993
Node: Commands For Moving380197
Node: Commands For History382248
Node: Commands For Text387242
Node: Commands For Killing390891
Node: Numeric Arguments393924
Node: Commands For Completion395063
Node: Keyboard Macros399254
Node: Miscellaneous Commands399942
Node: Readline vi Mode405887
Node: Programmable Completion406794
Node: Programmable Completion Builtins414574
Node: A Programmable Completion Example425326
Node: Using History Interactively430574
Node: Bash History Facilities431258
Node: Bash History Builtins434263
Node: History Interaction439287
Node: Event Designators442907
Node: Word Designators444261
Node: Modifiers446021
Node: Installing Bash447829
Node: Basic Installation448966
Node: Compilers and Options452688
Node: Compiling For Multiple Architectures453429
Node: Installation Names455121
Node: Specifying the System Type457230
Node: Sharing Defaults457947
Node: Operation Controls458620
Node: Optional Features459578
Node: Reporting Bugs470797
Node: Major Differences From The Bourne Shell472141
Node: GNU Free Documentation License488990
Node: Indexes514167
Node: Builtin Index514621
Node: Reserved Word Index521448
Node: Variable Index523896
Node: Function Index540670
Node: Concept Index554454

End Tag Table