fixes to read/wait; revert change that processes $'...' quoting in here-documents unconditionally

This commit is contained in:
Chet Ramey
2022-01-24 09:37:14 -05:00
parent 2a1c81bf63
commit 3011048a92
38 changed files with 9824 additions and 6133 deletions
+49
View File
@@ -2942,3 +2942,52 @@ subst.c
result must be passed to strcreplace
- parameter_brace_patsub: call expand_string_for_patsub if
patsub_replacement is set to quote
1/18
----
subst.c
- read_comsub: make istring_index a size_t to avoid overflow with very
large values of istring_size.
From https://savannah.gnu.org/support/index.php?110596
- expand_word_internal: make istring_index a size_t
1/20
----
buitins/cd.def
- add a description of `cd -' to the help text. Suggested by
Rob Landley <rob@landley.net>
1/21
----
lib/glob/glob.c
- glob_vector: if we allocate NEXTLINK using malloc, and free it due to
some allocation failure, reset FIRSTMALLOC to avoid duplicate frees
later on
subst.[ch]
- sub_append_string: the INDX parameter is now a size_t to avoid
overflow
parse.y
- decode_prompt_string: RESULT_INDEX is now a size_t to pass to
sub_append_string
jobs.[ch],nojobs.c
- wait_for_background_pids: now returns the number of jobs/processes
reaped
builtins/wait.def
- wait_builtin: if -p pid supplied without -n, make sure we do something
useful if no job/pid arguments are supplied and there are no jobs.
Reported by Oguz <oguzismailuysal@gmail.com>
builtins/read.def
- read_builtin: if we have a timeout, use SIGALRM instead of select
when in posix mode, since we use read instead of zread. Fixes bug
reported by Andreas Schwab <schwab@linux-m68k.org>
subst.c
- expand_string_dollar_quote: handle single-quoted and double-quoted
strings that might include $' and $" without attempting translation;
do more error checking for unterminated $' and $" that leaves those
characters unmodified
+2 -2
View File
@@ -1,7 +1,7 @@
This file is cd.def, from which is created cd.c. It implements the
builtins "cd" and "pwd" in Bash.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -79,7 +79,7 @@ $SHORT_DOC cd [-L|[-P [-e]] [-@]] [dir]
Change the shell working directory.
Change the current directory to DIR. The default DIR is the value of the
HOME shell variable.
HOME shell variable. If DIR is "-", it is converted to $OLDPWD.
The variable CDPATH defines the search path for the directory containing
DIR. Alternative directory names in CDPATH are separated by a colon (:).
+1 -1
View File
@@ -471,7 +471,7 @@ read_builtin (list)
read_timeout->flags = SHTIMER_LONGJMP;
#if defined (HAVE_SELECT)
read_timeout->flags |= edit ? SHTIMER_ALARM : SHTIMER_SELECT;
read_timeout->flags |= (edit || posixly_correct) ? SHTIMER_ALARM : SHTIMER_SELECT;
#else
read_timeout->flags |= SHTIMER_ALARM;
#endif
+2 -2
View File
@@ -235,8 +235,8 @@ wait_builtin (list)
currently active background processes. */
if (list == 0)
{
wait_for_background_pids (&pstat);
if (vname)
opt = wait_for_background_pids (&pstat);
if (vname && opt)
builtin_bind_var_to_int (vname, pstat.pid, bindflags);
WAIT_RETURN (EXECUTION_SUCCESS);
}
+22 -13
View File
@@ -3,7 +3,7 @@
</HEAD>
<BODY><TABLE WIDTH=100%>
<TR>
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2021 December 26<TH ALIGN=RIGHT width=33%>BASH(1)
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2022 January 17<TH ALIGN=RIGHT width=33%>BASH(1)
</TR>
</TABLE>
<BR><A HREF="#index">Index</A>
@@ -54,7 +54,7 @@ bash - GNU Bourne-Again SHell
<H3>COPYRIGHT</H3>
Bash is Copyright &#169; 1989-2021 by the Free Software Foundation, Inc.
Bash is Copyright &#169; 1989-2022 by the Free Software Foundation, Inc.
<A NAME="lbAE">&nbsp;</A>
<H3>DESCRIPTION</H3>
@@ -4215,18 +4215,27 @@ matches of <I>pattern</I> are deleted.
If <I>string</I> is null,
matches of <I>pattern</I> are deleted
and the <B>/</B> following <I>pattern</I> may be omitted.
<P>
If the <B>patsub_replacement</B> shell option is enabled using <B>shopt</B>,
any unquoted instances of <B>&amp;</B> in <I>string</I> are replaced with the
matching portion of <I>pattern</I>.
Backslash is used to quote <B>&amp;</B> in <I>string</I>; the backslash is removed
<P>
Quoting any part of <I>string</I> inhibits replacement in the
expansion of the quoted portion, including replacement strings stored
in shell variables.
Backslash will escape <B>&amp;</B> in <I>string</I>; the backslash is removed
in order to permit a literal <B>&amp;</B> in the replacement string.
Users should take care
if <I>string</I> is double-quoted to avoid unwanted interactions between
the backslash and double-quoting.
Pattern substitution performs the check for <B>&amp;</B> after expanding
<I>string</I>; shell programmers should quote backslashes intended to escape
the <B>&amp;</B> and inhibit replacement so they survive any quote removal
performed by the expansion of <I>string</I>.
Backslash can also be used to escape a backslash; <B>\\</B> results in
a literal backslash in the replacement.
Users should take care if <I>string</I> is double-quoted to avoid
unwanted interactions between the backslash and double-quoting, since
backslash has special meaning within double quotes.
Pattern substitution performs the check for unquoted <B>&amp;</B> after
expanding <I>string</I>;
shell programmers should quote any occurrences of <B>&amp;</B>
they want to be taken literally in the replacement
and ensure any instances of <B>&amp;</B> they want to be replaced are unquoted.
<P>
If the
<B>nocasematch</B>
@@ -14617,7 +14626,7 @@ There may be only one active coprocess at a time.
<HR>
<TABLE WIDTH=100%>
<TR>
<TH ALIGN=LEFT width=33%>GNU Bash 5.2<TH ALIGN=CENTER width=33%>2021 December 26<TH ALIGN=RIGHT width=33%>BASH(1)
<TH ALIGN=LEFT width=33%>GNU Bash 5.2<TH ALIGN=CENTER width=33%>2022 January 17<TH ALIGN=RIGHT width=33%>BASH(1)
</TR>
</TABLE>
<HR>
@@ -14723,7 +14732,7 @@ There may be only one active coprocess at a time.
<DT><A HREF="#lbDI">BUGS</A><DD>
</DL>
<HR>
This document was created by man2html from /usr/local/src/bash/bash-20220105/doc/bash.1.<BR>
Time: 11 January 2022 15:02:14 EST
This document was created by man2html from bash.1.<BR>
Time: 18 January 2022 10:57:39 EST
</BODY>
</HTML>
+178 -158
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, 26 December 2021).
Bash shell (version 5.2, 17 January 2022).
This is Edition 5.2, last updated 26 December 2021, of 'The GNU Bash
This is Edition 5.2, last updated 17 January 2022, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.2.
Copyright (C) 1988-2021 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, 26 December 2021). The Bash home page is
Bash shell (version 5.2, 17 January 2022). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.2, last updated 26 December 2021, of 'The GNU Bash
This is Edition 5.2, last updated 17 January 2022, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.2.
Bash contains features that appear in other popular shells, and some
@@ -2078,38 +2078,58 @@ omitted, the operator tests only for existence.
If the 'patsub_replacement' shell option is enabled using 'shopt',
any unquoted instances of '&' in STRING are replaced with the
matching portion of PATTERN. This is intended to duplicate a
common 'sed' idiom. Backslash is used to quote '&' in STRING; the
backslash is removed in order to permit a literal '&' in the
replacement string. Pattern substitution performs the check for
'&' after expanding STRING, so users should take care to quote
backslashes intended to escape the '&' and inhibit replacement so
they survive any quote removal performed by the expansion of
STRING. For instance,
common 'sed' idiom.
Quoting any part of STRING inhibits replacement in the expansion of
the quoted portion, including replacement strings stored in shell
variables. Backslash will escape '&' in STRING; the backslash is
removed in order to permit a literal '&' in the replacement string.
Users should take care if STRING is double-quoted to avoid unwanted
interactions between the backslash and double-quoting, since
backslash has special meaning within double quotes. Pattern
substitution performs the check for unquoted '&' after expanding
STRING, so users should ensure to properly quote any occurrences of
'&' they want to be taken literally in the replacement and ensure
any instances of '&' they want to be replaced are unquoted.
For instance,
var=abcdef
rep='& '
echo ${var/abc/& }
echo "${var/abc/& }"
echo ${var/abc/"& "}
echo ${var/abc/$rep}
echo "${var/abc/$rep}"
will display three lines of "abc def", while
will display four lines of "abc def", while
var=abcdef
rep='& '
echo ${var/abc/\& }
echo "${var/abc/\& }"
echo ${var/abc/"\& "}
echo ${var/abc/"& "}
echo ${var/abc/"$rep"}
will display two lines of "abc def" and a third line of "& def".
The first two are replaced because the backslash is removed by
quote removal performed during the expansion of STRING (the
expansion is performed in a context that doesn't take any enclosing
double quotes into account, as with other word expansions). In the
third case, the double quotes affect the expansion of '\&', and,
because '&' is not one of the characters for which backslash is
special in double quotes, the backslash survives the expansion,
inhibits the replacement, but is removed because it is treated
specially. One could use '\\&', unquoted, as the replacement
string to achive the same effect. It should rarely be necessary to
enclose only STRING in double quotes.
will display four lines of "& def". Like the pattern removal
operators, double quotes surrounding the replacement string quote
the expanded characters, while double quotes enclosing the entire
parameter substitution do not, since the expansion is performed in
a context that doesn't take any enclosing double quotes into
account.
Since backslash can escape '&', it can also escape a backslash in
the replacement string. This means that '\\' will insert a literal
backslash into the replacement, so these two 'echo' commands
var=abcdef
rep='\\&xyz'
echo ${var/abc/\\&xyz}
echo ${var/abc/$rep}
will both output '\abcxyzdef'.
It should rarely be necessary to enclose only STRING in double
quotes.
If the 'nocasematch' shell option (see the description of 'shopt'
in *note The Shopt Builtin::) is enabled, the match is performed
@@ -12422,138 +12442,138 @@ D.5 Concept Index

Tag Table:
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: Lists29189
Node: Compound Commands30981
Node: Looping Constructs31990
Node: Conditional Constructs34482
Node: Command Grouping48823
Node: Coprocesses50298
Node: GNU Parallel52958
Node: Shell Functions53872
Node: Shell Parameters61160
Node: Positional Parameters65545
Node: Special Parameters66444
Node: Shell Expansions69655
Node: Brace Expansion71779
Node: Tilde Expansion74510
Node: Shell Parameter Expansion77128
Node: Command Substitution94991
Node: Arithmetic Expansion96343
Node: Process Substitution97308
Node: Word Splitting98425
Node: Filename Expansion100366
Node: Pattern Matching103112
Node: Quote Removal107717
Node: Redirections108009
Node: Executing Commands117666
Node: Simple Command Expansion118333
Node: Command Search and Execution120440
Node: Command Execution Environment122815
Node: Environment125847
Node: Exit Status127507
Node: Signals129288
Node: Shell Scripts132734
Node: Shell Builtin Commands135758
Node: Bourne Shell Builtins137793
Node: Bash Builtins159251
Node: Modifying Shell Behavior190104
Node: The Set Builtin190446
Node: The Shopt Builtin201044
Node: Special Builtins216953
Node: Shell Variables217929
Node: Bourne Shell Variables218363
Node: Bash Variables220464
Node: Bash Features253277
Node: Invoking Bash254287
Node: Bash Startup Files260297
Node: Interactive Shells265397
Node: What is an Interactive Shell?265804
Node: Is this Shell Interactive?266450
Node: Interactive Shell Behavior267262
Node: Bash Conditional Expressions270888
Node: Shell Arithmetic275527
Node: Aliases278468
Node: Arrays281078
Node: The Directory Stack287322
Node: Directory Stack Builtins288103
Node: Controlling the Prompt292360
Node: The Restricted Shell295322
Node: Bash POSIX Mode297929
Node: Shell Compatibility Mode309199
Node: Job Control317225
Node: Job Control Basics317682
Node: Job Control Builtins322681
Node: Job Control Variables328078
Node: Command Line Editing329231
Node: Introduction and Notation330899
Node: Readline Interaction332519
Node: Readline Bare Essentials333707
Node: Readline Movement Commands335487
Node: Readline Killing Commands336444
Node: Readline Arguments338359
Node: Searching339400
Node: Readline Init File341583
Node: Readline Init File Syntax342841
Node: Conditional Init Constructs364326
Node: Sample Init File368519
Node: Bindable Readline Commands371640
Node: Commands For Moving372841
Node: Commands For History374889
Node: Commands For Text379880
Node: Commands For Killing383526
Node: Numeric Arguments386556
Node: Commands For Completion387692
Node: Keyboard Macros391880
Node: Miscellaneous Commands392564
Node: Readline vi Mode398500
Node: Programmable Completion399404
Node: Programmable Completion Builtins407181
Node: A Programmable Completion Example417873
Node: Using History Interactively423117
Node: Bash History Facilities423798
Node: Bash History Builtins426800
Node: History Interaction431805
Node: Event Designators435422
Node: Word Designators436773
Node: Modifiers438530
Node: Installing Bash440338
Node: Basic Installation441472
Node: Compilers and Options445191
Node: Compiling For Multiple Architectures445929
Node: Installation Names447619
Node: Specifying the System Type449725
Node: Sharing Defaults450438
Node: Operation Controls451108
Node: Optional Features452063
Node: Reporting Bugs463278
Node: Major Differences From The Bourne Shell464550
Node: GNU Free Documentation License481397
Node: Indexes506571
Node: Builtin Index507022
Node: Reserved Word Index513846
Node: Variable Index516291
Node: Function Index532780
Node: Concept Index546561
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: Lists29185
Node: Compound Commands30977
Node: Looping Constructs31986
Node: Conditional Constructs34478
Node: Command Grouping48819
Node: Coprocesses50294
Node: GNU Parallel52954
Node: Shell Functions53868
Node: Shell Parameters61156
Node: Positional Parameters65541
Node: Special Parameters66440
Node: Shell Expansions69651
Node: Brace Expansion71775
Node: Tilde Expansion74506
Node: Shell Parameter Expansion77124
Node: Command Substitution95458
Node: Arithmetic Expansion96810
Node: Process Substitution97775
Node: Word Splitting98892
Node: Filename Expansion100833
Node: Pattern Matching103579
Node: Quote Removal108184
Node: Redirections108476
Node: Executing Commands118133
Node: Simple Command Expansion118800
Node: Command Search and Execution120907
Node: Command Execution Environment123282
Node: Environment126314
Node: Exit Status127974
Node: Signals129755
Node: Shell Scripts133201
Node: Shell Builtin Commands136225
Node: Bourne Shell Builtins138260
Node: Bash Builtins159718
Node: Modifying Shell Behavior190571
Node: The Set Builtin190913
Node: The Shopt Builtin201511
Node: Special Builtins217420
Node: Shell Variables218396
Node: Bourne Shell Variables218830
Node: Bash Variables220931
Node: Bash Features253744
Node: Invoking Bash254754
Node: Bash Startup Files260764
Node: Interactive Shells265864
Node: What is an Interactive Shell?266271
Node: Is this Shell Interactive?266917
Node: Interactive Shell Behavior267729
Node: Bash Conditional Expressions271355
Node: Shell Arithmetic275994
Node: Aliases278935
Node: Arrays281545
Node: The Directory Stack287789
Node: Directory Stack Builtins288570
Node: Controlling the Prompt292827
Node: The Restricted Shell295789
Node: Bash POSIX Mode298396
Node: Shell Compatibility Mode309666
Node: Job Control317692
Node: Job Control Basics318149
Node: Job Control Builtins323148
Node: Job Control Variables328545
Node: Command Line Editing329698
Node: Introduction and Notation331366
Node: Readline Interaction332986
Node: Readline Bare Essentials334174
Node: Readline Movement Commands335954
Node: Readline Killing Commands336911
Node: Readline Arguments338826
Node: Searching339867
Node: Readline Init File342050
Node: Readline Init File Syntax343308
Node: Conditional Init Constructs364793
Node: Sample Init File368986
Node: Bindable Readline Commands372107
Node: Commands For Moving373308
Node: Commands For History375356
Node: Commands For Text380347
Node: Commands For Killing383993
Node: Numeric Arguments387023
Node: Commands For Completion388159
Node: Keyboard Macros392347
Node: Miscellaneous Commands393031
Node: Readline vi Mode398967
Node: Programmable Completion399871
Node: Programmable Completion Builtins407648
Node: A Programmable Completion Example418340
Node: Using History Interactively423584
Node: Bash History Facilities424265
Node: Bash History Builtins427267
Node: History Interaction432272
Node: Event Designators435889
Node: Word Designators437240
Node: Modifiers438997
Node: Installing Bash440805
Node: Basic Installation441939
Node: Compilers and Options445658
Node: Compiling For Multiple Architectures446396
Node: Installation Names448086
Node: Specifying the System Type450192
Node: Sharing Defaults450905
Node: Operation Controls451575
Node: Optional Features452530
Node: Reporting Bugs463745
Node: Major Differences From The Bourne Shell465017
Node: GNU Free Documentation License481864
Node: Indexes507038
Node: Builtin Index507489
Node: Reserved Word Index514313
Node: Variable Index516758
Node: Function Index533247
Node: Concept Index547028

End Tag Table
BIN
View File
Binary file not shown.
+4965 -4960
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -49,4 +49,4 @@ AAUUTTHHOORRSS
GNU Bash 5.1 2020 August 1 BASHBUG(1)
GNU Bash 5.2 2020 August 1 BASHBUG(1)
+2 -2
View File
@@ -1,6 +1,6 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.22.4
%%CreationDate: Fri Aug 7 11:58:10 2020
%%CreationDate: Tue Jan 11 16:04:43 2022
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%+ font Times-Italic
@@ -290,7 +290,7 @@ F2(EDIT)108 300 Q(OR)-.18 E F0 .327(Speci\214es the preferred editor)144
(are F)-.1 E(oundation)-.15 E(bfox@gnu.or)108 463.2 Q(g)-.18 E
(Chet Rame)108 480 Q 1.3 -.65(y, C)-.15 H(ase W).65 E(estern Reserv)-.8
E 2.5(eU)-.15 G(ni)-2.5 E -.15(ve)-.25 G(rsity).15 E(chet@po.cwru.edu)
108 492 Q(GNU Bash 5.1)72 768 Q(2020 August 1)145.395 E(1)199.555 E 0 Cg
108 492 Q(GNU Bash 5.2)72 768 Q(2020 August 1)145.395 E(1)199.555 E 0 Cg
EP
%%Trailer
end
+7 -7
View File
@@ -99,18 +99,18 @@
@xrdef{Shell Parameter Expansion-pg}{26}
@xrdef{Command Substitution-title}{Command Substitution}
@xrdef{Command Substitution-snt}{Section@tie 3.5.4}
@xrdef{Command Substitution-pg}{33}
@xrdef{Arithmetic Expansion-title}{Arithmetic Expansion}
@xrdef{Arithmetic Expansion-snt}{Section@tie 3.5.5}
@xrdef{Process Substitution-title}{Process Substitution}
@xrdef{Process Substitution-snt}{Section@tie 3.5.6}
@xrdef{Word Splitting-title}{Word Splitting}
@xrdef{Word Splitting-snt}{Section@tie 3.5.7}
@xrdef{Command Substitution-pg}{34}
@xrdef{Arithmetic Expansion-pg}{34}
@xrdef{Process Substitution-pg}{34}
@xrdef{Word Splitting-pg}{34}
@xrdef{Word Splitting-title}{Word Splitting}
@xrdef{Word Splitting-snt}{Section@tie 3.5.7}
@xrdef{Filename Expansion-title}{Filename Expansion}
@xrdef{Filename Expansion-snt}{Section@tie 3.5.8}
@xrdef{Word Splitting-pg}{35}
@xrdef{Filename Expansion-pg}{35}
@xrdef{Pattern Matching-title}{Pattern Matching}
@xrdef{Pattern Matching-snt}{Section@tie 3.5.8.1}
@@ -135,16 +135,16 @@
@xrdef{Command Execution Environment-pg}{42}
@xrdef{Environment-title}{Environment}
@xrdef{Environment-snt}{Section@tie 3.7.4}
@xrdef{Environment-pg}{43}
@xrdef{Exit Status-title}{Exit Status}
@xrdef{Exit Status-snt}{Section@tie 3.7.5}
@xrdef{Signals-title}{Signals}
@xrdef{Signals-snt}{Section@tie 3.7.6}
@xrdef{Environment-pg}{44}
@xrdef{Exit Status-pg}{44}
@xrdef{Signals-pg}{44}
@xrdef{Shell Scripts-title}{Shell Scripts}
@xrdef{Shell Scripts-snt}{Section@tie 3.8}
@xrdef{Shell Scripts-pg}{45}
@xrdef{Signals-pg}{45}
@xrdef{Shell Scripts-pg}{46}
@xrdef{Shell Builtin Commands-title}{Shell Builtin Commands}
@xrdef{Shell Builtin Commands-snt}{Chapter@tie 4}
@xrdef{Bourne Shell Builtins-title}{Bourne Shell Builtins}
+5 -5
View File
@@ -54,11 +54,11 @@
\entry{expansion, tilde}{25}{expansion, tilde}
\entry{parameter expansion}{26}{parameter expansion}
\entry{expansion, parameter}{26}{expansion, parameter}
\entry{command substitution}{33}{command substitution}
\entry{command substitution}{34}{command substitution}
\entry{expansion, arithmetic}{34}{expansion, arithmetic}
\entry{arithmetic expansion}{34}{arithmetic expansion}
\entry{process substitution}{34}{process substitution}
\entry{word splitting}{34}{word splitting}
\entry{word splitting}{35}{word splitting}
\entry{expansion, filename}{35}{expansion, filename}
\entry{expansion, pathname}{35}{expansion, pathname}
\entry{filename expansion}{35}{filename expansion}
@@ -70,10 +70,10 @@
\entry{command execution}{42}{command execution}
\entry{command search}{42}{command search}
\entry{execution environment}{42}{execution environment}
\entry{environment}{43}{environment}
\entry{environment}{44}{environment}
\entry{exit status}{44}{exit status}
\entry{signal handling}{44}{signal handling}
\entry{shell script}{45}{shell script}
\entry{signal handling}{45}{signal handling}
\entry{shell script}{46}{shell script}
\entry{special builtin}{76}{special builtin}
\entry{login shell}{92}{login shell}
\entry{interactive shell}{92}{interactive shell}
+5 -5
View File
@@ -17,7 +17,7 @@
\entry{command expansion}{41}
\entry{command history}{151}
\entry{command search}{42}
\entry{command substitution}{33}
\entry{command substitution}{34}
\entry{command timing}{10}
\entry{commands, compound}{11}
\entry{commands, conditional}{12}
@@ -38,7 +38,7 @@
\entry{directory stack}{101}
\initial {E}
\entry{editing command lines}{117}
\entry{environment}{43}
\entry{environment}{44}
\entry{evaluation, arithmetic}{97}
\entry{event designators}{154}
\entry{execution environment}{42}
@@ -118,11 +118,11 @@
\initial {S}
\entry{shell arithmetic}{97}
\entry{shell function}{19}
\entry{shell script}{45}
\entry{shell script}{46}
\entry{shell variable}{21}
\entry{shell, interactive}{93}
\entry{signal}{4}
\entry{signal handling}{44}
\entry{signal handling}{45}
\entry{special builtin}{4, 76}
\entry{startup files}{92}
\entry{string translations}{7}
@@ -136,6 +136,6 @@
\entry{variables, readline}{120}
\initial {W}
\entry{word}{4}
\entry{word splitting}{34}
\entry{word splitting}{35}
\initial {Y}
\entry{yanking text}{118}
BIN
View File
Binary file not shown.
+48 -28
View File
@@ -4,9 +4,9 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This text is a brief description of the features that are present in
the Bash shell (version 5.2, 26 December 2021).
the Bash shell (version 5.2, 17 January 2022).
This is Edition 5.2, last updated 26 December 2021,
This is Edition 5.2, last updated 17 January 2022,
of The GNU Bash Reference Manual,
for Bash, Version 5.2.
@@ -77,10 +77,10 @@ Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Previou
<span id="Bash-Features-1"></span><h1 class="top">Bash Features</h1>
<p>This text is a brief description of the features that are present in
the Bash shell (version 5.2, 26 December 2021).
the Bash shell (version 5.2, 17 January 2022).
The Bash home page is <a href="http://www.gnu.org/software/bash/">http://www.gnu.org/software/bash/</a>.
</p>
<p>This is Edition 5.2, last updated 26 December 2021,
<p>This is Edition 5.2, last updated 17 January 2022,
of <cite>The GNU Bash Reference Manual</cite>,
for <code>Bash</code>, Version 5.2.
</p>
@@ -2845,45 +2845,65 @@ and the &lsquo;<samp>/</samp>&rsquo; following <var>pattern</var> may be omitted
any unquoted instances of &lsquo;<samp>&amp;</samp>&rsquo; in <var>string</var> are replaced with the
matching portion of <var>pattern</var>.
This is intended to duplicate a common <code>sed</code> idiom.
Backslash is used to quote &lsquo;<samp>&amp;</samp>&rsquo; in <var>string</var>; the backslash is removed
</p>
<p>Quoting any part of <var>string</var> inhibits replacement in the
expansion of the quoted portion, including replacement strings stored
in shell variables.
Backslash will escape &lsquo;<samp>&amp;</samp>&rsquo; in <var>string</var>; the backslash is removed
in order to permit a literal &lsquo;<samp>&amp;</samp>&rsquo; in the replacement string.
Pattern substitution performs the check for &lsquo;<samp>&amp;</samp>&rsquo; after expanding
<var>string</var>,
so users should take care to quote backslashes intended to escape
the &lsquo;<samp>&amp;</samp>&rsquo; and inhibit replacement so they survive any quote removal
performed by the expansion of <var>string</var>.
For instance,
Users should take care if <var>string</var> is double-quoted to avoid
unwanted interactions between the backslash and double-quoting, since
backslash has special meaning within double quotes.
Pattern substitution performs the check for unquoted &lsquo;<samp>&amp;</samp>&rsquo; after
expanding <var>string</var>,
so users should ensure to properly quote any occurrences of &lsquo;<samp>&amp;</samp>&rsquo;
they want to be taken literally in the replacement
and ensure any instances of &lsquo;<samp>&amp;</samp>&rsquo; they want to be replaced are unquoted.
</p>
<p>For instance,
</p>
<div class="example">
<pre class="example">var=abcdef
rep='&amp; '
echo ${var/abc/&amp; }
echo &quot;${var/abc/&amp; }&quot;
echo ${var/abc/&quot;&amp; &quot;}
echo ${var/abc/$rep}
echo &quot;${var/abc/$rep}&quot;
</pre></div>
<p>will display three lines of &quot;abc def&quot;, while
<p>will display four lines of &quot;abc def&quot;, while
</p>
<div class="example">
<pre class="example">var=abcdef
rep='&amp; '
echo ${var/abc/\&amp; }
echo &quot;${var/abc/\&amp; }&quot;
echo ${var/abc/&quot;\&amp; &quot;}
echo ${var/abc/&quot;&amp; &quot;}
echo ${var/abc/&quot;$rep&quot;}
</pre></div>
<p>will display two lines of &quot;abc def&quot; and a third line of &quot;&amp; def&quot;.
The first two are replaced because the backslash is removed by quote
removal performed during the expansion of <var>string</var>
(the expansion is performed in a
context that doesn&rsquo;t take any enclosing double quotes into account, as
with other word expansions).
In the third case, the double quotes affect the expansion
of &lsquo;<samp>\&amp;</samp>&rsquo;, and, because &lsquo;<samp>&amp;</samp>&rsquo; is not one of the characters for
which backslash is special in double quotes,
the backslash survives the expansion, inhibits the replacement,
but is removed because it is treated specially.
One could use &lsquo;<samp>\\&amp;</samp>&rsquo;, unquoted, as the replacement string to achive
the same effect.
It should rarely be necessary to enclose only <var>string</var> in double
<p>will display four lines of &quot;&amp; def&quot;.
Like the pattern removal operators, double quotes surrounding the
replacement string quote the expanded characters, while double quotes
enclosing the entire parameter substitution do not, since
the expansion is performed in a
context that doesn&rsquo;t take any enclosing double quotes into account.
</p>
<p>Since backslash can escape &lsquo;<samp>&amp;</samp>&rsquo;, it can also escape a backslash in
the replacement string.
This means that &lsquo;<samp>\\</samp>&rsquo; will insert a literal
backslash into the replacement, so these two <code>echo</code> commands
</p>
<div class="example">
<pre class="example">var=abcdef
rep='\\&amp;xyz'
echo ${var/abc/\\&amp;xyz}
echo ${var/abc/$rep}
</pre></div>
<p>will both output &lsquo;<samp>\abcxyzdef</samp>&rsquo;.
</p>
<p>It should rarely be necessary to enclose only <var>string</var> in double
quotes.
</p>
<p>If the <code>nocasematch</code> shell option
+40 -47
View File
@@ -1,12 +1,9 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/MacPorts 2021.58693_0) (preloaded format=pdfetex 2021.8.30) 11 JAN 2022 15:04
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/MacPorts 2021.58693_0) (preloaded format=pdftex 2021.10.21) 18 JAN 2022 10:57
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
%&-line parsing enabled.
**\input /usr/local/src/bash/bash-20220105/doc/bashref.texi \input /usr/local/s
rc/bash/bash-20220105/doc/bashref.texi
(/usr/local/src/bash/bash-20220105/doc/bashref.texi
(/usr/local/src/bash/bash-20220105/doc/texinfo.tex
**/usr/local/src/chet/src/bash/src/doc/bashref.texi
(/usr/local/src/chet/src/bash/src/doc/bashref.texi (./texinfo.tex
Loading texinfo [version 2015-11-22.14]:
\outerhsize=\dimen16
\outervsize=\dimen17
@@ -162,27 +159,24 @@ This is `epsf.tex' v2.7.4 <14 February 2011>
texinfo.tex: doing @include of version.texi
(/usr/local/src/bash/bash-20220105/doc/version.texi) [1{/opt/local/var/db/texmf
/fonts/map/pdftex/updmap/pdftex.map}] [2]
(/usr/local/build/bash/bash-20220105/doc/bashref.toc [-1] [-2] [-3]) [-4]
(/usr/local/build/bash/bash-20220105/doc/bashref.toc)
(/usr/local/build/bash/bash-20220105/doc/bashref.toc) Chapter 1
(./version.texi) [1{/opt/local/var/db/texmf/fonts/map/pdftex/updmap/pdftex.map}
] [2] (./bashref.toc [-1] [-2] [-3]) [-4] (./bashref.toc) (./bashref.toc)
Chapter 1
\openout0 = `bashref.toc'.
(/usr/local/build/bash/bash-20220105/doc/bashref.aux)
(./bashref.aux)
\openout1 = `bashref.aux'.
Chapter 2 [1] [2]
@cpindfile=@write2
\openout2 = `bashref.cp'.
[3] Chapter 3 [4] [5] [6] [7]
[3] Chapter 3 [4] [5] [6] [7]
@vrindfile=@write3
\openout3 = `bashref.vr'.
[8]
[8]
Overfull \hbox (3.12749pt too wide) in paragraph at lines 723--724
@texttt coproc[]|
@@ -229,7 +223,7 @@ Overfull \hbox (5.95723pt too wide) in paragraph at lines 724--725
[47] [48] [49] [50] [51]
[52] [53] [54] [55] [56] [57] [58] [59] [60] [61] [62] [63] [64] [65]
Overfull \hbox (38.26585pt too wide) in paragraph at lines 5180--5180
Overfull \hbox (38.26585pt too wide) in paragraph at lines 5201--5201
[]@texttt set [-abefhkmnptuvxBCEHPT] [-o @textttsl option-name@texttt ] [--] [
-] [@textttsl ar-gu-ment []@texttt ][]
@@ -242,7 +236,7 @@ Overfull \hbox (38.26585pt too wide) in paragraph at lines 5180--5180
.etc.
Overfull \hbox (38.26585pt too wide) in paragraph at lines 5181--5181
Overfull \hbox (38.26585pt too wide) in paragraph at lines 5202--5202
[]@texttt set [+abefhkmnptuvxBCEHPT] [+o @textttsl option-name@texttt ] [--] [
-] [@textttsl ar-gu-ment []@texttt ][]
@@ -261,7 +255,7 @@ Overfull \hbox (38.26585pt too wide) in paragraph at lines 5181--5181
texinfo.tex: doing @include of rluser.texi
(/usr/local/src/bash/bash-20220105/lib/readline/doc/rluser.texi Chapter 8
(/usr/local/src/chet/src/bash/src/lib/readline/doc/rluser.texi Chapter 8
[115] [116] [117] [118] [119] [120] [121] [122] [123] [124] [125]
Underfull \hbox (badness 7540) in paragraph at lines 831--837
[]@textrm In the ex-am-ple above, @textttsl C-u[] @textrm is bound to the func
@@ -323,10 +317,10 @@ Overfull \hbox (15.27109pt too wide) in paragraph at lines 2090--2090
texinfo.tex: doing @include of hsuser.texi
(/usr/local/src/bash/bash-20220105/lib/readline/doc/hsuser.texi Chapter 9
(/usr/local/src/chet/src/bash/src/lib/readline/doc/hsuser.texi Chapter 9
[150] [151] [152] [153] [154] [155]) Chapter 10 [156] [157] [158] [159]
[160]
Underfull \hbox (badness 10000) in paragraph at lines 9297--9306
Underfull \hbox (badness 10000) in paragraph at lines 9318--9327
[]@textrm All of the fol-low-ing op-tions ex-cept for `@texttt alt-array-implem
entation[]@textrm '[],
@@ -339,7 +333,7 @@ entation[]@textrm '[],
.etc.
Underfull \hbox (badness 10000) in paragraph at lines 9297--9306
Underfull \hbox (badness 10000) in paragraph at lines 9318--9327
@textrm `@texttt disabled-builtins[]@textrm '[], `@texttt direxpand-default[]@t
extrm '[], `@texttt strict-posix-default[]@textrm '[], and
@@ -355,35 +349,34 @@ extrm '[], `@texttt strict-posix-default[]@textrm '[], and
[170] [171] Appendix C [172]
texinfo.tex: doing @include of fdl.texi
(/usr/local/src/bash/bash-20220105/doc/fdl.texi
[173] [174] [175] [176] [177] [178] [179]) Appendix D [180] [181] [182]
[183] [184] [185] [186] [187] [188] [189] )
(./fdl.texi [173] [174] [175] [176] [177] [178]
[179]) Appendix D [180] [181] [182] [183] [184] [185] [186] [187] [188]
[189] )
Here is how much of TeX's memory you used:
4094 strings out of 497086
47566 string characters out of 6206517
141412 words of memory out of 5000000
4093 strings out of 497086
46984 string characters out of 6206519
140410 words of memory out of 5000000
4867 multiletter control sequences out of 15000+600000
34315 words of font info for 116 fonts, out of 8000000 for 9000
51 hyphenation exceptions out of 8191
16i,6n,16p,389b,978s stack positions out of 5000i,500n,10000p,200000b,80000s
{/opt/local/share/texmf-texlive/font
s/enc/dvips/cm-super/cm-super-t1.enc}</opt/local/share/texmf-texlive/fonts/type
1/public/amsfonts/cm/cmbx12.pfb></opt/local/share/texmf-texlive/fonts/type1/pub
lic/amsfonts/cm/cmcsc10.pfb></opt/local/share/texmf-texlive/fonts/type1/public/
amsfonts/cm/cmmi10.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfo
nts/cm/cmmi12.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/c
m/cmmi9.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr1
0.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr9.pfb><
/opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmsl10.pfb></opt/
local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmsltt10.pfb></opt/loc
al/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmsy10.pfb></opt/local/sh
are/texmf-texlive/fonts/type1/public/amsfonts/cm/cmti10.pfb></opt/local/share/t
exmf-texlive/fonts/type1/public/amsfonts/cm/cmtt10.pfb></opt/local/share/texmf-
texlive/fonts/type1/public/amsfonts/cm/cmtt12.pfb></opt/local/share/texmf-texli
ve/fonts/type1/public/amsfonts/cm/cmtt9.pfb></opt/local/share/texmf-texlive/fon
ts/type1/public/cm-super/sfrm1095.pfb></opt/local/share/texmf-texlive/fonts/typ
e1/public/cm-super/sfrm1440.pfb>
Output written on bashref.pdf (195 pages, 790709 bytes).
16i,6n,16p,323b,978s stack positions out of 5000i,500n,10000p,200000b,80000s
{/opt/local/share/texmf-texlive/fonts/enc/dvips/cm-super/cm-super-t1.enc
}</opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmbx12.pfb></op
t/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmcsc10.pfb></opt/lo
cal/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmmi10.pfb></opt/local/s
hare/texmf-texlive/fonts/type1/public/amsfonts/cm/cmmi12.pfb></opt/local/share/
texmf-texlive/fonts/type1/public/amsfonts/cm/cmmi9.pfb></opt/local/share/texmf-
texlive/fonts/type1/public/amsfonts/cm/cmr10.pfb></opt/local/share/texmf-texliv
e/fonts/type1/public/amsfonts/cm/cmr9.pfb></opt/local/share/texmf-texlive/fonts
/type1/public/amsfonts/cm/cmsl10.pfb></opt/local/share/texmf-texlive/fonts/type
1/public/amsfonts/cm/cmsltt10.pfb></opt/local/share/texmf-texlive/fonts/type1/p
ublic/amsfonts/cm/cmsy10.pfb></opt/local/share/texmf-texlive/fonts/type1/public
/amsfonts/cm/cmti10.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsf
onts/cm/cmtt10.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/
cm/cmtt12.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cm
tt9.pfb></opt/local/share/texmf-texlive/fonts/type1/public/cm-super/sfrm1095.pf
b></opt/local/share/texmf-texlive/fonts/type1/public/cm-super/sfrm1440.pfb>
Output written on bashref.pdf (195 pages, 791026 bytes).
PDF statistics:
2743 PDF objects out of 2984 (max. 8388607)
2501 compressed objects within 26 object streams
BIN
View File
Binary file not shown.
+834 -828
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -31,10 +31,10 @@
@numsubsecentry{Brace Expansion}{3.5.1}{Brace Expansion}{24}
@numsubsecentry{Tilde Expansion}{3.5.2}{Tilde Expansion}{25}
@numsubsecentry{Shell Parameter Expansion}{3.5.3}{Shell Parameter Expansion}{26}
@numsubsecentry{Command Substitution}{3.5.4}{Command Substitution}{33}
@numsubsecentry{Command Substitution}{3.5.4}{Command Substitution}{34}
@numsubsecentry{Arithmetic Expansion}{3.5.5}{Arithmetic Expansion}{34}
@numsubsecentry{Process Substitution}{3.5.6}{Process Substitution}{34}
@numsubsecentry{Word Splitting}{3.5.7}{Word Splitting}{34}
@numsubsecentry{Word Splitting}{3.5.7}{Word Splitting}{35}
@numsubsecentry{Filename Expansion}{3.5.8}{Filename Expansion}{35}
@numsubsubsecentry{Pattern Matching}{3.5.8.1}{Pattern Matching}{36}
@numsubsecentry{Quote Removal}{3.5.9}{Quote Removal}{37}
@@ -43,7 +43,7 @@
@numsubsecentry{Redirecting Output}{3.6.2}{}{39}
@numsubsecentry{Appending Redirected Output}{3.6.3}{}{39}
@numsubsecentry{Redirecting Standard Output and Standard Error}{3.6.4}{}{39}
@numsubsecentry{Appending Standard Output and Standard Error}{3.6.5}{}{39}
@numsubsecentry{Appending Standard Output and Standard Error}{3.6.5}{}{40}
@numsubsecentry{Here Documents}{3.6.6}{}{40}
@numsubsecentry{Here Strings}{3.6.7}{}{40}
@numsubsecentry{Duplicating File Descriptors}{3.6.8}{}{40}
@@ -53,10 +53,10 @@
@numsubsecentry{Simple Command Expansion}{3.7.1}{Simple Command Expansion}{41}
@numsubsecentry{Command Search and Execution}{3.7.2}{Command Search and Execution}{42}
@numsubsecentry{Command Execution Environment}{3.7.3}{Command Execution Environment}{42}
@numsubsecentry{Environment}{3.7.4}{Environment}{43}
@numsubsecentry{Environment}{3.7.4}{Environment}{44}
@numsubsecentry{Exit Status}{3.7.5}{Exit Status}{44}
@numsubsecentry{Signals}{3.7.6}{Signals}{44}
@numsecentry{Shell Scripts}{3.8}{Shell Scripts}{45}
@numsubsecentry{Signals}{3.7.6}{Signals}{45}
@numsecentry{Shell Scripts}{3.8}{Shell Scripts}{46}
@numchapentry{Shell Builtin Commands}{4}{Shell Builtin Commands}{47}
@numsecentry{Bourne Shell Builtins}{4.1}{Bourne Shell Builtins}{47}
@numsecentry{Bash Builtin Commands}{4.2}{Bash Builtins}{54}
+1 -1
View File
@@ -1,6 +1,6 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.22.4
%%CreationDate: Tue Jan 11 15:02:05 2022
%%CreationDate: Tue Jan 18 10:57:20 2022
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%+ font Times-Italic
+1 -1
View File
@@ -1,6 +1,6 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.22.4
%%CreationDate: Tue Jan 11 15:02:05 2022
%%CreationDate: Tue Jan 18 10:57:20 2022
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%DocumentSuppliedResources: procset grops 1.22 4
+1 -1
View File
@@ -342,7 +342,7 @@ extern char *sh_double_quote PARAMS((const char *));
extern char *sh_mkdoublequoted PARAMS((const char *, int, int));
extern char *sh_un_double_quote PARAMS((char *));
extern char *sh_backslash_quote PARAMS((char *, const char *, int));
extern char *sh_backslash_quote_for_double_quotes PARAMS((char *));
extern char *sh_backslash_quote_for_double_quotes PARAMS((char *, int));
extern char *sh_quote_reusable PARAMS((char *, int));
extern int sh_contains_shell_metas PARAMS((const char *));
extern int sh_contains_quotes PARAMS((const char *));
+7 -4
View File
@@ -3,7 +3,7 @@
/* This file works with both POSIX and BSD systems. It implements job
control. */
/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -2644,16 +2644,16 @@ wait_for_single_pid (pid, flags)
}
/* Wait for all of the background processes started by this shell to finish. */
void
int
wait_for_background_pids (ps)
struct procstat *ps;
{
register int i, r;
int any_stopped, check_async;
int any_stopped, check_async, njobs;
sigset_t set, oset;
pid_t pid;
for (any_stopped = 0, check_async = 1;;)
for (njobs = any_stopped = 0, check_async = 1;;)
{
BLOCK_CHILD (set, oset);
@@ -2698,6 +2698,7 @@ wait_for_background_pids (ps)
check_async = 0;
mark_all_jobs_as_dead ();
}
njobs++;
}
#if defined (PROCESS_SUBSTITUTION)
@@ -2709,6 +2710,8 @@ wait_for_background_pids (ps)
mark_dead_jobs_as_notified (1);
cleanup_dead_jobs ();
bgp_clear ();
return njobs;
}
/* Make OLD_SIGINT_HANDLER the SIGINT signal handler. */
+2 -2
View File
@@ -1,6 +1,6 @@
/* jobs.h -- structures and definitions used by the jobs.c file. */
/* Copyright (C) 1993-2019 Free Software Foundation, Inc.
/* Copyright (C) 1993-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -279,7 +279,7 @@ extern int job_exit_status PARAMS((int));
extern int job_exit_signal PARAMS((int));
extern int wait_for_single_pid PARAMS((pid_t, int));
extern void wait_for_background_pids PARAMS((struct procstat *));
extern int wait_for_background_pids PARAMS((struct procstat *));
extern int wait_for PARAMS((pid_t, int));
extern int wait_for_job PARAMS((int, int, struct procstat *));
extern int wait_for_any_job PARAMS((int, struct procstat *));
+15 -3
View File
@@ -818,8 +818,7 @@ glob_vector (pat, dir, flags)
add_current = ((flags & (GX_ALLDIRS|GX_ADDCURDIR)) == (GX_ALLDIRS|GX_ADDCURDIR));
/* Scan the directory, finding all names that match.
For each name that matches, allocate a struct globval
/* Scan the directory, finding all names that match For each name that matches, allocate a struct globval
on the stack and store the name in it.
Chain those structs together; lastlink is the front of the chain. */
while (1)
@@ -901,6 +900,9 @@ glob_vector (pat, dir, flags)
nextname = (char *) malloc (sdlen + 1);
if (nextlink == 0 || nextname == 0)
{
if (firstmalloc && firstmalloc == nextlink)
firstmalloc = 0;
/* If we reset FIRSTMALLOC we can free this here. */
FREE (nextlink);
FREE (nextname);
free (subdir);
@@ -936,8 +938,18 @@ glob_vector (pat, dir, flags)
nextname = (char *) malloc (D_NAMLEN (dp) + 1);
if (nextlink == 0 || nextname == 0)
{
/* We free NEXTLINK here, since it won't be added to the
LASTLINK chain. If we used malloc, and it returned non-
NULL, firstmalloc will be set to something valid. If it's
NEXTLINK, reset it before we free NEXTLINK to avoid
duplicate frees. If not, it will be taken care of by the
loop below with TMPLINK. */
if (firstmalloc)
FREE (nextlink);
{
if (firstmalloc == nextlink)
firstmalloc = 0;
FREE (nextlink);
}
FREE (nextname);
lose = 1;
break;
+2 -1
View File
@@ -315,8 +315,9 @@ sh_backslash_quote (string, table, flags)
/* Quote characters that get special treatment when in double quotes in STRING
using backslashes. Return a new string. */
char *
sh_backslash_quote_for_double_quotes (string)
sh_backslash_quote_for_double_quotes (string, flags)
char *string;
int flags;
{
unsigned char c;
char *result, *r, *s, *send;
+2 -10
View File
@@ -1,7 +1,7 @@
/* make_cmd.c -- Functions for making instances of the various
parser constructs. */
/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -632,10 +632,7 @@ make_here_document (temp, lineno)
}
if (*line == 0)
{
free (full_line);
continue;
}
continue;
if (STREQN (line, redir_word, redir_len) && line[redir_len] == '\n')
break;
@@ -644,7 +641,6 @@ make_here_document (temp, lineno)
if (STREQN (line, redir_word, redir_len) && (parser_state & PST_EOFTOKEN) && shell_eof_token && strchr (line+redir_len, shell_eof_token))
{
shell_ungets (line + redir_len);
free (full_line);
full_line = 0;
break;
}
@@ -660,15 +656,11 @@ make_here_document (temp, lineno)
being an empty string before the call to strlen. */
FASTCOPY (line, document + document_index, len);
document_index += len;
free (full_line);
}
if (full_line == 0)
internal_warning (_("here-document at line %d delimited by end-of-file (wanted `%s')"), lineno, redir_word);
FREE (full_line);
document_done:
if (document)
document[document_index] = '\0';
+7 -2
View File
@@ -3,7 +3,7 @@
/* This file works under BSD, System V, minix, and Posix systems. It does
not implement job control. */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -707,18 +707,20 @@ wait_for_single_pid (pid, flags)
/* Wait for all of the shell's children to exit. Called by the `wait'
builtin. */
void
int
wait_for_background_pids (ps)
struct procstat *ps;
{
pid_t got_pid;
WAIT status;
int njobs;
/* If we aren't using job control, we let the kernel take care of the
bookkeeping for us. wait () will return -1 and set errno to ECHILD
when there are no more unwaited-for child processes on both
4.2 BSD-based and System V-based systems. */
njobs = 0;
siginterrupt (SIGINT, 1);
/* Wait for ECHILD */
@@ -726,6 +728,7 @@ wait_for_background_pids (ps)
while ((got_pid = WAITPID (-1, &status, 0)) != -1)
{
waiting_for_child = 0;
njobs++;
set_pid_status (got_pid, status);
if (ps)
{
@@ -749,6 +752,8 @@ wait_for_background_pids (ps)
mark_dead_jobs_as_notified (1);
cleanup_dead_jobs ();
return njobs;
}
void
+10 -28
View File
@@ -1,6 +1,6 @@
/* parse.y - Yacc grammar for bash. */
/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -2136,14 +2136,12 @@ read_a_line (remove_quoted_newline)
the secondary prompt. This is used to read the lines of a here
document. REMOVE_QUOTED_NEWLINE is non-zero if we should remove
newlines quoted with backslashes while reading the line. It is
non-zero unless the delimiter of the here document was quoted.
If it is zero, we don't perform $'...' and $"..." expansion because
we treat the lines as if they are between double quotes. */
non-zero unless the delimiter of the here document was quoted. */
char *
read_secondary_line (remove_quoted_newline)
int remove_quoted_newline;
{
char *ret, *t;
char *ret;
int n, c;
prompt_string_pointer = &ps2_prompt;
@@ -2163,23 +2161,7 @@ read_secondary_line (remove_quoted_newline)
maybe_add_history (ret);
}
#endif /* HISTORY */
if (ret == 0)
return ret;
if (remove_quoted_newline == 0)
return (savestring (ret));
t = ret;
while (t = strchr (t, '$'))
{
if (t[1] == '\'' || t[1] == '"')
break;
else
t++;
}
if (t == 0)
return (savestring (ret));
t = expand_string_dollar_quote (ret, 1);
return t;
return ret;
}
/* **************************************************************** */
@@ -3875,7 +3857,7 @@ parse_matched_pair (qc, open, close, lenp, flags)
nestret = sh_single_quote (ttrans);
else
/* single quotes aren't special, use backslash instead */
nestret = sh_backslash_quote_for_double_quotes (ttrans);
nestret = sh_backslash_quote_for_double_quotes (ttrans, 0);
}
else
nestret = sh_mkdoublequoted (ttrans, ttranslen, 0);
@@ -5577,7 +5559,7 @@ decode_prompt_string (string)
int last_exit_value, last_comsub_pid;
#if defined (PROMPT_STRING_DECODE)
size_t result_size;
int result_index;
size_t result_index;
int c, n, i;
char *temp, *t_host, octal_string[4];
struct tm *tm;
@@ -5714,7 +5696,7 @@ decode_prompt_string (string)
/* Make sure that expand_prompt_string is called with a
second argument of Q_DOUBLE_QUOTES if we use this
function here. */
temp = sh_backslash_quote_for_double_quotes (timebuf);
temp = sh_backslash_quote_for_double_quotes (timebuf, 0);
else
temp = savestring (timebuf);
goto add_string;
@@ -5730,7 +5712,7 @@ decode_prompt_string (string)
temp = base_pathname (shell_name);
/* Try to quote anything the user can set in the file system */
if (promptvars || posixly_correct)
temp = sh_backslash_quote_for_double_quotes (temp);
temp = sh_backslash_quote_for_double_quotes (temp, 0);
else
temp = savestring (temp);
goto add_string;
@@ -5807,7 +5789,7 @@ decode_prompt_string (string)
/* Make sure that expand_prompt_string is called with a
second argument of Q_DOUBLE_QUOTES if we use this
function here. */
temp = sh_backslash_quote_for_double_quotes (t_string);
temp = sh_backslash_quote_for_double_quotes (t_string, 0);
else
temp = savestring (t_string);
@@ -5829,7 +5811,7 @@ decode_prompt_string (string)
/* Make sure that expand_prompt_string is called with a
second argument of Q_DOUBLE_QUOTES if we use this
function here. */
temp = sh_backslash_quote_for_double_quotes (t_host);
temp = sh_backslash_quote_for_double_quotes (t_host, 0);
else
temp = savestring (t_host);
free (t_host);
+55 -11
View File
@@ -4,7 +4,7 @@
/* ``Have a little faith, there's magic in the night. You ain't a
beauty, but, hey, you're alright.'' */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -738,16 +738,15 @@ unquoted_substring (substr, string)
INLINE char *
sub_append_string (source, target, indx, size)
char *source, *target;
int *indx;
size_t *indx;
size_t *size;
{
if (source)
{
int n;
size_t srclen;
size_t n, srclen;
srclen = STRLEN (source);
if (srclen >= (int)(*size - *indx))
if (srclen >= (*size - *indx))
{
n = srclen + *indx;
n = (n + DEFAULT_ARRAY_SIZE) - (n % DEFAULT_ARRAY_SIZE);
@@ -771,7 +770,7 @@ char *
sub_append_number (number, target, indx, size)
intmax_t number;
char *target;
int *indx;
size_t *indx;
size_t *size;
{
char *temp;
@@ -3861,8 +3860,8 @@ expand_string_dollar_quote (string, flags)
char *string;
int flags;
{
size_t slen;
int sindex, c, translen, retind, retsize, peekc, news;
size_t slen, retind, retsize;
int sindex, c, translen, peekc, news;
char *ret, *trans, *send, *t;
DECLARE_MBSTATE;
@@ -3891,6 +3890,25 @@ expand_string_dollar_quote (string, flags)
COPY_CHAR_I (ret, retind, string, send, sindex);
break;
case '\'':
case '"':
if (c == '\'')
news = skip_single_quoted (string, slen, ++sindex, SX_COMPLETE);
else
news = skip_double_quoted (string, slen, ++sindex, SX_COMPLETE);
translen = news - sindex - 1;
RESIZE_MALLOCED_BUFFER (ret, retind, translen + 3, retsize, 64);
ret[retind++] = c;
if (translen > 0)
{
strncpy (ret + retind, string + sindex, translen);
retind += translen;
}
if (news > sindex && string[news - 1] == c)
ret[retind++] = c;
sindex = news;
break;
case CTLESC:
RESIZE_MALLOCED_BUFFER (ret, retind, locale_mb_cur_max + 2, retsize, 64);
if (flags)
@@ -3907,14 +3925,30 @@ expand_string_dollar_quote (string, flags)
if (peekc != '\'')
#endif
{
RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 16);
RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 16);
ret[retind++] = c;
break;
}
if (string[sindex + 1] == '\0') /* don't bother */
{
RESIZE_MALLOCED_BUFFER (ret, retind, 3, retsize, 16);
ret[retind++] = c;
ret[retind++] = peekc;
sindex++;
break;
}
if (peekc == '\'')
{
/* We overload SX_COMPLETE below */
news = skip_single_quoted (string, slen, ++sindex, SX_COMPLETE);
/* Check for unclosed string and don't bother if so */
if (news > sindex && string[news] == '\0' && string[news-1] != peekc)
{
RESIZE_MALLOCED_BUFFER (ret, retind, 3, retsize, 16);
ret[retind++] = c;
ret[retind++] = peekc;
continue;
}
t = substring (string, sindex, news - 1);
trans = ansiexpand (t, 0, news-sindex-1, &translen);
free (t);
@@ -3926,6 +3960,15 @@ expand_string_dollar_quote (string, flags)
{
news = ++sindex;
t = string_extract_double_quoted (string, &news, SX_COMPLETE);
/* Check for unclosed string and don't bother if so */
if (news > sindex && string[news] == '\0' && string[news-1] != peekc)
{
RESIZE_MALLOCED_BUFFER (ret, retind, 3, retsize, 16);
ret[retind++] = c;
ret[retind++] = peekc;
free (t);
continue;
}
trans = locale_expand (t, 0, news-sindex, 0, &translen);
free (t);
if (singlequote_translations &&
@@ -6426,8 +6469,9 @@ read_comsub (fd, quoted, flags, rflag)
int *rflag;
{
char *istring, buf[COMSUB_PIPEBUF], *bufp;
int istring_index, c, tflag, skip_ctlesc, skip_ctlnul;
int c, tflag, skip_ctlesc, skip_ctlnul;
int mb_cur_max;
size_t istring_index;
size_t istring_size;
ssize_t bufn;
int nullbyte;
@@ -10553,7 +10597,7 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin
size_t istring_size;
/* Index into ISTRING. */
int istring_index;
size_t istring_index;
/* Temporary string storage. */
char *temp, *temp1;
+1 -1
View File
@@ -146,7 +146,7 @@ extern int do_word_assignment PARAMS((WORD_DESC *, int));
of space allocated to TARGET. SOURCE can be NULL, in which
case nothing happens. Gets rid of SOURCE by free ()ing it.
Returns TARGET in case the location has changed. */
extern char *sub_append_string PARAMS((char *, char *, int *, size_t *));
extern char *sub_append_string PARAMS((char *, char *, size_t *, size_t *));
/* Append the textual representation of NUMBER to TARGET.
INDEX and SIZE are as in SUB_APPEND_STRING. */
+1686
View File
File diff suppressed because it is too large Load Diff
+1853
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -32,6 +32,7 @@ i killed it
2: ok 2
2: ok 3
127
./jobs5.sub: line 71: declare: wpid: not found
child1 exit status 0
[1]+ Running sleep 20 &
./jobs7.sub: line 5: fg: no current jobs
+5
View File
@@ -64,3 +64,8 @@ unset wpid
jobs
wait -n -p wpid
echo $wpid $?
# make sure wait -p var does something useful without the -n option
jobs
wait -p wpid
declare -p wpid
+2 -3
View File
@@ -275,11 +275,10 @@ argv[2] = <b>
[ abc def ghi jkl / abc def ghi jkl ]
[ abc def ghi jkl ]
[ abc def ghi jkl / abc def ghi jkl / abc def ghi jkl ]
5: OK
5: notOK
OK
OK
5: 'not too
bad'
5: $'not\ttoo\nbad'
"A"
A
argv[1] = <"A">
+1
View File
@@ -78,6 +78,7 @@ unset or null 3
timeout 4: ok
abcde
abcde
one
two three four
one
+5
View File
@@ -59,3 +59,8 @@ echo abcde | {
read -e -t .0001 a <<<abcde
echo $a
set -o posix
read -t 0.1 a </dev/tty
echo $a