mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-28 06:03:06 +02:00
Bash-5.3-rc1 release
This commit is contained in:
+47
-21
@@ -1,6 +1,6 @@
|
||||
/* execute_cmd.c -- Execute a COMMAND structure. */
|
||||
|
||||
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2025 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -776,6 +776,14 @@ execute_command_internal (COMMAND *command, int asynchronous, int pipe_in, int p
|
||||
|
||||
if (user_subshell && ignore_return == 0 && invert == 0 && exit_immediately_on_error && exec_result != EXECUTION_SUCCESS)
|
||||
{
|
||||
/* Update BASH_COMMAND before running any traps,
|
||||
including the exit trap, since we are going to exit
|
||||
the shell. */
|
||||
if (signal_in_progress (DEBUG_TRAP) == 0 && running_trap == 0)
|
||||
{
|
||||
FREE (the_printed_command_except_trap);
|
||||
the_printed_command_except_trap = savestring (the_printed_command);
|
||||
}
|
||||
run_pending_traps ();
|
||||
jump_to_top_level (ERREXIT);
|
||||
}
|
||||
@@ -4202,7 +4210,7 @@ execute_null_command (REDIRECT *redirects, int pipe_in, int pipe_out, int async)
|
||||
{
|
||||
forcefork += rd->rflags & REDIR_VARASSIGN;
|
||||
/* Safety */
|
||||
forcefork += (rd->redirector.dest == 0 || fd_is_bash_input (rd->redirector.dest)) && (INPUT_REDIRECT (rd->instruction) || TRANSLATE_REDIRECT (rd->instruction) || rd->instruction == r_close_this);
|
||||
forcefork += (rd->redirector.dest == 0 || fd_is_bash_input (rd->redirector.dest));
|
||||
}
|
||||
|
||||
if (forcefork || pipe_in != NO_PIPE || pipe_out != NO_PIPE || async)
|
||||
@@ -5570,7 +5578,7 @@ execute_builtin_or_function (WORD_LIST *words,
|
||||
REDIRECT *redirects, struct fd_bitmap *fds_to_close,
|
||||
int flags)
|
||||
{
|
||||
int result;
|
||||
int result, has_exec_redirects;
|
||||
REDIRECT *saved_undo_list;
|
||||
#if defined (PROCESS_SUBSTITUTION)
|
||||
int ofifo, nfifo, osize;
|
||||
@@ -5597,17 +5605,25 @@ execute_builtin_or_function (WORD_LIST *words,
|
||||
return (EX_REDIRFAIL); /* was EXECUTION_FAILURE */
|
||||
}
|
||||
|
||||
/* Is this the exec builtin with redirections? We want to undo them and
|
||||
throw away the exec_redirection_undo_list if exec has a program name
|
||||
argument, fails to execute it, and does not exit the shell */
|
||||
has_exec_redirects = (builtin == exec_builtin) && redirection_undo_list;
|
||||
|
||||
saved_undo_list = redirection_undo_list;
|
||||
|
||||
/* Calling the "exec" builtin changes redirections forever. */
|
||||
if (builtin == exec_builtin)
|
||||
{
|
||||
dispose_redirects (saved_undo_list);
|
||||
/* let exec_builtin handle disposing redirection_undo_list */
|
||||
saved_undo_list = exec_redirection_undo_list;
|
||||
exec_redirection_undo_list = (REDIRECT *)NULL;
|
||||
}
|
||||
else
|
||||
dispose_exec_redirects ();
|
||||
{
|
||||
dispose_exec_redirects ();
|
||||
redirection_undo_list = (REDIRECT *)NULL;
|
||||
}
|
||||
|
||||
if (saved_undo_list)
|
||||
{
|
||||
@@ -5615,8 +5631,6 @@ execute_builtin_or_function (WORD_LIST *words,
|
||||
add_unwind_protect (uw_cleanup_redirects, (char *)saved_undo_list);
|
||||
}
|
||||
|
||||
redirection_undo_list = (REDIRECT *)NULL;
|
||||
|
||||
if (builtin)
|
||||
result = execute_builtin (builtin, words, flags, 0);
|
||||
else
|
||||
@@ -5628,26 +5642,38 @@ execute_builtin_or_function (WORD_LIST *words,
|
||||
if (ferror (stdout))
|
||||
clearerr (stdout);
|
||||
|
||||
/* If we are executing the `command' builtin, but this_shell_builtin is
|
||||
set to `exec_builtin', we know that we have something like
|
||||
`command exec [redirection]', since otherwise `exec' would have
|
||||
overwritten the shell and we wouldn't get here. In this case, we
|
||||
want to behave as if the `command' builtin had not been specified
|
||||
and preserve the redirections. */
|
||||
if (builtin == command_builtin && this_shell_builtin == exec_builtin)
|
||||
if (has_exec_redirects && redirection_undo_list)
|
||||
{
|
||||
int discard;
|
||||
|
||||
discard = 0;
|
||||
/* We have returned from the exec builtin. If redirection_undo_list is
|
||||
still non-null, we had an operand and failed to exit the shell for
|
||||
some reason. We want to dispose of saved_undo_list, discard the frame,
|
||||
and let the redirections be undone as usual. If redirection_undo_list
|
||||
is NULL, then exec_builtin had no program name operand and disposed
|
||||
of it. In that case, we should perform the redirections in
|
||||
exec_redirection_undo_list (saved_undo_list) like usual. */
|
||||
if (saved_undo_list)
|
||||
{
|
||||
dispose_redirects (saved_undo_list); /* exec_redirection_undo_list */
|
||||
discard_unwind_frame ("saved-redirects");
|
||||
}
|
||||
saved_undo_list = exec_redirection_undo_list = (REDIRECT *)NULL;
|
||||
}
|
||||
/* This code is no longer executed and remains only for explanatory reasons. */
|
||||
else if (builtin == command_builtin && this_shell_builtin == exec_builtin)
|
||||
{
|
||||
/* If we are executing the `command' builtin, but this_shell_builtin is
|
||||
set to `exec_builtin', we know that we have something like
|
||||
`command exec [redirection]', since otherwise `exec' would have
|
||||
overwritten the shell and we wouldn't get here. In this case, we
|
||||
want to behave as if the `command' builtin had not been specified
|
||||
and preserve the redirections. */
|
||||
if (saved_undo_list)
|
||||
{
|
||||
dispose_redirects (saved_undo_list);
|
||||
discard = 1;
|
||||
dispose_redirects (saved_undo_list); /* redirection_undo_list */
|
||||
discard_unwind_frame ("saved-redirects");
|
||||
}
|
||||
redirection_undo_list = exec_redirection_undo_list;
|
||||
saved_undo_list = exec_redirection_undo_list = (REDIRECT *)NULL;
|
||||
if (discard)
|
||||
discard_unwind_frame ("saved-redirects");
|
||||
}
|
||||
|
||||
if (saved_undo_list)
|
||||
|
||||
Reference in New Issue
Block a user