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
+22
View File
@@ -4770,3 +4770,25 @@ jobs.c
- without_job_control: set original_pgrp == NO_PID since we don't
want to be messing with the terminal pgrp if we call end_job_control.
From a report from ks1322 ks1322 <ks1322@gmail.com>
12/21
-----
include/{posixtime.h,systimes.h,shmbutil.h,shtty.h}
- PARAMS: remove
12/22
-----
builtins/evalfile.c
- _evalfile: add SEVAL_NOOPTIMIZE to the parse_and_execute flags
(maybe overkill, but safer). From a report by
Dan Church <h3xx@gmx.com> and Oguz <oguzismailuysal@gmail.com>
lib/sh/gettimeofday.c
- gettimeofday: added code for _WIN32 version
12/27
-----
doc/{bash.1,bashref.texi},builtins/printf.def
- specify the valid format characters as a subset of what printf(3)
specifies, note that the %n format specifier takes a variable name
as an argument. Suggestion from Emanuele Torre <torreemanuele6@gmail.com>
+1
View File
@@ -1099,6 +1099,7 @@ tests/exec11.sub f
tests/exec12.sub f
tests/exec13.sub f
tests/exec14.sub f
tests/exec15.sub f
tests/exp.tests f
tests/exp.right f
tests/exp1.sub f
+2 -2
View File
@@ -1,6 +1,6 @@
/* evalfile.c - read and evaluate commands from a file or file descriptor */
/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
/* Copyright (C) 1996-2017,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -266,7 +266,7 @@ file_error_and_exit:
#endif
/* set the flags to be passed to parse_and_execute */
pflags = SEVAL_RESETLINE;
pflags = SEVAL_RESETLINE|SEVAL_NOOPTIMIZE;
pflags |= (flags & FEVAL_HISTORY) ? 0 : SEVAL_NOHIST;
if (flags & FEVAL_BUILTIN)
+2 -2
View File
@@ -35,8 +35,8 @@ 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 format specifications described in printf(1),
printf interprets:
In addition to the standard format characters csndiouxXeEfFgGaA described
in printf(3), printf interprets:
%b expand backslash escape sequences in the corresponding argument
%q quote the argument in a way that can be reused as shell input
+416 -408
View File
File diff suppressed because it is too large Load Diff
+12 -6
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Mon Dec 19 13:56:57 EST 2022
.\" Last Change: Tue Dec 27 16:11:59 EST 2022
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2022 December 19" "GNU Bash 5.2"
.TH BASH 1 "2022 December 27" "GNU Bash 5.2"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -3215,7 +3215,7 @@ If \fIparameter\fP is \fB@\fP or \fB*\fP, the result is \fIlength\fP
positional parameters beginning at \fIoffset\fP.
A negative \fIoffset\fP is taken relative to one greater than the greatest
positional parameter, so an offset of \-1 evaluates to the last positional
parameter.
parameter (or 0 if there are no positional parameters).
It is an expansion error if \fIlength\fP evaluates to a number less than
zero.
.sp 1
@@ -9445,8 +9445,9 @@ plain characters, which are simply copied to 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
\fIargument\fP.
In addition to the standard \fIprintf\fP(1) format specifications,
\fBprintf\fP interprets the following extensions:
In addition to the standard \fIprintf\fP(3) format characters
.BR csndiouxXeEfFgGaA ,
\fBprintf\fP interprets the following additional format specifiers:
.RS
.PD 0
.TP
@@ -9480,6 +9481,9 @@ arguments from the format specification and write that many bytes from
(or use that wide a field for) the expanded argument, which usually
contains more characters than the original.
.PP
The %n format specifier accepts a corresponding argument that is treated
as a shell variable name.
.PP
Arguments to non-string format specifiers are treated as C 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 the ASCII value of
@@ -9489,7 +9493,9 @@ The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP.
If the \fIformat\fP requires more \fIarguments\fP 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.
The return value is zero on success,
non-zero if an invalid option is supplied or a write or assignment error
occurs.
.RE
.TP
\fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
+217 -195
View File
@@ -1,9 +1,9 @@
This is bash.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.
@@ -26,10 +26,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
@@ -1955,8 +1955,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:
@@ -4102,8 +4103,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
@@ -4130,6 +4131,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
@@ -4139,7 +4143,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]
@@ -4259,24 +4264,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.
@@ -7129,12 +7140,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,
@@ -7142,141 +7158,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:
@@ -11853,8 +11875,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.
@@ -11863,7 +11885,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.
@@ -11872,12 +11894,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.
@@ -12543,138 +12565,138 @@ D.5 Concept Index

Tag Table:
Node: Top892
Node: Introduction2807
Node: What is Bash?3020
Node: What is a shell?4131
Node: Definitions6666
Node: Basic Shell Features9614
Node: Shell Syntax10830
Node: Shell Operation11853
Node: Quoting13143
Node: Escape Character14444
Node: Single Quotes14926
Node: Double Quotes15271
Node: ANSI-C Quoting16546
Node: Locale Translation17853
Node: Creating Internationalized Scripts19161
Node: Comments23275
Node: Shell Commands23890
Node: Reserved Words24825
Node: Simple Commands25578
Node: Pipelines26229
Node: Lists29225
Node: Compound Commands31017
Node: Looping Constructs32026
Node: Conditional Constructs34518
Node: Command Grouping49003
Node: Coprocesses50478
Node: GNU Parallel53138
Node: Shell Functions54052
Node: Shell Parameters61934
Node: Positional Parameters66319
Node: Special Parameters67218
Node: Shell Expansions70429
Node: Brace Expansion72553
Node: Tilde Expansion75284
Node: Shell Parameter Expansion77902
Node: Command Substitution96251
Node: Arithmetic Expansion97603
Node: Process Substitution98568
Node: Word Splitting99685
Node: Filename Expansion101626
Node: Pattern Matching104372
Node: Quote Removal109371
Node: Redirections109663
Node: Executing Commands119320
Node: Simple Command Expansion119987
Node: Command Search and Execution122094
Node: Command Execution Environment124469
Node: Environment127501
Node: Exit Status129161
Node: Signals130942
Node: Shell Scripts134388
Node: Shell Builtin Commands137412
Node: Bourne Shell Builtins139447
Node: Bash Builtins161229
Node: Modifying Shell Behavior192082
Node: The Set Builtin192424
Node: The Shopt Builtin203022
Node: Special Builtins218931
Node: Shell Variables219907
Node: Bourne Shell Variables220341
Node: Bash Variables222442
Node: Bash Features255254
Node: Invoking Bash256264
Node: Bash Startup Files262274
Node: Interactive Shells267402
Node: What is an Interactive Shell?267810
Node: Is this Shell Interactive?268456
Node: Interactive Shell Behavior269268
Node: Bash Conditional Expressions272894
Node: Shell Arithmetic277533
Node: Aliases280474
Node: Arrays283084
Node: The Directory Stack289472
Node: Directory Stack Builtins290253
Node: Controlling the Prompt294510
Node: The Restricted Shell297472
Node: Bash POSIX Mode300079
Node: Shell Compatibility Mode312043
Node: Job Control320607
Node: Job Control Basics321064
Node: Job Control Builtins326063
Node: Job Control Variables331855
Node: Command Line Editing333008
Node: Introduction and Notation334676
Node: Readline Interaction336296
Node: Readline Bare Essentials337484
Node: Readline Movement Commands339270
Node: Readline Killing Commands340227
Node: Readline Arguments342145
Node: Searching343186
Node: Readline Init File345369
Node: Readline Init File Syntax346627
Node: Conditional Init Constructs370210
Node: Sample Init File374403
Node: Bindable Readline Commands377524
Node: Commands For Moving378725
Node: Commands For History380773
Node: Commands For Text385764
Node: Commands For Killing389410
Node: Numeric Arguments392440
Node: Commands For Completion393576
Node: Keyboard Macros397764
Node: Miscellaneous Commands398449
Node: Readline vi Mode404391
Node: Programmable Completion405295
Node: Programmable Completion Builtins413072
Node: A Programmable Completion Example423821
Node: Using History Interactively429066
Node: Bash History Facilities429747
Node: Bash History Builtins432749
Node: History Interaction437770
Node: Event Designators441387
Node: Word Designators442738
Node: Modifiers444495
Node: Installing Bash446300
Node: Basic Installation447434
Node: Compilers and Options451153
Node: Compiling For Multiple Architectures451891
Node: Installation Names453580
Node: Specifying the System Type455686
Node: Sharing Defaults456400
Node: Operation Controls457070
Node: Optional Features458025
Node: Reporting Bugs469241
Node: Major Differences From The Bourne Shell470582
Node: GNU Free Documentation License487428
Node: Indexes512602
Node: Builtin Index513053
Node: Reserved Word Index519877
Node: Variable Index522322
Node: Function Index539093
Node: Concept Index552874
Node: Top894
Node: Introduction2811
Node: What is Bash?3024
Node: What is a shell?4135
Node: Definitions6670
Node: Basic Shell Features9618
Node: Shell Syntax10834
Node: Shell Operation11857
Node: Quoting13147
Node: Escape Character14448
Node: Single Quotes14930
Node: Double Quotes15275
Node: ANSI-C Quoting16550
Node: Locale Translation17857
Node: Creating Internationalized Scripts19165
Node: Comments23279
Node: Shell Commands23894
Node: Reserved Words24829
Node: Simple Commands25582
Node: Pipelines26233
Node: Lists29229
Node: Compound Commands31021
Node: Looping Constructs32030
Node: Conditional Constructs34522
Node: Command Grouping49007
Node: Coprocesses50482
Node: GNU Parallel53142
Node: Shell Functions54056
Node: Shell Parameters61938
Node: Positional Parameters66323
Node: Special Parameters67222
Node: Shell Expansions70433
Node: Brace Expansion72557
Node: Tilde Expansion75288
Node: Shell Parameter Expansion77906
Node: Command Substitution96305
Node: Arithmetic Expansion97657
Node: Process Substitution98622
Node: Word Splitting99739
Node: Filename Expansion101680
Node: Pattern Matching104426
Node: Quote Removal109425
Node: Redirections109717
Node: Executing Commands119374
Node: Simple Command Expansion120041
Node: Command Search and Execution122148
Node: Command Execution Environment124523
Node: Environment127555
Node: Exit Status129215
Node: Signals130996
Node: Shell Scripts134442
Node: Shell Builtin Commands137466
Node: Bourne Shell Builtins139501
Node: Bash Builtins161283
Node: Modifying Shell Behavior192671
Node: The Set Builtin193013
Node: The Shopt Builtin203611
Node: Special Builtins219520
Node: Shell Variables220496
Node: Bourne Shell Variables220930
Node: Bash Variables223031
Node: Bash Features255843
Node: Invoking Bash256853
Node: Bash Startup Files262863
Node: Interactive Shells267991
Node: What is an Interactive Shell?268399
Node: Is this Shell Interactive?269045
Node: Interactive Shell Behavior269857
Node: Bash Conditional Expressions273483
Node: Shell Arithmetic278122
Node: Aliases281063
Node: Arrays283673
Node: The Directory Stack290061
Node: Directory Stack Builtins290842
Node: Controlling the Prompt295099
Node: The Restricted Shell298061
Node: Bash POSIX Mode300668
Node: Shell Compatibility Mode313227
Node: Job Control321791
Node: Job Control Basics322248
Node: Job Control Builtins327247
Node: Job Control Variables333039
Node: Command Line Editing334192
Node: Introduction and Notation335860
Node: Readline Interaction337480
Node: Readline Bare Essentials338668
Node: Readline Movement Commands340454
Node: Readline Killing Commands341411
Node: Readline Arguments343329
Node: Searching344370
Node: Readline Init File346553
Node: Readline Init File Syntax347811
Node: Conditional Init Constructs371394
Node: Sample Init File375587
Node: Bindable Readline Commands378708
Node: Commands For Moving379909
Node: Commands For History381957
Node: Commands For Text386948
Node: Commands For Killing390594
Node: Numeric Arguments393624
Node: Commands For Completion394760
Node: Keyboard Macros398948
Node: Miscellaneous Commands399633
Node: Readline vi Mode405575
Node: Programmable Completion406479
Node: Programmable Completion Builtins414256
Node: A Programmable Completion Example425005
Node: Using History Interactively430250
Node: Bash History Facilities430931
Node: Bash History Builtins433933
Node: History Interaction438954
Node: Event Designators442571
Node: Word Designators443922
Node: Modifiers445679
Node: Installing Bash447484
Node: Basic Installation448618
Node: Compilers and Options452337
Node: Compiling For Multiple Architectures453075
Node: Installation Names454764
Node: Specifying the System Type456870
Node: Sharing Defaults457584
Node: Operation Controls458254
Node: Optional Features459209
Node: Reporting Bugs470425
Node: Major Differences From The Bourne Shell471766
Node: GNU Free Documentation License488612
Node: Indexes513786
Node: Builtin Index514237
Node: Reserved Word Index521061
Node: Variable Index523506
Node: Function Index540277
Node: Concept Index554058

End Tag Table
BIN
View File
Binary file not shown.
+1376 -1358
View File
File diff suppressed because it is too large Load Diff
+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
+11 -5
View File
@@ -2309,7 +2309,7 @@ If @var{parameter} is @samp{@@} or @samp{*}, the result is @var{length}
positional parameters beginning at @var{offset}.
A negative @var{offset} is taken relative to one greater than the greatest
positional parameter, so an offset of -1 evaluates to the last positional
parameter.
parameter (or 0 if there are no positional parameters).
It is an expansion error if @var{length} evaluates to a number less than zero.
The following examples illustrate substring expansion using positional
@@ -4866,8 +4866,9 @@ plain characters, which are simply copied to 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
@var{argument}.
In addition to the standard @code{printf(1)} formats, @code{printf}
interprets the following extensions:
In addition to the standard @code{printf(3)} format characters
@code{csndiouxXeEfFgGaA},
@code{printf} interprets the following additional format specifiers:
@table @code
@item %b
@@ -4897,6 +4898,9 @@ arguments from the format specification and write that many bytes 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 the ASCII value of
@@ -4905,8 +4909,10 @@ the following character.
The @var{format} is reused as necessary to consume all of the @var{arguments}.
If the @var{format} requires more @var{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.
appropriate, had been supplied.
The return value is zero on success,
non-zero if an invalid option is supplied or a write or assignment error
occurs.
@item read
@btindex read
+2 -2
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2022 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Mon Dec 19 13:56:45 EST 2022
@set LASTCHANGE Tue Dec 27 16:12:26 EST 2022
@set EDITION 5.2
@set VERSION 5.2
@set UPDATED 19 December 2022
@set UPDATED 27 December 2022
@set UPDATED-MONTH December 2022
+2 -2
View File
@@ -1,6 +1,6 @@
/* posixtime.h -- wrapper for time.h, sys/times.h mess. */
/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
/* Copyright (C) 1999-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -49,7 +49,7 @@ struct timeval
#endif
#if !HAVE_GETTIMEOFDAY
extern int gettimeofday PARAMS((struct timeval * restrict, void * restrict));
extern int gettimeofday (struct timeval * restrict, void * restrict);
#endif
/* These exist on BSD systems, at least. */
+5 -5
View File
@@ -29,13 +29,13 @@
#if defined (HANDLE_MULTIBYTE)
#include "shmbchar.h"
extern size_t xwcsrtombs PARAMS((char *, const wchar_t **, size_t, mbstate_t *));
extern size_t xmbsrtowcs PARAMS((wchar_t *, const char **, size_t, mbstate_t *));
extern size_t xdupmbstowcs PARAMS((wchar_t **, char ***, const char *));
extern size_t xwcsrtombs (char *, const wchar_t **, size_t, mbstate_t *);
extern size_t xmbsrtowcs (wchar_t *, const char **, size_t, mbstate_t *);
extern size_t xdupmbstowcs (wchar_t **, char ***, const char *);
extern size_t mbstrlen PARAMS((const char *));
extern size_t mbstrlen (const char *);
extern char *xstrchr PARAMS((const char *, int));
extern char *xstrchr (const char *, int);
extern int locale_mb_cur_max; /* XXX */
extern int locale_utf8locale; /* XXX */
+21 -21
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 1999-2020 Free Software Foundation, Inc. */
/* Copyright (C) 1999-2020,2022 Free Software Foundation, Inc. */
/* This file is part of GNU Bash, the Bourne Again SHell.
@@ -67,24 +67,24 @@
/* Get and set terminal attributes for the file descriptor passed as
an argument. */
extern int ttgetattr PARAMS((int, TTYSTRUCT *));
extern int ttsetattr PARAMS((int, TTYSTRUCT *));
extern int ttgetattr (int, TTYSTRUCT *);
extern int ttsetattr (int, TTYSTRUCT *);
/* Save and restore the terminal's attributes from static storage. */
extern void ttsave PARAMS((void));
extern void ttrestore PARAMS((void));
extern void ttsave (void);
extern void ttrestore (void);
/* Return the attributes corresponding to the file descriptor (0 or 1)
passed as an argument. */
extern TTYSTRUCT *ttattr PARAMS((int));
extern TTYSTRUCT *ttattr (int);
/* These functions only operate on the passed TTYSTRUCT; they don't
actually change anything with the kernel's current tty settings. */
extern int tt_setonechar PARAMS((TTYSTRUCT *));
extern int tt_setnoecho PARAMS((TTYSTRUCT *));
extern int tt_seteightbit PARAMS((TTYSTRUCT *));
extern int tt_setnocanon PARAMS((TTYSTRUCT *));
extern int tt_setcbreak PARAMS((TTYSTRUCT *));
extern int tt_setonechar (TTYSTRUCT *);
extern int tt_setnoecho (TTYSTRUCT *);
extern int tt_seteightbit (TTYSTRUCT *);
extern int tt_setnocanon (TTYSTRUCT *);
extern int tt_setcbreak (TTYSTRUCT *);
/* These functions are all generally mutually exclusive. If you call
more than one (bracketed with calls to ttsave and ttrestore, of
@@ -94,19 +94,19 @@ extern int tt_setcbreak PARAMS((TTYSTRUCT *));
/* These functions work with a given file descriptor and set terminal
attributes */
extern int ttfd_onechar PARAMS((int, TTYSTRUCT *));
extern int ttfd_noecho PARAMS((int, TTYSTRUCT *));
extern int ttfd_eightbit PARAMS((int, TTYSTRUCT *));
extern int ttfd_nocanon PARAMS((int, TTYSTRUCT *));
extern int ttfd_onechar (int, TTYSTRUCT *);
extern int ttfd_noecho (int, TTYSTRUCT *);
extern int ttfd_eightbit (int, TTYSTRUCT *);
extern int ttfd_nocanon (int, TTYSTRUCT *);
extern int ttfd_cbreak PARAMS((int, TTYSTRUCT *));
extern int ttfd_cbreak (int, TTYSTRUCT *);
/* These functions work with fd 0 and the TTYSTRUCT saved with ttsave () */
extern int ttonechar PARAMS((void));
extern int ttnoecho PARAMS((void));
extern int tteightbit PARAMS((void));
extern int ttnocanon PARAMS((void));
extern int ttonechar (void);
extern int ttnoecho (void);
extern int tteightbit (void);
extern int ttnocanon (void);
extern int ttcbreak PARAMS((void));
extern int ttcbreak (void);
#endif
+2 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
/* Copyright (C) 1991-2020,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -49,7 +49,7 @@ struct tms
Return the elapsed real time from an arbitrary point in the
past (the bash emulation uses the epoch), or (clock_t) -1 for
errors. All times are in CLK_TCKths of a second. */
extern clock_t times PARAMS((struct tms *buffer));
extern clock_t times (struct tms *buffer);
#endif /* !HAVE_SYS_TIMES_H */
#endif /* _BASH_SYSTIMES_H */
+1 -1
View File
@@ -150,7 +150,7 @@ int rl_set_timeout (unsigned int, unsigned int);
int rl_timeout_remaining (unsigned int *, unsigned int *);
int _rl_timeout_init (void);
int _rl_timeout_sigalrm_handler (void);
int _rl_timeout_handle_sigalrm (void);
#if defined (RL_TIMEOUT_USE_SELECT)
int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *);
#endif
+1 -1
View File
@@ -40,7 +40,7 @@
# if defined (HAVE_TERMIO_H)
# define TERMIO_TTY_DRIVER
# else
# if !defined (__MINGW32__) && !defined (_WIN32)
# if !defined (__MINGW32__) && !defined (_MSC_VER)
# define NEW_TTY_DRIVER
# else
# define NO_TTY_DRIVER
+3 -3
View File
@@ -69,7 +69,7 @@
#include "rlshell.h"
#include "xmalloc.h"
#if defined (__MINGW32__)
#if defined (_WIN32)
# include <windows.h>
# include <wincon.h>
@@ -229,7 +229,7 @@ _emx_get_screensize (int *swp, int *shp)
}
#endif
#if defined (__MINGW32__)
#if defined (_WIN32)
static void
_win_get_screensize (int *swp, int *shp)
{
@@ -272,7 +272,7 @@ _rl_get_screen_size (int tty, int ignore_env)
#if defined (__EMX__)
_emx_get_screensize (&wc, &wr);
#elif defined (__MINGW32__)
#elif defined (_WIN32) && !defined (__CYGWIN__)
_win_get_screensize (&wc, &wr);
#endif
+25 -1
View File
@@ -23,13 +23,37 @@
#if !defined (HAVE_GETTIMEOFDAY)
#include "posixtime.h"
#if HAVE_STDINT_H
#include <stdint.h>
#endif
/* A version of gettimeofday that just sets tv_sec from time(3) */
/* A version of gettimeofday that just sets tv_sec from time(3) on Unix-like
systems that don't have it, or a version for Win32 systems. */
int
gettimeofday (struct timeval *restrict tv, void *restrict tz)
{
#if !defined (_WIN32)
tv->tv_sec = (time_t) time ((time_t *)0);
tv->tv_usec = 0;
#else
/* EPOCH is the number of 100 nanosecond intervals from
January 1, 1601 (UTC) to January 1, 1970.
(the correct value has 9 trailing zeros) */
static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
SYSTEMTIME system_time;
FILETIME file_time;
uint64_t time;
GetSystemTime(&system_time);
SystemTimeToFileTime(&system_time, &file_time);
time = ((uint64_t)file_time.dwLowDateTime);
time += ((uint64_t)file_time.dwHighDateTime) << 32;
tp->tv_sec = (long) ((time - EPOCH) / 10000000L);
tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
#endif
return 0;
}
#endif
+30
View File
@@ -170,3 +170,33 @@ w
x
y
z
Darwin
x
archive
install
s
sub1
sub2
test
68
archive
install
s
sub1
sub2
test
44
archive
install
s
sub1
sub2
test
86
2
78
1 start
2 start
sub3
1 done
42
+72
View File
@@ -0,0 +1,72 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# problems with fork optimization in subshells in bash-5.2
: ${TMPDIR:=/tmp}
TDIR=$TMPDIR/delta-$$
mkdir "$TDIR" || exit 2
CMD='env true && env ls -1 "$TDIR"'
trap 'rm -rf "$TDIR"' EXIT
cd "$TDIR" &&
{
touch archive install test;
echo "$CMD" > s
echo '( echo "1 start" ; . "$TDIR/sub2" ; echo "1 done" ; exit 42 )' >sub1
echo 'echo "2 start" && env echo sub3' >sub2
} &&
cd "$OLDPWD"
[ -f "$TDIR"/s ] || exit 2
d2()
{
eval "$1" ; return 78
}
d1()
{
cmd="$1"
( env true && env ls -1 "$TDIR";
exit 68 )
echo $?
( . $TDIR/s ; exit 44 )
echo $?
( eval "$cmd" ; exit 86 )
echo $?
return 43
}
dfunc()
{
local x="$CMD"
d1 "$x" || return 2
echo oops: after
}
${THIS_SH} -c '(. <(echo ": && env echo Darwin"); echo x)'
( dfunc xxx )
echo $?
v=$(d2 "$CMD")
echo $?
. $TDIR/sub1
echo $?
exit 0
+3
View File
@@ -158,3 +158,6 @@ $THIS_SH -c '/bin/echo c && /bin/echo d && echo e'
${THIS_SH} ./exec13.sub
${THIS_SH} ./exec14.sub
# problems with fork optimization in bash-5.2
${THIS_SH} ./exec15.sub