mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-27 07:43:07 +02:00
new option to auto-close varassign redirs; fixed some new parser error reporting issues
This commit is contained in:
@@ -10603,3 +10603,44 @@ builtins/evalstring.c
|
||||
command, rewind the input string here before returning, instead of
|
||||
guessing where to rewind it in the caller
|
||||
|
||||
6/22
|
||||
----
|
||||
|
||||
redir.c
|
||||
- do_redirection_internal: if VARASSIGN_REDIR_AUTOCLOSE is non-zero,
|
||||
add a redirect to automatically close {var}<fn and other styles of
|
||||
varassign redirection. It's zero by default
|
||||
|
||||
builtins/shopt.def
|
||||
- varredir_close: new shell option, mirrors the value of
|
||||
varassign_redir_autoclose. Suggested multiple times by multiple
|
||||
people
|
||||
|
||||
doc/{bash.1,bashref.texi}
|
||||
- varredir_close: document new shell option (the name is tentative)
|
||||
|
||||
6/24
|
||||
----
|
||||
|
||||
parse.y
|
||||
- yylex: if read_token returns a value < 0, return YYerror to the
|
||||
parser
|
||||
- parse_comsub: if the current_token is not shell_eof_token when
|
||||
yyparse returns, return an error to read_token_word instead of
|
||||
trying to keep parsing. Fixes interactive-only (?) bug reported by
|
||||
Koichi Murase <myoga.murase@gmail.com>
|
||||
|
||||
parser.h
|
||||
- PST_NOERROR: don't print error messages in yyerror(), just reset
|
||||
the parser and return
|
||||
|
||||
parse.y
|
||||
- yyerror: if parser_state & PST_NOERROR, don't print an error message
|
||||
- xparse_dolparen: if the flags includes SX_COMPLETE, add PST_NOERROR
|
||||
to parser_state, to inhibit error messages. Fixes bug with adding
|
||||
lines with incomplete command substitutions to the history list
|
||||
reported by Koichi Murase <myoga.murase@gmail.com>
|
||||
|
||||
subst.c
|
||||
- skip_matched_pair: make sure to pass the SX_COMPLETE flag to
|
||||
extract_delimited_string
|
||||
|
||||
@@ -1509,6 +1509,7 @@ tests/vredir4.sub f
|
||||
tests/vredir5.sub f
|
||||
tests/vredir6.sub f
|
||||
tests/vredir7.sub f
|
||||
tests/vredir8.sub f
|
||||
tests/misc/dev-tcp.tests f
|
||||
tests/misc/perf-script f
|
||||
tests/misc/perftest f
|
||||
|
||||
@@ -93,6 +93,7 @@ extern int lastpipe_opt;
|
||||
extern int inherit_errexit;
|
||||
extern int localvar_inherit;
|
||||
extern int localvar_unset;
|
||||
extern int varassign_redir_autoclose;
|
||||
|
||||
#if defined (EXTENDED_GLOB)
|
||||
extern int extended_glob;
|
||||
@@ -249,6 +250,7 @@ static struct {
|
||||
#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT)
|
||||
{ "syslog_history", &syslog_history, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
{ "varredir_close", &varassign_redir_autoclose, (shopt_set_func_t *)NULL },
|
||||
{ "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL },
|
||||
{ (char *)0, (int *)0, (shopt_set_func_t *)NULL }
|
||||
};
|
||||
@@ -357,6 +359,7 @@ reset_shopt_options ()
|
||||
glob_ignore_case = match_ignore_case = 0;
|
||||
print_shift_error = 0;
|
||||
source_uses_path = promptvars = 1;
|
||||
varassign_redir_autoclose = 0;
|
||||
|
||||
#if defined (JOB_CONTROL)
|
||||
check_jobs_at_exit = 0;
|
||||
|
||||
+2211
-2196
File diff suppressed because it is too large
Load Diff
+25
-16
@@ -589,12 +589,12 @@ The
|
||||
variable may be used to specify the format of
|
||||
the time information.
|
||||
.PP
|
||||
Each command in a pipeline is executed as a separate process (i.e., in a
|
||||
subshell).
|
||||
Each command in a pipeline is executed in a \fIsubshell\fP, which is a
|
||||
separate process.
|
||||
See
|
||||
.SM
|
||||
\fBCOMMAND EXECUTION ENVIRONMENT\fP
|
||||
for a description of a subshell environment.
|
||||
for a description of subshells and a subshell environment.
|
||||
If the \fBlastpipe\fP option is enabled using the \fBshopt\fP builtin
|
||||
(see the description of \fBshopt\fP below),
|
||||
the last element of a pipeline may be run by the shell process
|
||||
@@ -673,10 +673,10 @@ the rest of the command by one or more newlines, and may be followed by a
|
||||
newline in place of a semicolon.
|
||||
.TP
|
||||
(\fIlist\fP)
|
||||
\fIlist\fP is executed in a subshell environment (see
|
||||
\fIlist\fP is executed in a subshell (see
|
||||
.SM
|
||||
\fBCOMMAND EXECUTION ENVIRONMENT\fP
|
||||
below).
|
||||
below for a description of a subshell environment).
|
||||
Variable assignments and builtin
|
||||
commands that affect the shell's environment do not remain in effect
|
||||
after the command completes. The return status is the exit status of
|
||||
@@ -1278,10 +1278,7 @@ is evaluated as an arithmetic expression even if the $((...)) expansion is
|
||||
not used (see
|
||||
.B "Arithmetic Expansion"
|
||||
below).
|
||||
Word splitting is not performed, with the exception
|
||||
of \fB"$@"\fP as explained below under
|
||||
.BR "Special Parameters" .
|
||||
Pathname expansion is not performed.
|
||||
Word splitting and pathname expansion are not performed.
|
||||
Assignment statements may also appear as arguments to the
|
||||
.BR alias ,
|
||||
.BR declare ,
|
||||
@@ -1435,7 +1432,7 @@ builtin command, or those set by the shell itself
|
||||
option).
|
||||
.TP
|
||||
.B $
|
||||
Expands to the process ID of the shell. In a () subshell, it
|
||||
Expands to the process ID of the shell. In a subshell, it
|
||||
expands to the process ID of the current shell, not the
|
||||
subshell.
|
||||
.TP
|
||||
@@ -3950,7 +3947,8 @@ by {\fIvarname\fP}, the value of \fIvarname\fP defines the file
|
||||
descriptor to close.
|
||||
If {\fIvarname\fP} is supplied, the redirection persists beyond
|
||||
the scope of the command, allowing the shell programmer to manage
|
||||
the file descriptor himself.
|
||||
the file descriptor's lifetime manually.
|
||||
The \fBvarredir_close\fP shell option manages this behavior.
|
||||
.PP
|
||||
In the following descriptions, if the file descriptor number is
|
||||
omitted, and the first character of the redirection operator is
|
||||
@@ -4503,7 +4501,8 @@ or
|
||||
will list the function names only
|
||||
(and optionally the source file and line number, if the \fBextdebug\fP
|
||||
shell option is enabled).
|
||||
Functions may be exported so that subshells
|
||||
Functions may be exported so that child shell processes
|
||||
(those created when executing a separate shell invocation)
|
||||
automatically have them defined with the
|
||||
.B \-f
|
||||
option to the
|
||||
@@ -4892,8 +4891,9 @@ to the command are set to the arguments given, if any.
|
||||
If this execution fails because the file is not in executable
|
||||
format, and the file is not a directory, it is assumed to be
|
||||
a \fIshell script\fP, a file
|
||||
containing shell commands. A subshell is spawned to execute
|
||||
it. This subshell reinitializes itself, so
|
||||
containing shell commands, and the shell creates a
|
||||
to execute it.
|
||||
This subshell reinitializes itself, so
|
||||
that the effect is as if a new shell had been invoked
|
||||
to handle the script, with the exception that the locations of
|
||||
commands remembered by the parent (see
|
||||
@@ -4949,8 +4949,8 @@ of \fB$$\fP, and the value of
|
||||
When a simple command other than a builtin or shell function
|
||||
is to be executed, it
|
||||
is invoked in a separate execution environment that consists of
|
||||
the following. Unless otherwise noted, the values are inherited
|
||||
from the shell.
|
||||
the following.
|
||||
Unless otherwise noted, the values are inherited from the shell.
|
||||
.if n .sp 1
|
||||
.IP \(bu
|
||||
the shell's open files, plus any modifications and additions specified
|
||||
@@ -4969,6 +4969,8 @@ shell's parent, and traps ignored by the shell are ignored
|
||||
A command invoked in this separate environment cannot affect the
|
||||
shell's execution environment.
|
||||
.PP
|
||||
A \fIsubshell\fP is a copy of the shell process.
|
||||
.PP
|
||||
Command substitution, commands grouped with parentheses,
|
||||
and asynchronous commands are invoked in a
|
||||
subshell environment that is a duplicate of the shell environment,
|
||||
@@ -10398,6 +10400,13 @@ If set, the
|
||||
to find the directory containing the file supplied as an argument.
|
||||
This option is enabled by default.
|
||||
.TP 8
|
||||
.B varredir_close
|
||||
If set, the shell automatically closes file descriptors assigned using the
|
||||
\fI{varname}\fP redirection syntax (see
|
||||
.SM
|
||||
.B REDIRECTION
|
||||
above) instead of leaving them open when the command completes.
|
||||
.TP 8
|
||||
.B xpg_echo
|
||||
If set, the \fBecho\fP builtin expands backslash-escape sequences
|
||||
by default.
|
||||
|
||||
+145
-128
@@ -703,8 +703,8 @@ information.
|
||||
If the pipeline is not executed asynchronously (*note Lists::), the
|
||||
shell waits for all commands in the pipeline to complete.
|
||||
|
||||
Each command in a pipeline is executed in its own subshell, which is
|
||||
a separate process (*note Command Execution Environment::). If the
|
||||
Each command in a pipeline is executed in its own "subshell", which
|
||||
is a separate process (*note Command Execution Environment::). If the
|
||||
'lastpipe' option is enabled using the 'shopt' builtin (*note The Shopt
|
||||
Builtin::), the last element of a pipeline may be run by the shell
|
||||
process when job control is not active.
|
||||
@@ -1176,9 +1176,9 @@ list may be redirected to a single stream.
|
||||
'()'
|
||||
( LIST )
|
||||
|
||||
Placing a list of commands between parentheses causes a subshell
|
||||
environment to be created (*note Command Execution Environment::),
|
||||
and each of the commands in LIST to be executed in that subshell.
|
||||
Placing a list of commands between parentheses forces the shell to
|
||||
create a subshell (*note Command Execution Environment::), and each
|
||||
of the commands in LIST is executed in that subshell environment.
|
||||
Since the LIST is executed in a subshell, variable assignments do
|
||||
not remain in effect after the subshell completes.
|
||||
|
||||
@@ -1423,7 +1423,8 @@ been shadowed will become visible.
|
||||
the 'declare' ('typeset') builtin command (*note Bash Builtins::). The
|
||||
'-F' option to 'declare' or 'typeset' will list the function names only
|
||||
(and optionally the source file and line number, if the 'extdebug' shell
|
||||
option is enabled). Functions may be exported so that subshells
|
||||
option is enabled). Functions may be exported so that child shell
|
||||
processes (those created when executing a separate shell invocation)
|
||||
automatically have them defined with the '-f' option to the 'export'
|
||||
builtin (*note Bourne Shell Builtins::).
|
||||
|
||||
@@ -1584,9 +1585,8 @@ only be referenced; assignment to them is not allowed.
|
||||
shell itself (such as the '-i' option).
|
||||
|
||||
'$'
|
||||
($$) Expands to the process ID of the shell. In a '()' subshell,
|
||||
it expands to the process ID of the invoking shell, not the
|
||||
subshell.
|
||||
($$) Expands to the process ID of the shell. In a subshell, it
|
||||
expands to the process ID of the invoking shell, not the subshell.
|
||||
|
||||
'!'
|
||||
($!) Expands to the process ID of the job most recently placed
|
||||
@@ -2382,6 +2382,14 @@ the following sub-patterns:
|
||||
'!(PATTERN-LIST)'
|
||||
Matches anything except one of the given patterns.
|
||||
|
||||
When matching filenames, the 'dotglob' shell option determines the
|
||||
set of filenames that are tested: when 'dotglob' is enabled, the set of
|
||||
filenames includes all files beginning with '.', but the filenames '.'
|
||||
and '..' must be matched by a pattern or sub-pattern that begins with a
|
||||
dot; when it is disabled, the set does not include any filenames
|
||||
beginning with "." unless the pattern or sub-pattern begins with a '.'.
|
||||
As above, '.' only has a special meaning when matching filenames.
|
||||
|
||||
Complicated extended pattern matching against long strings is slow,
|
||||
especially when the patterns contain alternations and the strings
|
||||
contain multiple matches. Using separate matches against shorter
|
||||
@@ -2421,7 +2429,8 @@ file descriptor greater than 10 and assign it to {VARNAME}. If >&- or
|
||||
<&- is preceded by {VARNAME}, the value of VARNAME defines the file
|
||||
descriptor to close. If {VARNAME} is supplied, the redirection persists
|
||||
beyond the scope of the command, allowing the shell programmer to manage
|
||||
the file descriptor's lifetime manually.
|
||||
the file descriptor's lifetime manually. The 'varredir_close' shell
|
||||
option manages this behavior (*note The Shopt Builtin::).
|
||||
|
||||
In the following descriptions, if the file descriptor number is
|
||||
omitted, and the first character of the redirection operator is '<', the
|
||||
@@ -2805,6 +2814,8 @@ inherited from the shell.
|
||||
A command invoked in this separate environment cannot affect the
|
||||
shell's execution environment.
|
||||
|
||||
A "subshell" is a copy of the shell process.
|
||||
|
||||
Command substitution, commands grouped with parentheses, and
|
||||
asynchronous commands are invoked in a subshell environment that is a
|
||||
duplicate of the shell environment, except that traps caught by the
|
||||
@@ -2960,8 +2971,8 @@ parameters are unset.
|
||||
|
||||
A shell script may be made executable by using the 'chmod' command to
|
||||
turn on the execute bit. When Bash finds such a file while searching
|
||||
the '$PATH' for a command, it spawns a subshell to execute it. In other
|
||||
words, executing
|
||||
the '$PATH' for a command, it creates a subshell to execute it. In
|
||||
other words, executing
|
||||
filename ARGUMENTS
|
||||
is equivalent to executing
|
||||
bash filename ARGUMENTS
|
||||
@@ -4871,6 +4882,12 @@ This builtin allows you to change additional shell optional behavior.
|
||||
find the directory containing the file supplied as an
|
||||
argument. This option is enabled by default.
|
||||
|
||||
'varredir_close'
|
||||
If set, the shell automatically closes file descriptors
|
||||
assigned using the '{varname}' redirection syntax (*note
|
||||
Redirections::) instead of leaving them open when the command
|
||||
completes.
|
||||
|
||||
'xpg_echo'
|
||||
If set, the 'echo' builtin expands backslash-escape sequences
|
||||
by default.
|
||||
@@ -11590,21 +11607,21 @@ D.3 Parameter and Variable Index
|
||||
| ||||