mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-03 10:20:49 +02:00
changes to command timing with errexit; binary file checks; treat exit builtin slightly differently when using bash -c
This commit is contained in:
@@ -1990,3 +1990,55 @@ aclocal.m4
|
||||
configure.ac
|
||||
- BASH_CHECK_DECL -> AC_CHECK_DECLS
|
||||
- quad_t: use AC_CHECK_TYPE (new style) instead of BASH_CHECK_TYPE
|
||||
|
||||
|
||||
9/14
|
||||
----
|
||||
execute_cmd.c
|
||||
- time_command: if we longjmp back to the top_level we saved, make sure
|
||||
we're in the same subshell environment before printing the timing
|
||||
stats. We could have longjmped back from a child process of the
|
||||
command or pipeline we want to time. From a report by
|
||||
Sergej Alikov <sergej@alikov.com>
|
||||
- time_command: restore command->flags even if we longjmp back
|
||||
|
||||
general.c
|
||||
- check_binary_file: if the first line of the ENOEXEC file starts with
|
||||
a `#!', check the rest of the buffer for NULs to determine whether
|
||||
this is a binary file. Since we only check the first line, a #! line
|
||||
followed by binary data could be confused for a shell script
|
||||
|
||||
9/16
|
||||
----
|
||||
bashjmp.h
|
||||
- EXITBLTIN: new longjmp `code' value: used by the exit builtin
|
||||
|
||||
{execute_cmd,shell,subst,trap}.c,builtins/evalstring.c
|
||||
- treat EXITBLTIN exactly the same as EXITPROG (for now)
|
||||
|
||||
builtins/exit.def
|
||||
- exit_builtin: jump_to_top_level with value EXITBLTIN
|
||||
|
||||
builtins/evalstring.c
|
||||
- parse_and_execute: EXITBLTIN has its own case, with the same contents
|
||||
as EXITPROG
|
||||
|
||||
9/17
|
||||
----
|
||||
builtins/evalstring.c
|
||||
- parse_and_execute: change EXITBLTIN case to avoid running the
|
||||
unwind-protect stack to the `pe_dispose' tag (which has the effect
|
||||
of running all the unwind-protects installed by the commands in
|
||||
the string) if we're executing in a function and EXIT is trapped.
|
||||
This has the effect of running the EXIT trap in the function context,
|
||||
which is what we do when we're not in parse_and_execute (eval,
|
||||
bash -c, command substitution, etc.)
|
||||
|
||||
9/18
|
||||
----
|
||||
arrayfunc.c
|
||||
- expand_and_quote_kvpair_word,quote_compound_array_word,
|
||||
expand_and_quote_assoc_word,quote_compound_array_list: make sure
|
||||
the value has CTLESC characters doubled even when being single-
|
||||
quoted, since that's what the parser does with standalone assignment
|
||||
statements. From https://savannah.gnu.org/support/?110538
|
||||
|
||||
@@ -932,6 +932,7 @@ tests/array25.sub f
|
||||
tests/array26.sub f
|
||||
tests/array27.sub f
|
||||
tests/array28.sub f
|
||||
tests/array29.sub f
|
||||
tests/array-at-star f
|
||||
tests/array2.right f
|
||||
tests/assoc.tests f
|
||||
@@ -1500,6 +1501,7 @@ tests/varenv18.sub f
|
||||
tests/varenv19.sub f
|
||||
tests/varenv20.sub f
|
||||
tests/varenv21.sub f
|
||||
tests/varenv22.sub f
|
||||
tests/version f
|
||||
tests/version.mini f
|
||||
tests/vredir.tests f
|
||||
|
||||
+39
-8
@@ -613,10 +613,18 @@ char *
|
||||
expand_and_quote_kvpair_word (w)
|
||||
char *w;
|
||||
{
|
||||
char *t, *r;
|
||||
char *r, *s, *t;
|
||||
|
||||
t = w ? expand_subscript_string (w, 0) : 0;
|
||||
#if 0 /* TAG:bash-5.2 */
|
||||
s = (t && strchr (t, CTLESC)) ? quote_escapes (t) : t;
|
||||
r = sh_single_quote (s ? s : "");
|
||||
if (s != t)
|
||||
free (s);
|
||||
#else
|
||||
r = sh_single_quote (t ? t : "");
|
||||
#endif
|
||||
|
||||
free (t);
|
||||
return r;
|
||||
}
|
||||
@@ -892,10 +900,10 @@ quote_compound_array_word (w, type)
|
||||
int ind, wlen, i;
|
||||
|
||||
if (w[0] != LBRACK)
|
||||
return (sh_single_quote (w));
|
||||
return (sh_single_quote (w)); /* XXX - quote CTLESC */
|
||||
ind = skipsubscript (w, 0, 0);
|
||||
if (w[ind] != RBRACK)
|
||||
return (sh_single_quote (w));
|
||||
return (sh_single_quote (w)); /* XXX - quote CTLESC */
|
||||
|
||||
wlen = strlen (w);
|
||||
w[ind] = '\0';
|
||||
@@ -912,7 +920,14 @@ quote_compound_array_word (w, type)
|
||||
if (w[ind] == '+')
|
||||
nword[i++] = w[ind++];
|
||||
nword[i++] = w[ind++];
|
||||
#if 0 /* TAG:bash-5.2 */
|
||||
t = (strchr (w+ind, CTLESC)) ? quote_escapes (w+ind) : w+ind;
|
||||
value = sh_single_quote (t);
|
||||
if (t != w+ind)
|
||||
free (t);
|
||||
#else
|
||||
value = sh_single_quote (w + ind);
|
||||
#endif
|
||||
strcpy (nword + i, value);
|
||||
|
||||
return nword;
|
||||
@@ -930,14 +945,14 @@ expand_and_quote_assoc_word (w, type)
|
||||
char *w;
|
||||
int type;
|
||||
{
|
||||
char *nword, *key, *value, *t;
|
||||
char *nword, *key, *value, *s, *t;
|
||||
int ind, wlen, i;
|
||||
|
||||
if (w[0] != LBRACK)
|
||||
return (sh_single_quote (w));
|
||||
return (sh_single_quote (w)); /* XXX - quote_escapes */
|
||||
ind = skipsubscript (w, 0, 0);
|
||||
if (w[ind] != RBRACK)
|
||||
return (sh_single_quote (w));
|
||||
return (sh_single_quote (w)); /* XXX - quote_escapes */
|
||||
|
||||
w[ind] = '\0';
|
||||
t = expand_subscript_string (w+1, 0);
|
||||
@@ -957,7 +972,14 @@ expand_and_quote_assoc_word (w, type)
|
||||
nword[i++] = w[ind++];
|
||||
|
||||
t = expand_subscript_string (w+ind, 0);
|
||||
#if 0 /* TAG:bash-5.2 */
|
||||
s = (t && strchr (t, CTLESC)) ? quote_escapes (t) : t;
|
||||
value = sh_single_quote (s ? s : "");
|
||||
if (s != t)
|
||||
free (s);
|
||||
#else
|
||||
value = sh_single_quote (t ? t : "");
|
||||
#endif
|
||||
free (t);
|
||||
nword = xrealloc (nword, wlen + 5 + STRLEN (value));
|
||||
strcpy (nword + i, value);
|
||||
@@ -977,7 +999,7 @@ quote_compound_array_list (list, type)
|
||||
WORD_LIST *list;
|
||||
int type;
|
||||
{
|
||||
char *t;
|
||||
char *s, *t;
|
||||
WORD_LIST *l;
|
||||
|
||||
for (l = list; l; l = l->next)
|
||||
@@ -985,7 +1007,16 @@ quote_compound_array_list (list, type)
|
||||
if (l->word == 0 || l->word->word == 0)
|
||||
continue; /* should not happen, but just in case... */
|
||||
if ((l->word->flags & W_ASSIGNMENT) == 0)
|
||||
t = sh_single_quote (l->word->word);
|
||||
{
|
||||
#if 0 /* TAG:bash-5.2 */
|
||||
s = (strchr (l->word->word, CTLESC)) ? quote_escapes (l->word->word) : l->word->word;
|
||||
t = sh_single_quote (s);
|
||||
if (s != l->word->word)
|
||||
free (s);
|
||||
#else
|
||||
t = sh_single_quote (l->word->word);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
t = quote_compound_array_word (l->word->word, type);
|
||||
free (l->word->word);
|
||||
|
||||
@@ -42,5 +42,6 @@ extern int no_longjmp_on_fatal_error;
|
||||
#define EXITPROG 3 /* Unconditionally exit the program now. */
|
||||
#define ERREXIT 4 /* Exit due to error condition */
|
||||
#define SIGEXIT 5 /* Exit due to fatal terminating signal */
|
||||
#define EXITBLTIN 6 /* Exit due to the exit builtin. */
|
||||
|
||||
#endif /* _BASHJMP_H_ */
|
||||
|
||||
@@ -375,6 +375,25 @@ parse_and_execute (string, from_file, flags)
|
||||
should_jump_to_top_level = 1;
|
||||
goto out;
|
||||
|
||||
case EXITBLTIN:
|
||||
if (command)
|
||||
{
|
||||
if (variable_context && signal_is_trapped (0))
|
||||
{
|
||||
/* Let's make sure we run the exit trap in the function
|
||||
context, as we do when not running parse_and_execute.
|
||||
The pe_dispose unwind frame comes before any unwind-
|
||||
protects installed by the string we're evaluating, so
|
||||
it will undo the current function scope. */
|
||||
dispose_command (command);
|
||||
discard_unwind_frame ("pe_dispose");
|
||||
}
|
||||
else
|
||||
run_unwind_frame ("pe_dispose");
|
||||
}
|
||||
should_jump_to_top_level = 1;
|
||||
goto out;
|
||||
|
||||
case DISCARD:
|
||||
if (command)
|
||||
run_unwind_frame ("pe_dispose");
|
||||
@@ -608,6 +627,7 @@ itrace("parse_string: longjmp executed: code = %d", code);
|
||||
case FORCE_EOF:
|
||||
case ERREXIT:
|
||||
case EXITPROG:
|
||||
case EXITBLTIN:
|
||||
case DISCARD: /* XXX */
|
||||
if (command)
|
||||
dispose_command (command);
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ exit_or_logout (list)
|
||||
last_command_exit_value = exit_value;
|
||||
|
||||
/* Exit the program. */
|
||||
jump_to_top_level (EXITPROG);
|
||||
jump_to_top_level (EXITBLTIN);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
|
||||
+1654
-1650
File diff suppressed because it is too large
Load Diff
+5
-1
@@ -4843,7 +4843,11 @@ expansion, parameter expansion, command substitution, arithmetic expansion,
|
||||
and quote removal before being assigned to the variable.
|
||||
.PP
|
||||
If no command name results, the variable assignments affect the current
|
||||
shell environment. Otherwise, the variables are added to the environment
|
||||
shell environment.
|
||||
In the case of such a command (one that consists only of assignment
|
||||
statements and redirections), assignment statements are performed before
|
||||
redirections.
|
||||
Otherwise, the variables are added to the environment
|
||||
of the executed command and do not affect the current shell environment.
|
||||
If any of the assignments attempts to assign a value to a readonly variable,
|
||||
an error occurs, and the command exits with a non-zero status.
|
||||
|
||||
+107
-103
@@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 6.7 from
|
||||
bashref.texi.
|
||||
|
||||
This text is a brief description of the features that are present in the
|
||||
Bash shell (version 5.1, 10 August 2021).
|
||||
Bash shell (version 5.1, 23 August 2021).
|
||||
|
||||
This is Edition 5.1, last updated 10 August 2021, of 'The GNU Bash
|
||||
This is Edition 5.1, last updated 23 August 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, 10 August 2021). The Bash home page is
|
||||
Bash shell (version 5.1, 23 August 2021). The Bash home page is
|
||||
<http://www.gnu.org/software/bash/>.
|
||||
|
||||
This is Edition 5.1, last updated 10 August 2021, of 'The GNU Bash
|
||||
This is Edition 5.1, last updated 23 August 2021, of 'The GNU Bash
|
||||
Reference Manual', for 'Bash', Version 5.1.
|
||||
|
||||
Bash contains features that appear in other popular shells, and some
|
||||
@@ -2118,6 +2118,10 @@ omitted, the operator tests only for existence.
|
||||
'a'
|
||||
The expansion is a string consisting of flag values
|
||||
representing PARAMETER's attributes.
|
||||
'k'
|
||||
Like the 'K' transformation, but expands the keys and values
|
||||
of indexed and associative arrays to separate words after word
|
||||
splitting.
|
||||
|
||||
If PARAMETER is '@' or '*', the operation is applied to each
|
||||
positional parameter in turn, and the expansion is the resultant
|
||||
@@ -2972,8 +2976,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 creates a subshell to execute it. In
|
||||
other words, executing
|
||||
the '$PATH' for a command, it creates a new instance of itself to
|
||||
execute it. In other words, executing
|
||||
filename ARGUMENTS
|
||||
is equivalent to executing
|
||||
bash filename ARGUMENTS
|
||||
@@ -12260,103 +12264,103 @@ Node: Shell Expansions69743
|
||||
Node: Brace Expansion71870
|
||||
Node: Tilde Expansion74604
|
||||
Node: Shell Parameter Expansion77225
|
||||
Node: Command Substitution92354
|
||||
Node: Arithmetic Expansion93709
|
||||
Node: Process Substitution94677
|
||||
Node: Word Splitting95797
|
||||
Node: Filename Expansion97741
|
||||
Node: Pattern Matching100341
|
||||
Node: Quote Removal104949
|
||||
Node: Redirections105244
|
||||
Node: Executing Commands114904
|
||||
Node: Simple Command Expansion115574
|
||||
Node: Command Search and Execution117528
|
||||
Node: Command Execution Environment119906
|
||||
Node: Environment122941
|
||||
Node: Exit Status124604
|
||||
Node: Signals126388
|
||||
Node: Shell Scripts128355
|
||||
Node: Shell Builtin Commands131368
|
||||
Node: Bourne Shell Builtins133406
|
||||
Node: Bash Builtins154867
|
||||
Node: Modifying Shell Behavior185684
|
||||
Node: The Set Builtin186029
|
||||
Node: The Shopt Builtin196442
|
||||
Node: Special Builtins211871
|
||||
Node: Shell Variables212850
|
||||
Node: Bourne Shell Variables213287
|
||||
Node: Bash Variables215391
|
||||
Node: Bash Features248206
|
||||
Node: Invoking Bash249219
|
||||
Node: Bash Startup Files255232
|
||||
Node: Interactive Shells260335
|
||||
Node: What is an Interactive Shell?260745
|
||||
Node: Is this Shell Interactive?261394
|
||||
Node: Interactive Shell Behavior262209
|
||||
Node: Bash Conditional Expressions265722
|
||||
Node: Shell Arithmetic270364
|
||||
Node: Aliases273308
|
||||
Node: Arrays275921
|
||||
Node: The Directory Stack281930
|
||||
Node: Directory Stack Builtins282714
|
||||
Node: Controlling the Prompt286974
|
||||
Node: The Restricted Shell289939
|
||||
Node: Bash POSIX Mode292536
|
||||
Node: Shell Compatibility Mode303809
|
||||
Node: Job Control310465
|
||||
Node: Job Control Basics310925
|
||||
Node: Job Control Builtins315927
|
||||
Node: Job Control Variables321327
|
||||
Node: Command Line Editing322483
|
||||
Node: Introduction and Notation324154
|
||||
Node: Readline Interaction325777
|
||||
Node: Readline Bare Essentials326968
|
||||
Node: Readline Movement Commands328751
|
||||
Node: Readline Killing Commands329711
|
||||
Node: Readline Arguments331629
|
||||
Node: Searching332673
|
||||
Node: Readline Init File334859
|
||||
Node: Readline Init File Syntax336120
|
||||
Node: Conditional Init Constructs357400
|
||||
Node: Sample Init File361596
|
||||
Node: Bindable Readline Commands364720
|
||||
Node: Commands For Moving365924
|
||||
Node: Commands For History367975
|
||||
Node: Commands For Text372969
|
||||
Node: Commands For Killing376618
|
||||
Node: Numeric Arguments379651
|
||||
Node: Commands For Completion380790
|
||||
Node: Keyboard Macros384981
|
||||
Node: Miscellaneous Commands385668
|
||||
Node: Readline vi Mode391607
|
||||
Node: Programmable Completion392514
|
||||
Node: Programmable Completion Builtins400294
|
||||
Node: A Programmable Completion Example410989
|
||||
Node: Using History Interactively416236
|
||||
Node: Bash History Facilities416920
|
||||
Node: Bash History Builtins419925
|
||||
Node: History Interaction424933
|
||||
Node: Event Designators428553
|
||||
Node: Word Designators429907
|
||||
Node: Modifiers431667
|
||||
Node: Installing Bash433478
|
||||
Node: Basic Installation434615
|
||||
Node: Compilers and Options437873
|
||||
Node: Compiling For Multiple Architectures438614
|
||||
Node: Installation Names440307
|
||||
Node: Specifying the System Type441125
|
||||
Node: Sharing Defaults441841
|
||||
Node: Operation Controls442514
|
||||
Node: Optional Features443472
|
||||
Node: Reporting Bugs454272
|
||||
Node: Major Differences From The Bourne Shell455547
|
||||
Node: GNU Free Documentation License472397
|
||||
Node: Indexes497574
|
||||
Node: Builtin Index498028
|
||||
Node: Reserved Word Index504855
|
||||
Node: Variable Index507303
|
||||
Node: Function Index523795
|
||||
Node: Concept Index537579
|
||||
Node: Command Substitution92528
|
||||
Node: Arithmetic Expansion93883
|
||||
Node: Process Substitution94851
|
||||
Node: Word Splitting95971
|
||||
Node: Filename Expansion97915
|
||||
Node: Pattern Matching100515
|
||||
Node: Quote Removal105123
|
||||
Node: Redirections105418
|
||||
Node: Executing Commands115078
|
||||
Node: Simple Command Expansion115748
|
||||
Node: Command Search and Execution117702
|
||||
Node: Command Execution Environment120080
|
||||
Node: Environment123115
|
||||
Node: Exit Status124778
|
||||
Node: Signals126562
|
||||
Node: Shell Scripts128529
|
||||
Node: Shell Builtin Commands131556
|
||||
Node: Bourne Shell Builtins133594
|
||||
Node: Bash Builtins155055
|
||||
Node: Modifying Shell Behavior185872
|
||||
Node: The Set Builtin186217
|
||||
Node: The Shopt Builtin196630
|
||||
Node: Special Builtins212059
|
||||
Node: Shell Variables213038
|
||||
Node: Bourne Shell Variables213475
|
||||
Node: Bash Variables215579
|
||||
Node: Bash Features248394
|
||||
Node: Invoking Bash249407
|
||||
Node: Bash Startup Files255420
|
||||
Node: Interactive Shells260523
|
||||
Node: What is an Interactive Shell?260933
|
||||
Node: Is this Shell Interactive?261582
|
||||
Node: Interactive Shell Behavior262397
|
||||
Node: Bash Conditional Expressions265910
|
||||
Node: Shell Arithmetic270552
|
||||
Node: Aliases273496
|
||||
Node: Arrays276109
|
||||
Node: The Directory Stack282118
|
||||
Node: Directory Stack Builtins282902
|
||||
Node: Controlling the Prompt287162
|
||||
Node: The Restricted Shell290127
|
||||
Node: Bash POSIX Mode292724
|
||||
Node: Shell Compatibility Mode303997
|
||||
Node: Job Control310653
|
||||
Node: Job Control Basics311113
|
||||
Node: Job Control Builtins316115
|
||||
Node: Job Control Variables321515
|
||||
Node: Command Line Editing322671
|
||||
Node: Introduction and Notation324342
|
||||
Node: Readline Interaction325965
|
||||
Node: Readline Bare Essentials327156
|
||||
Node: Readline Movement Commands328939
|
||||
Node: Readline Killing Commands329899
|
||||
Node: Readline Arguments331817
|
||||
Node: Searching332861
|
||||
Node: Readline Init File335047
|
||||
Node: Readline Init File Syntax336308
|
||||
Node: Conditional Init Constructs357588
|
||||
Node: Sample Init File361784
|
||||
Node: Bindable Readline Commands364908
|
||||
Node: Commands For Moving366112
|
||||
Node: Commands For History368163
|
||||
Node: Commands For Text373157
|
||||
Node: Commands For Killing376806
|
||||
Node: Numeric Arguments379839
|
||||
Node: Commands For Completion380978
|
||||
Node: Keyboard Macros385169
|
||||
Node: Miscellaneous Commands385856
|
||||
Node: Readline vi Mode391795
|
||||
Node: Programmable Completion392702
|
||||
Node: Programmable Completion Builtins400482
|
||||
Node: A Programmable Completion Example411177
|
||||
Node: Using History Interactively416424
|
||||
Node: Bash History Facilities417108
|
||||
Node: Bash History Builtins420113
|
||||
Node: History Interaction425121
|
||||
Node: Event Designators428741
|
||||
Node: Word Designators430095
|
||||
Node: Modifiers431855
|
||||
Node: Installing Bash433666
|
||||
Node: Basic Installation434803
|
||||
Node: Compilers and Options438061
|
||||
Node: Compiling For Multiple Architectures438802
|
||||
Node: Installation Names440495
|
||||
Node: Specifying the System Type441313
|
||||
Node: Sharing Defaults442029
|
||||
Node: Operation Controls442702
|
||||
Node: Optional Features443660
|
||||
Node: Reporting Bugs454460
|
||||
Node: Major Differences From The Bourne Shell455735
|
||||
Node: GNU Free Documentation License472585
|
||||
Node: Indexes497762
|
||||
Node: Builtin Index498216
|
||||
Node: Reserved Word Index505043
|
||||
Node: Variable Index507491
|
||||
Node: Function Index523983
|
||||
Node: Concept Index537767
|
||||
|
||||
End Tag Table
|
||||
|
||||
|
||||
+5
-1
@@ -3166,7 +3166,11 @@ and quote removal before being assigned to the variable.
|
||||
@end enumerate
|
||||
|
||||
If no command name results, the variable assignments affect the current
|
||||
shell environment. Otherwise, the variables are added to the environment
|
||||
shell environment.
|
||||
In the case of such a command (one that consists only of assignment
|
||||
statements and redirections), assignment statements are performed before
|
||||
redirections.
|
||||
Otherwise, the variables are added to the environment
|
||||
of the executed command and do not affect the current shell environment.
|
||||
If any of the assignments attempts to assign a value to a readonly variable,
|
||||
an error occurs, and the command exits with a non-zero status.
|
||||
|
||||
@@ -93,6 +93,7 @@ reader_loop ()
|
||||
case FORCE_EOF:
|
||||
case ERREXIT:
|
||||
case EXITPROG:
|
||||
case EXITBLTIN:
|
||||
current_command = (COMMAND *)NULL;
|
||||
if (exit_immediately_on_error)
|
||||
variable_context = 0; /* not in a function */
|
||||
|
||||
+14
-7
@@ -1324,6 +1324,7 @@ time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close)
|
||||
int cpu;
|
||||
char *time_format;
|
||||
volatile procenv_t save_top_level;
|
||||
volatile int old_subshell;
|
||||
|
||||
#if defined (HAVE_GETRUSAGE) && defined (HAVE_GETTIMEOFDAY)
|
||||
struct timeval real, user, sys;
|
||||
@@ -1353,6 +1354,7 @@ time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
old_subshell = subshell_environment;
|
||||
posix_time = command && (command->flags & CMD_TIME_POSIX);
|
||||
|
||||
nullcmd = (command == 0) || (command->type == cm_simple && command->value.Simple->words == 0 && command->value.Simple->redirects == 0);
|
||||
@@ -1373,12 +1375,17 @@ time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close)
|
||||
command->flags &= ~(CMD_TIME_PIPELINE|CMD_TIME_POSIX);
|
||||
code = setjmp_nosigs (top_level);
|
||||
if (code == NOT_JUMPED)
|
||||
{
|
||||
rv = execute_command_internal (command, asynchronous, pipe_in, pipe_out, fds_to_close);
|
||||
command->flags = old_flags;
|
||||
}
|
||||
rv = execute_command_internal (command, asynchronous, pipe_in, pipe_out, fds_to_close);
|
||||
COPY_PROCENV (save_top_level, top_level);
|
||||
|
||||
command->flags = old_flags;
|
||||
|
||||
/* If we're jumping in a different subshell environment than we started,
|
||||
don't bother printing timing stats, just keep longjmping back to the
|
||||
original top level. */
|
||||
if (code != NOT_JUMPED && subshell_environment && subshell_environment != old_subshell)
|
||||
sh_longjmp (top_level, code);
|
||||
|
||||
rs = us = ss = 0;
|
||||
rsf = usf = ssf = cpu = 0;
|
||||
|
||||
@@ -1682,7 +1689,7 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
|
||||
|
||||
/* If we're going to exit the shell, we don't want to invert the return
|
||||
status. */
|
||||
if (result == EXITPROG)
|
||||
if (result == EXITPROG || result == EXITBLTIN)
|
||||
invert = 0, return_code = last_command_exit_value;
|
||||
else if (result)
|
||||
return_code = (last_command_exit_value == EXECUTION_SUCCESS) ? EXECUTION_FAILURE : last_command_exit_value;
|
||||
@@ -5365,7 +5372,7 @@ execute_subshell_builtin_or_function (words, redirects, builtin, var,
|
||||
if (return_catch_flag && builtin == return_builtin)
|
||||
funcvalue = setjmp_nosigs (return_catch);
|
||||
|
||||
if (result == EXITPROG)
|
||||
if (result == EXITPROG || result == EXITBLTIN)
|
||||
subshell_exit (last_command_exit_value);
|
||||
else if (result)
|
||||
subshell_exit (EXECUTION_FAILURE);
|
||||
@@ -6011,7 +6018,7 @@ shell_execve (command, args, env)
|
||||
If so, the format of the line is "#! interpreter [argument]".
|
||||
A single argument is allowed. The BSD kernel restricts
|
||||
the length of the entire line to 32 characters (32 bytes
|
||||
being the size of the BSD exec header), but we allow 80
|
||||
being the size of the BSD exec header), but we allow up to 128
|
||||
characters. */
|
||||
if (sample_len > 0)
|
||||
{
|
||||
|
||||
@@ -686,6 +686,12 @@ check_binary_file (sample, sample_len)
|
||||
if (sample_len >= 4 && sample[0] == 0x7f && sample[1] == 'E' && sample[2] == 'L' && sample[3] == 'F')
|
||||
return 1;
|
||||
|
||||
/* Generally we check the first line for NULs. If the first line looks like
|
||||
a `#!' interpreter specifier, we just look for NULs anywhere in the
|
||||
buffer. */
|
||||
if (sample[0] == '#' && sample[1] == '!')
|
||||
return (memchr (sample, '\0', sample_len) != NULL);
|
||||
|
||||
for (i = 0; i < sample_len; i++)
|
||||
{
|
||||
c = sample[i];
|
||||
|
||||
@@ -628,7 +628,7 @@ main (argc, argv, env)
|
||||
code = setjmp_sigs (top_level);
|
||||
if (code)
|
||||
{
|
||||
if (code == EXITPROG || code == ERREXIT)
|
||||
if (code == EXITPROG || code == ERREXIT || code == EXITBLTIN)
|
||||
exit_shell (last_command_exit_value);
|
||||
else
|
||||
{
|
||||
@@ -1366,6 +1366,7 @@ run_wordexp (words)
|
||||
return last_command_exit_value = 127;
|
||||
case ERREXIT:
|
||||
case EXITPROG:
|
||||
case EXITBLTIN:
|
||||
return last_command_exit_value;
|
||||
case DISCARD:
|
||||
return last_command_exit_value = 1;
|
||||
@@ -1444,6 +1445,7 @@ run_one_command (command)
|
||||
return last_command_exit_value = 127;
|
||||
case ERREXIT:
|
||||
case EXITPROG:
|
||||
case EXITBLTIN:
|
||||
return last_command_exit_value;
|
||||
case DISCARD:
|
||||
return last_command_exit_value = 1;
|
||||
|
||||
@@ -6252,7 +6252,7 @@ process_substitute (string, open_for_read_in_child)
|
||||
|
||||
if (result == ERREXIT)
|
||||
rc = last_command_exit_value;
|
||||
else if (result == EXITPROG)
|
||||
else if (result == EXITPROG || result == EXITBLTIN)
|
||||
rc = last_command_exit_value;
|
||||
else if (result)
|
||||
rc = EXECUTION_FAILURE;
|
||||
@@ -6665,7 +6665,7 @@ command_substitute (string, quoted, flags)
|
||||
|
||||
if (result == ERREXIT)
|
||||
rc = last_command_exit_value;
|
||||
else if (result == EXITPROG)
|
||||
else if (result == EXITPROG || result == EXITBLTIN)
|
||||
rc = last_command_exit_value;
|
||||
else if (result)
|
||||
rc = EXECUTION_FAILURE;
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
|
||||
@@ -759,3 +759,9 @@ declare -a bug2=([0]="")
|
||||
declare -a bug3=([0]="" [1]="5" [2]="" [3]="1" [4]="")
|
||||
declare -a not_bug=([0]="no" [1]="nulls")
|
||||
declare -a workaround=([0]="")
|
||||
declare -a var=([0]=$'\001\001\001\001')
|
||||
declare -a foo=([0]=$'\001\001\001\001')
|
||||
declare -a foo=([0]=$'\001\001')
|
||||
declare -a foo=([0]=$'\001\001')
|
||||
declare -A foo=([v]=$'\001\001' )
|
||||
declare -A foo=([v]=$'\001\001' )
|
||||
|
||||
@@ -425,3 +425,4 @@ ${THIS_SH} ./array25.sub
|
||||
${THIS_SH} ./array26.sub
|
||||
${THIS_SH} ./array27.sub
|
||||
${THIS_SH} ./array28.sub
|
||||
${THIS_SH} ./array29.sub
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
var=( $'\x01\x01\x01\x01' )
|
||||
declare -p var
|
||||
|
||||
pv()
|
||||
{
|
||||
local -a foo
|
||||
foo=( "${var[@]}" )
|
||||
declare -p foo
|
||||
}
|
||||
pv
|
||||
|
||||
# these are wrong through bash-5.1; there is a fix tagged for bash-5.2
|
||||
# when I uncomment that fix, these results will reflect it
|
||||
|
||||
pv1()
|
||||
{
|
||||
local -a foo=( "${var[@]}" )
|
||||
declare -p foo
|
||||
}
|
||||
pv1
|
||||
|
||||
pv2()
|
||||
{
|
||||
local -a foo=( [0]="${var[@]}" )
|
||||
declare -p foo
|
||||
}
|
||||
pv2
|
||||
|
||||
pv3()
|
||||
{
|
||||
local -A foo=( v "${var[@]}" )
|
||||
declare -p foo
|
||||
}
|
||||
pv3
|
||||
|
||||
pv4()
|
||||
{
|
||||
local -A foo=( [v]="${var[@]}" )
|
||||
declare -p foo
|
||||
}
|
||||
pv4
|
||||
@@ -264,6 +264,14 @@ ignoreeof off
|
||||
ignoreeof on
|
||||
10
|
||||
match 1
|
||||
trap -- 'echo trap:$FUNCNAME' EXIT
|
||||
trap:f
|
||||
trap -- 'echo trap:$FUNCNAME' EXIT
|
||||
trap:f
|
||||
trap -- 'echo trap:$FUNCNAME' EXIT
|
||||
trap:f
|
||||
trap -- 'echo trap:$FUNCNAME' EXIT
|
||||
trap:f
|
||||
a=z
|
||||
a=b
|
||||
a=z
|
||||
|
||||
@@ -259,6 +259,7 @@ ${THIS_SH} ./varenv18.sub
|
||||
${THIS_SH} ./varenv19.sub
|
||||
${THIS_SH} ./varenv20.sub
|
||||
${THIS_SH} ./varenv21.sub
|
||||
${THIS_SH} ./varenv22.sub
|
||||
|
||||
# make sure variable scoping is done right
|
||||
tt() { typeset a=b;echo a=$a; };a=z;echo a=$a;tt;echo a=$a
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# test behavior of FUNCNAME in and out of parse_and_execute scenarios
|
||||
|
||||
# in parse_and_execute
|
||||
${THIS_SH} -c 'trap "echo trap:\$FUNCNAME" EXIT ; trap ; f() { exit; } ; f' bash
|
||||
|
||||
${THIS_SH} << \EOF
|
||||
eval "trap 'echo trap:\$FUNCNAME' EXIT ; trap; f() { exit; } ; f"
|
||||
EOF
|
||||
|
||||
# not in parse_and_execute
|
||||
${THIS_SH} << \EOF
|
||||
trap 'echo trap:$FUNCNAME' EXIT ; trap; f() { exit; } ; f
|
||||
EOF
|
||||
|
||||
# this has to be last
|
||||
trap 'echo trap:$FUNCNAME' EXIT ; trap; f() { exit; } ; f
|
||||
|
||||
Reference in New Issue
Block a user