mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-30 00:49:57 +02:00
minor documentation update on SIGINT handling
This commit is contained in:
@@ -2310,3 +2310,17 @@ doc/bashref.texi
|
||||
|
||||
doc/{mkposix,mkinst,mkrbash},doc/Makefile.in
|
||||
- changes to allow scripts to be run outside the source directory
|
||||
|
||||
10/18
|
||||
-----
|
||||
subst.c
|
||||
- patsub_replacement: controls whether pattern substitution expands `&'
|
||||
in the replacement string. Initialized to 1 by default
|
||||
|
||||
10/19
|
||||
-----
|
||||
doc/{bash.1,bashref.texi}
|
||||
- document bash's WCE SIGINT behavior when job control is not enabled
|
||||
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
|
||||
|
||||
+61
-2
@@ -5,12 +5,12 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet.ramey@case.edu
|
||||
.\"
|
||||
.\" Last Change: Fri Oct 8 14:10:30 EDT 2021
|
||||
.\" Last Change: Tue Oct 19 11:34:57 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 8" "GNU Bash 5.1"
|
||||
.TH BASH 1 "2021 October 19" "GNU Bash 5.1"
|
||||
.\"
|
||||
.\" There's some problem with having a `@'
|
||||
.\" in a tagged paragraph with the BSD man macros.
|
||||
@@ -5214,6 +5214,63 @@ When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP
|
||||
builtin, the reception of a signal for which a trap has been set will
|
||||
cause the \fBwait\fP builtin to return immediately with an exit status
|
||||
greater than 128, immediately after which the trap is executed.
|
||||
.PP
|
||||
When job control is not enabled, and \fBbash\fP is waiting for a foreground
|
||||
command to complete, the shell receives keyboard-generated signals
|
||||
such as
|
||||
.SM
|
||||
.B SIGINT
|
||||
(usually generated by \fB^C\fP) 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 \fB^C\fP sends
|
||||
.SM
|
||||
.B SIGINT
|
||||
to all processes in that process group.
|
||||
.PP
|
||||
When \fBbash\fP is running without job control enabled and receives
|
||||
.SM
|
||||
.B SIGINT
|
||||
while waiting for a foreground command, it waits until that foreground
|
||||
command terminates and then decides what to do about the
|
||||
.SM
|
||||
.BR SIGINT :
|
||||
.IP 1.
|
||||
If the command terminates due to the
|
||||
.SM
|
||||
.BR SIGINT ,
|
||||
\fBbash\fP concludes
|
||||
that the user meant to end the entire script, and acts on the
|
||||
.SM
|
||||
.B SIGINT
|
||||
(e.g., by running a
|
||||
.SM
|
||||
.B SIGINT
|
||||
trap or exiting itself);
|
||||
.IP 2.
|
||||
If the command does not terminate due to
|
||||
.SM
|
||||
.BR SIGINT ,
|
||||
the program handled the
|
||||
.SM
|
||||
.B SIGINT
|
||||
itself and did not treat it as a fatal signal.
|
||||
In that case, \fBbash\fP does not treat
|
||||
.SM
|
||||
.B SIGINT
|
||||
as a fatal signal, either, instead assuming that the
|
||||
.SM
|
||||
.B SIGINT
|
||||
was used as part of the program's normal operation
|
||||
(e.g., emacs uses it to abort editing
|
||||
commands) or deliberately discarded.
|
||||
However, \fBbash\fP will run any
|
||||
trap set on
|
||||
.SM
|
||||
.BR SIGINT ,
|
||||
as it does with any other trapped signal it
|
||||
receives while it is waiting for the foreground command to
|
||||
complete, for compatibility.
|
||||
.SH "JOB CONTROL"
|
||||
.I Job control
|
||||
refers to the ability to selectively stop (\fIsuspend\fP)
|
||||
@@ -10131,6 +10188,8 @@ history is enabled, as described above under
|
||||
.B compat43
|
||||
.TP 8
|
||||
.B compat44
|
||||
.TP 8
|
||||
.B compat50
|
||||
.PD
|
||||
These control aspects of the shell's compatibility mode
|
||||
(see
|
||||
|
||||
@@ -3549,6 +3549,37 @@ which a trap has been set will cause the @code{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 @code{SIGINT} (usually generated by @samp{^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 @samp{^C} sends @code{SIGINT} to all processes
|
||||
in that process group.
|
||||
See @ref{Job Control}, for a more in-depth discussion of process groups.
|
||||
|
||||
When Bash is running without job control enabled and receives @code{SIGINT}
|
||||
while waiting for a foreground command, it waits until that foreground
|
||||
command terminates and then decides what to do about the @code{SIGINT}:
|
||||
|
||||
@enumerate
|
||||
@item
|
||||
If the command terminates due to the @code{SIGINT}, Bash concludes
|
||||
that the user meant to end the entire script, and acts on the
|
||||
@code{SIGINT} (e.g., by running a @code{SIGINT} trap or exiting itself);
|
||||
|
||||
@item
|
||||
If the pipeline does not terminate due to @code{SIGINT}, the program
|
||||
handled the @code{SIGINT} itself and did not treat it as a fatal signal.
|
||||
In that case, Bash does not treat @code{SIGINT} as a fatal signal,
|
||||
either, instead assuming that the @code{SIGINT} was used as part of the
|
||||
program's normal operation (e.g., @command{emacs} uses it to abort editing
|
||||
commands) or deliberately discarded. However, Bash will run any
|
||||
trap set on @code{SIGINT}, as it does with any other trapped signal it
|
||||
receives while it is waiting for the foreground command to
|
||||
complete, for compatibility.
|
||||
@end enumerate
|
||||
|
||||
@node Shell Scripts
|
||||
@section Shell Scripts
|
||||
@cindex shell script
|
||||
|
||||
+2
-2
@@ -2,10 +2,10 @@
|
||||
Copyright (C) 1988-2021 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set LASTCHANGE Fri Oct 15 15:24:19 EDT 2021
|
||||
@set LASTCHANGE Tue Oct 19 11:34:34 EDT 2021
|
||||
|
||||
@set EDITION 5.1
|
||||
@set VERSION 5.1
|
||||
|
||||
@set UPDATED 15 October 2021
|
||||
@set UPDATED 19 October 2021
|
||||
@set UPDATED-MONTH October 2021
|
||||
|
||||
@@ -187,6 +187,10 @@ int allow_null_glob_expansion;
|
||||
/* Non-zero means to throw an error when globbing fails to match anything. */
|
||||
int fail_glob_expansion;
|
||||
|
||||
/* If non-zero, perform `&' substitution on the replacement string in the
|
||||
pattern substitution word expansion. */
|
||||
int patsub_replacement = 1;
|
||||
|
||||
/* Extern functions and variables from different files. */
|
||||
extern struct fd_bitmap *current_fds_to_close;
|
||||
extern int wordexp_only;
|
||||
@@ -8680,7 +8684,7 @@ parameter_brace_patsub (varname, value, ind, patsub, quoted, pflags, flags)
|
||||
consistently. The replacement string already undergoes quote removal
|
||||
above, so users need to make sure any desired backslash makes it
|
||||
through that. */
|
||||
if (rep && *rep && shouldexp_replacement (rep))
|
||||
if (patsub_replacement && rep && *rep && shouldexp_replacement (rep))
|
||||
mflags |= MATCH_EXPREP;
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
BUILD_DIR=/usr/local/build/bash/bash-current
|
||||
BUILD_DIR=/usr/local/build/chet/bash/bash-current
|
||||
THIS_SH=$BUILD_DIR/bash
|
||||
PATH=$PATH:$BUILD_DIR
|
||||
|
||||
|
||||
Reference in New Issue
Block a user