new `patsub_replacement' shell option

This commit is contained in:
Chet Ramey
2021-10-25 11:56:15 -04:00
parent 2c8ac78cbb
commit c813e24652
9 changed files with 869 additions and 771 deletions
+10
View File
@@ -2324,3 +2324,13 @@ doc/{bash.1,bashref.texi}
and the shell receives a SIGINT while waiting for the foreground
command to complete. Added at Red Hat's request. A complete
discussion is at https://www.cons.org/cracauer/sigint.html
10/25
-----
builtins/shopt.def
- patsub_replacement: new shell option, exposes patsub_replacement
variable controlling whether pattern substitution expands `&' in
the replacement string. Still enabled by default.
doc/{bash.1,bashref.texi}
- patsub_replacement: document new shopt option
+3
View File
@@ -95,6 +95,7 @@ extern int localvar_inherit;
extern int localvar_unset;
extern int varassign_redir_autoclose;
extern int singlequote_translations;
extern int patsub_replacement;
#if defined (EXTENDED_GLOB)
extern int extended_glob;
@@ -237,6 +238,7 @@ static struct {
{ "nocasematch", &match_ignore_case, (shopt_set_func_t *)NULL },
{ "noexpand_translation", &singlequote_translations, (shopt_set_func_t *)NULL },
{ "nullglob", &allow_null_glob_expansion, (shopt_set_func_t *)NULL },
{ "patsub_replacement", &patsub_replacement, (shopt_set_func_t *)NULL },
#if defined (PROGRAMMABLE_COMPLETION)
{ "progcomp", &prog_completion_enabled, (shopt_set_func_t *)NULL },
# if defined (ALIAS)
@@ -363,6 +365,7 @@ reset_shopt_options ()
source_uses_path = promptvars = 1;
varassign_redir_autoclose = 0;
singlequote_translations = 0;
patsub_replacement = 1;
#if defined (JOB_CONTROL)
check_jobs_at_exit = 0;
+695 -662
View File
File diff suppressed because it is too large Load Diff
+11 -3
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Tue Oct 19 11:34:57 EDT 2021
.\" Last Change: Mon Oct 25 11:23:10 EDT 2021
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2021 October 19" "GNU Bash 5.1"
.TH BASH 1 "2021 October 25" "GNU Bash 5.1"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -3367,7 +3367,8 @@ matches of \fIpattern\fP are deleted.
If \fIstring\fP is null,
matches of \fIpattern\fP are deleted
and the \fB/\fP following \fIpattern\fP may be omitted.
Any unquoted instances of \fB&\fP in \fIstring\fP are replaced with the
If the \fBpatsub_replacement\fP shell option is enabled using \fBshopt\fP,
any unquoted instances of \fB&\fP in \fIstring\fP are replaced with the
matching portion of \fIpattern\fP.
Backslash is used to quote \fB&\fP in \fIstring\fP; the backslash is removed
in order to permit a literal \fB&\fP in the replacement string.
@@ -10481,6 +10482,13 @@ files (see
above)
to expand to a null string, rather than themselves.
.TP 8
.B patsub_replacement
If set, \fBbash\fP
expands occurrences of \fB&\fP in the replacement string of pattern
substitution to the text matched by the pattern, as described
under \fBParameter Expansion\fP above.
This option is enabled by default.
.TP 8
.B progcomp
If set, the programmable completion facilities (see
\fBProgrammable Completion\fP above) are enabled.
+136 -102
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.1, 15 October 2021).
Bash shell (version 5.1, 25 October 2021).
This is Edition 5.1, last updated 15 October 2021, of 'The GNU Bash
This is Edition 5.1, last updated 25 October 2021, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.1.
Copyright (C) 1988-2021 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.1, 15 October 2021). The Bash home page is
Bash shell (version 5.1, 25 October 2021). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.1, last updated 15 October 2021, of 'The GNU Bash
This is Edition 5.1, last updated 25 October 2021, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.1.
Bash contains features that appear in other popular shells, and some
@@ -2076,7 +2076,8 @@ omitted, the operator tests only for existence.
of PATTERN are deleted and the '/' following PATTERN may be
omitted.
Any unquoted instances of '&' in STRING are replaced with the
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
@@ -3022,6 +3023,33 @@ the 'wait' builtin, the reception of a signal for which a trap has been
set will cause the 'wait' builtin to return immediately with an exit
status greater than 128, immediately after which the trap is executed.
When job control is not enabled, and Bash is waiting for a foreground
command to complete, the shell receives keyboard-generated signals such
as 'SIGINT' (usually generated by '^C') that users commonly intend to
send to that command. This happens because the shell and the command
are in the same process group as the terminal, and '^C' sends 'SIGINT'
to all processes in that process group. See *note Job Control::, for a
more in-depth discussion of process groups.
When Bash is running without job control enabled and receives
'SIGINT' while waiting for a foreground command, it waits until that
foreground command terminates and then decides what to do about the
'SIGINT':
1. If the command terminates due to the 'SIGINT', Bash concludes that
the user meant to end the entire script, and acts on the 'SIGINT'
(e.g., by running a 'SIGINT' trap or exiting itself);
2. If the pipeline does not terminate due to 'SIGINT', the program
handled the 'SIGINT' itself and did not treat it as a fatal signal.
In that case, Bash does not treat 'SIGINT' as a fatal signal,
either, instead assuming that the 'SIGINT' was used as part of the
program's normal operation (e.g., 'emacs' uses it to abort editing
commands) or deliberately discarded. However, Bash will run any
trap set on 'SIGINT', as it does with any other trapped signal it
receives while it is waiting for the foreground command to
complete, for compatibility.

File: bashref.info, Node: Shell Scripts, Prev: Executing Commands, Up: Basic Shell Features
@@ -4932,6 +4960,12 @@ This builtin allows you to change additional shell optional behavior.
If set, Bash allows filename patterns which match no files to
expand to a null string, rather than themselves.
'patsub_replacement'
If set, Bash expands occurrences of '&' in the replacement
string of pattern substitution to the text matched by the
pattern, as described above (*note Shell Parameter
Expansion::). This option is enabled by default.
'progcomp'
If set, the programmable completion facilities (*note
Programmable Completion::) are enabled. This option is
@@ -12373,103 +12407,103 @@ Node: Shell Expansions69747
Node: Brace Expansion71874
Node: Tilde Expansion74608
Node: Shell Parameter Expansion77229
Node: Command Substitution95023
Node: Arithmetic Expansion96378
Node: Process Substitution97346
Node: Word Splitting98466
Node: Filename Expansion100410
Node: Pattern Matching103010
Node: Quote Removal107618
Node: Redirections107913
Node: Executing Commands117573
Node: Simple Command Expansion118243
Node: Command Search and Execution120353
Node: Command Execution Environment122731
Node: Environment125766
Node: Exit Status127429
Node: Signals129213
Node: Shell Scripts131180
Node: Shell Builtin Commands134207
Node: Bourne Shell Builtins136245
Node: Bash Builtins157706
Node: Modifying Shell Behavior188523
Node: The Set Builtin188868
Node: The Shopt Builtin199281
Node: Special Builtins214710
Node: Shell Variables215689
Node: Bourne Shell Variables216126
Node: Bash Variables218230
Node: Bash Features251045
Node: Invoking Bash252058
Node: Bash Startup Files258071
Node: Interactive Shells263174
Node: What is an Interactive Shell?263584
Node: Is this Shell Interactive?264233
Node: Interactive Shell Behavior265048
Node: Bash Conditional Expressions268561
Node: Shell Arithmetic273203
Node: Aliases276147
Node: Arrays278760
Node: The Directory Stack284769
Node: Directory Stack Builtins285553
Node: Controlling the Prompt289813
Node: The Restricted Shell292778
Node: Bash POSIX Mode295375
Node: Shell Compatibility Mode306648
Node: Job Control313304
Node: Job Control Basics313764
Node: Job Control Builtins318766
Node: Job Control Variables324166
Node: Command Line Editing325322
Node: Introduction and Notation326993
Node: Readline Interaction328616
Node: Readline Bare Essentials329807
Node: Readline Movement Commands331590
Node: Readline Killing Commands332550
Node: Readline Arguments334468
Node: Searching335512
Node: Readline Init File337698
Node: Readline Init File Syntax338959
Node: Conditional Init Constructs360239
Node: Sample Init File364435
Node: Bindable Readline Commands367559
Node: Commands For Moving368763
Node: Commands For History370814
Node: Commands For Text375808
Node: Commands For Killing379457
Node: Numeric Arguments382490
Node: Commands For Completion383629
Node: Keyboard Macros387820
Node: Miscellaneous Commands388507
Node: Readline vi Mode394446
Node: Programmable Completion395353
Node: Programmable Completion Builtins403133
Node: A Programmable Completion Example413828
Node: Using History Interactively419075
Node: Bash History Facilities419759
Node: Bash History Builtins422764
Node: History Interaction427772
Node: Event Designators431392
Node: Word Designators432746
Node: Modifiers434506
Node: Installing Bash436317
Node: Basic Installation437454
Node: Compilers and Options441176
Node: Compiling For Multiple Architectures441917
Node: Installation Names443610
Node: Specifying the System Type445719
Node: Sharing Defaults446435
Node: Operation Controls447108
Node: Optional Features448066
Node: Reporting Bugs459159
Node: Major Differences From The Bourne Shell460434
Node: GNU Free Documentation License477284
Node: Indexes502461
Node: Builtin Index502915
Node: Reserved Word Index509742
Node: Variable Index512190
Node: Function Index528682
Node: Concept Index542466
Node: Command Substitution95095
Node: Arithmetic Expansion96450
Node: Process Substitution97418
Node: Word Splitting98538
Node: Filename Expansion100482
Node: Pattern Matching103082
Node: Quote Removal107690
Node: Redirections107985
Node: Executing Commands117645
Node: Simple Command Expansion118315
Node: Command Search and Execution120425
Node: Command Execution Environment122803
Node: Environment125838
Node: Exit Status127501
Node: Signals129285
Node: Shell Scripts132734
Node: Shell Builtin Commands135761
Node: Bourne Shell Builtins137799
Node: Bash Builtins159260
Node: Modifying Shell Behavior190077
Node: The Set Builtin190422
Node: The Shopt Builtin200835
Node: Special Builtins216549
Node: Shell Variables217528
Node: Bourne Shell Variables217965
Node: Bash Variables220069
Node: Bash Features252884
Node: Invoking Bash253897
Node: Bash Startup Files259910
Node: Interactive Shells265013
Node: What is an Interactive Shell?265423
Node: Is this Shell Interactive?266072
Node: Interactive Shell Behavior266887
Node: Bash Conditional Expressions270400
Node: Shell Arithmetic275042
Node: Aliases277986
Node: Arrays280599
Node: The Directory Stack286608
Node: Directory Stack Builtins287392
Node: Controlling the Prompt291652
Node: The Restricted Shell294617
Node: Bash POSIX Mode297214
Node: Shell Compatibility Mode308487
Node: Job Control315143
Node: Job Control Basics315603
Node: Job Control Builtins320605
Node: Job Control Variables326005
Node: Command Line Editing327161
Node: Introduction and Notation328832
Node: Readline Interaction330455
Node: Readline Bare Essentials331646
Node: Readline Movement Commands333429
Node: Readline Killing Commands334389
Node: Readline Arguments336307
Node: Searching337351
Node: Readline Init File339537
Node: Readline Init File Syntax340798
Node: Conditional Init Constructs362078
Node: Sample Init File366274
Node: Bindable Readline Commands369398
Node: Commands For Moving370602
Node: Commands For History372653
Node: Commands For Text377647
Node: Commands For Killing381296
Node: Numeric Arguments384329
Node: Commands For Completion385468
Node: Keyboard Macros389659
Node: Miscellaneous Commands390346
Node: Readline vi Mode396285
Node: Programmable Completion397192
Node: Programmable Completion Builtins404972
Node: A Programmable Completion Example415667
Node: Using History Interactively420914
Node: Bash History Facilities421598
Node: Bash History Builtins424603
Node: History Interaction429611
Node: Event Designators433231
Node: Word Designators434585
Node: Modifiers436345
Node: Installing Bash438156
Node: Basic Installation439293
Node: Compilers and Options443015
Node: Compiling For Multiple Architectures443756
Node: Installation Names445449
Node: Specifying the System Type447558
Node: Sharing Defaults448274
Node: Operation Controls448947
Node: Optional Features449905
Node: Reporting Bugs460998
Node: Major Differences From The Bourne Shell462273
Node: GNU Free Documentation License479123
Node: Indexes504300
Node: Builtin Index504754
Node: Reserved Word Index511581
Node: Variable Index514029
Node: Function Index530521
Node: Concept Index544305

End Tag Table
+9 -1
View File
@@ -2440,7 +2440,8 @@ If @var{string} is null,
matches of @var{pattern} are deleted
and the @samp{/} following @var{pattern} may be omitted.
Any unquoted instances of @samp{&} in @var{string} are replaced with the
If the @code{patsub_replacement} shell option is enabled using @code{shopt},
any unquoted instances of @samp{&} in @var{string} are replaced with the
matching portion of @var{pattern}.
This is intended to duplicate a common @code{sed} idiom.
Backslash is used to quote @samp{&} in @var{string}; the backslash is removed
@@ -5786,6 +5787,13 @@ If the string is not translated, this has no effect.
If set, Bash allows filename patterns which match no
files to expand to a null string, rather than themselves.
@item patsub_replacement
If set, Bash
expands occurrences of @samp{&} in the replacement string of pattern
substitution to the text matched by the pattern, as described
above (@pxref{Shell Parameter Expansion}).
This option is enabled by default.
@item progcomp
If set, the programmable completion facilities
(@pxref{Programmable Completion}) are enabled.
+2 -2
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2021 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Tue Oct 19 11:34:34 EDT 2021
@set LASTCHANGE Mon Oct 25 11:21:24 EDT 2021
@set EDITION 5.1
@set VERSION 5.1
@set UPDATED 19 October 2021
@set UPDATED 25 October 2021
@set UPDATED-MONTH October 2021
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
BUILD_DIR=/usr/local/build/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+2
View File
@@ -48,6 +48,7 @@ shopt -u nocaseglob
shopt -u nocasematch
shopt -u noexpand_translation
shopt -u nullglob
shopt -s patsub_replacement
shopt -s progcomp
shopt -u progcomp_alias
shopt -s promptvars
@@ -70,6 +71,7 @@ shopt -s force_fignore
shopt -s globasciiranges
shopt -s hostcomplete
shopt -s interactive_comments
shopt -s patsub_replacement
shopt -s progcomp
shopt -s promptvars
shopt -s sourcepath