complete initial implementation of nofork command substitution (${ command; })

This commit is contained in:
Chet Ramey
2023-05-15 13:30:18 -04:00
parent c375f8f45f
commit e44e3d50de
42 changed files with 4387 additions and 3516 deletions
+194 -147
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, 20 April 2023).
Bash shell (version 5.2, 14 May 2023).
This is Edition 5.2, last updated 20 April 2023, of 'The GNU Bash
This is Edition 5.2, last updated 14 May 2023, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.2.
Copyright (C) 1988-2023 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, 20 April 2023). The Bash home page is
Bash shell (version 5.2, 14 May 2023). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.2, last updated 20 April 2023, of 'The GNU Bash
This is Edition 5.2, last updated 14 May 2023, of 'The GNU Bash
Reference Manual', for 'Bash', Version 5.2.
Bash contains features that appear in other popular shells, and some
@@ -419,8 +419,8 @@ File: bashref.info, Node: ANSI-C Quoting, Next: Locale Translation, Prev: Dou
3.1.2.4 ANSI-C Quoting
......................
Character sequences of the form $'STRING' are treated as a special kind
of single quotes. The sequence expands to STRING, with
Character sequences of the form '$'STRING'' are treated as a special
kind of single quotes. The sequence expands to STRING, with
backslash-escaped characters in STRING replaced as specified by the ANSI
C standard. Backslash escape sequences, if present, are decoded as
follows:
@@ -2240,11 +2240,11 @@ File: bashref.info, Node: Command Substitution, Next: Arithmetic Expansion, P
--------------------------
Command substitution allows the output of a command to replace the
command itself. Command substitution occurs when a command is enclosed
as follows:
command itself. The standard form of command substitution occurs when a
command is enclosed as follows:
$(COMMAND)
or
`COMMAND`
or (deprecated)
`COMMAND`.
Bash performs the expansion by executing COMMAND in a subshell
environment and replacing the command substitution with the standard
@@ -2253,17 +2253,64 @@ newlines are not deleted, but they may be removed during word splitting.
The command substitution '$(cat FILE)' can be replaced by the equivalent
but faster '$(< FILE)'.
When the old-style backquote form of substitution is used, backslash
retains its literal meaning except when followed by '$', '`', or '\'.
The first backquote not preceded by a backslash terminates the command
With the old-style backquote form of substitution, backslash retains
its literal meaning except when followed by '$', '`', or '\'. The first
backquote not preceded by a backslash terminates the command
substitution. When using the '$(COMMAND)' form, all characters between
the parentheses make up the command; none are treated specially.
There is an alternate form of command substitution:
${C COMMAND; }
which executes COMMAND in the current execution environment. This means
that side effects of COMMAND take effect immediately in the current
execution environment and persist in the current environment after the
command completes (e.g., the 'exit' builtin will exit the shell).
The character C following the open brace must be a space, tab,
newline, '(', or '|', and the close brace must be in a position where a
reserved word may appear (i.e., preceded by a command terminator such as
semicolon). Bash allows the close brace to be joined to the remaining
characters in the word without being followed by a shell metacharacter
as a reserved word would usually require.
This type of command substitution superficially resembles executing
an unnamed shell function: local variables are created as when a shell
function is executing, and the 'return' builtin forces COMMAND to
complete; however, the rest of the execution environment, including the
positional parameters, is shared with the caller.
If the first character following the open brace is a '(', COMMAND is
executed in a subshell, and COMMAND must be terminated by a ')'. This
is similar to the '(' compound command (*note Command Grouping::). If
the first character is a '|', the construct expands to the value of the
'REPLY' shell variable after COMMAND executes, without removing any
trailing newlines, and the standard output of COMMAND remains the same
as in the calling shell. Bash creates 'REPLY' as an initially-unset
local variable when COMMAND executes, and restores 'REPLY' to the value
it had before the command substitution after COMMAND completes, as with
any local variable.
For example, this construct expands to '12345', and leaves the shell
variable 'X' unchanged in the current execution environment:
${ local X=12345 ; echo $X; }
(not declaring 'X' as local would modify its value in the current
environment, as with normal shell function execution), while this
construct does not require any output to expand to '12345':
${| REPLY=12345; }
and restores 'REPLY' to the value it had before the command
substitution.
Command substitutions may be nested. To nest when using the
backquoted form, escape the inner backquotes with backslashes.
If the substitution appears within double quotes, word splitting and
filename expansion are not performed on the results.
If the substitution appears within double quotes, Bash does not
perform word splitting and filename expansion on the results.

File: bashref.info, Node: Arithmetic Expansion, Next: Process Substitution, Prev: Command Substitution, Up: Shell Expansions
@@ -12707,138 +12754,138 @@ D.5 Concept Index

Tag Table:
Node: Top891
Node: Introduction2805
Node: What is Bash?3021
Node: What is a shell?4135
Node: Definitions6673
Node: Basic Shell Features9624
Node: Shell Syntax10843
Node: Shell Operation11869
Node: Quoting13162
Node: Escape Character14466
Node: Single Quotes14951
Node: Double Quotes15299
Node: ANSI-C Quoting16577
Node: Locale Translation17887
Node: Creating Internationalized Scripts19198
Node: Comments23315
Node: Shell Commands23933
Node: Reserved Words24871
Node: Simple Commands25627
Node: Pipelines26281
Node: Lists29280
Node: Compound Commands31075
Node: Looping Constructs32087
Node: Conditional Constructs34582
Node: Command Grouping49070
Node: Coprocesses50548
Node: GNU Parallel53211
Node: Shell Functions54128
Node: Shell Parameters62013
Node: Positional Parameters66401
Node: Special Parameters67303
Node: Shell Expansions70517
Node: Brace Expansion72644
Node: Tilde Expansion75378
Node: Shell Parameter Expansion77999
Node: Command Substitution96401
Node: Arithmetic Expansion97756
Node: Process Substitution98724
Node: Word Splitting99844
Node: Filename Expansion101892
Node: Pattern Matching104825
Node: Quote Removal109827
Node: Redirections110122
Node: Executing Commands119815
Node: Simple Command Expansion120485
Node: Command Search and Execution122595
Node: Command Execution Environment124982
Node: Environment128017
Node: Exit Status129680
Node: Signals131464
Node: Shell Scripts134913
Node: Shell Builtin Commands137940
Node: Bourne Shell Builtins139978
Node: Bash Builtins162177
Node: Modifying Shell Behavior194176
Node: The Set Builtin194521
Node: The Shopt Builtin205119
Node: Special Builtins221031
Node: Shell Variables222010
Node: Bourne Shell Variables222447
Node: Bash Variables224551
Node: Bash Features258616
Node: Invoking Bash259629
Node: Bash Startup Files265642
Node: Interactive Shells270773
Node: What is an Interactive Shell?271184
Node: Is this Shell Interactive?271833
Node: Interactive Shell Behavior272648
Node: Bash Conditional Expressions276277
Node: Shell Arithmetic280919
Node: Aliases283880
Node: Arrays286774
Node: The Directory Stack293337
Node: Directory Stack Builtins294121
Node: Controlling the Prompt298381
Node: The Restricted Shell301346
Node: Bash POSIX Mode303956
Node: Shell Compatibility Mode319749
Node: Job Control327993
Node: Job Control Basics328453
Node: Job Control Builtins333455
Node: Job Control Variables339250
Node: Command Line Editing340406
Node: Introduction and Notation342077
Node: Readline Interaction343700
Node: Readline Bare Essentials344891
Node: Readline Movement Commands346680
Node: Readline Killing Commands347640
Node: Readline Arguments349561
Node: Searching350605
Node: Readline Init File352791
Node: Readline Init File Syntax354052
Node: Conditional Init Constructs377843
Node: Sample Init File382039
Node: Bindable Readline Commands385163
Node: Commands For Moving386367
Node: Commands For History388418
Node: Commands For Text393412
Node: Commands For Killing397061
Node: Numeric Arguments400094
Node: Commands For Completion401233
Node: Keyboard Macros405424
Node: Miscellaneous Commands406112
Node: Readline vi Mode412150
Node: Programmable Completion413057
Node: Programmable Completion Builtins420837
Node: A Programmable Completion Example431825
Node: Using History Interactively437073
Node: Bash History Facilities437757
Node: Bash History Builtins440762
Node: History Interaction445786
Node: Event Designators449406
Node: Word Designators450760
Node: Modifiers452520
Node: Installing Bash454328
Node: Basic Installation455465
Node: Compilers and Options459187
Node: Compiling For Multiple Architectures459928
Node: Installation Names461620
Node: Specifying the System Type463729
Node: Sharing Defaults464446
Node: Operation Controls465119
Node: Optional Features466077
Node: Reporting Bugs477296
Node: Major Differences From The Bourne Shell478630
Node: GNU Free Documentation License495479
Node: Indexes520656
Node: Builtin Index521110
Node: Reserved Word Index527937
Node: Variable Index530385
Node: Function Index547373
Node: Concept Index561157
Node: Top887
Node: Introduction2797
Node: What is Bash?3013
Node: What is a shell?4127
Node: Definitions6665
Node: Basic Shell Features9616
Node: Shell Syntax10835
Node: Shell Operation11861
Node: Quoting13154
Node: Escape Character14458
Node: Single Quotes14943
Node: Double Quotes15291
Node: ANSI-C Quoting16569
Node: Locale Translation17881
Node: Creating Internationalized Scripts19192
Node: Comments23309
Node: Shell Commands23927
Node: Reserved Words24865
Node: Simple Commands25621
Node: Pipelines26275
Node: Lists29274
Node: Compound Commands31069
Node: Looping Constructs32081
Node: Conditional Constructs34576
Node: Command Grouping49064
Node: Coprocesses50542
Node: GNU Parallel53205
Node: Shell Functions54122
Node: Shell Parameters62007
Node: Positional Parameters66395
Node: Special Parameters67297
Node: Shell Expansions70511
Node: Brace Expansion72638
Node: Tilde Expansion75372
Node: Shell Parameter Expansion77993
Node: Command Substitution96395
Node: Arithmetic Expansion99987
Node: Process Substitution100955
Node: Word Splitting102075
Node: Filename Expansion104123
Node: Pattern Matching107056
Node: Quote Removal112058
Node: Redirections112353
Node: Executing Commands122046
Node: Simple Command Expansion122716
Node: Command Search and Execution124826
Node: Command Execution Environment127213
Node: Environment130248
Node: Exit Status131911
Node: Signals133695
Node: Shell Scripts137144
Node: Shell Builtin Commands140171
Node: Bourne Shell Builtins142209
Node: Bash Builtins164408
Node: Modifying Shell Behavior196407
Node: The Set Builtin196752
Node: The Shopt Builtin207350
Node: Special Builtins223262
Node: Shell Variables224241
Node: Bourne Shell Variables224678
Node: Bash Variables226782
Node: Bash Features260847
Node: Invoking Bash261860
Node: Bash Startup Files267873
Node: Interactive Shells273004
Node: What is an Interactive Shell?273415
Node: Is this Shell Interactive?274064
Node: Interactive Shell Behavior274879
Node: Bash Conditional Expressions278508
Node: Shell Arithmetic283150
Node: Aliases286111
Node: Arrays289005
Node: The Directory Stack295568
Node: Directory Stack Builtins296352
Node: Controlling the Prompt300612
Node: The Restricted Shell303577
Node: Bash POSIX Mode306187
Node: Shell Compatibility Mode321980
Node: Job Control330224
Node: Job Control Basics330684
Node: Job Control Builtins335686
Node: Job Control Variables341481
Node: Command Line Editing342637
Node: Introduction and Notation344308
Node: Readline Interaction345931
Node: Readline Bare Essentials347122
Node: Readline Movement Commands348911
Node: Readline Killing Commands349871
Node: Readline Arguments351792
Node: Searching352836
Node: Readline Init File355022
Node: Readline Init File Syntax356283
Node: Conditional Init Constructs380074
Node: Sample Init File384270
Node: Bindable Readline Commands387394
Node: Commands For Moving388598
Node: Commands For History390649
Node: Commands For Text395643
Node: Commands For Killing399292
Node: Numeric Arguments402325
Node: Commands For Completion403464
Node: Keyboard Macros407655
Node: Miscellaneous Commands408343
Node: Readline vi Mode414381
Node: Programmable Completion415288
Node: Programmable Completion Builtins423068
Node: A Programmable Completion Example434056
Node: Using History Interactively439304
Node: Bash History Facilities439988
Node: Bash History Builtins442993
Node: History Interaction448017
Node: Event Designators451637
Node: Word Designators452991
Node: Modifiers454751
Node: Installing Bash456559
Node: Basic Installation457696
Node: Compilers and Options461418
Node: Compiling For Multiple Architectures462159
Node: Installation Names463851
Node: Specifying the System Type465960
Node: Sharing Defaults466677
Node: Operation Controls467350
Node: Optional Features468308
Node: Reporting Bugs479527
Node: Major Differences From The Bourne Shell480861
Node: GNU Free Documentation License497710
Node: Indexes522887
Node: Builtin Index523341
Node: Reserved Word Index530168
Node: Variable Index532616
Node: Function Index549604
Node: Concept Index563388

End Tag Table