command builtin should not abort on variable assignment errors

Resolves: #1389838
This commit is contained in:
Siteshwar Vashisht 2017-05-30 06:45:50 +02:00
parent 31a9b53e19
commit b316f71360
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,31 @@
diff --git a/execute_cmd.h b/execute_cmd.h
--- a/execute_cmd.h
+++ b/execute_cmd.h
@@ -37,6 +37,9 @@ struct func_array_state
};
#endif
+/* Variables delared in execute_cmd.c, used by many other files */
+extern int executing_command_builtin;
+
extern struct fd_bitmap *new_fd_bitmap __P((int));
extern void dispose_fd_bitmap __P((struct fd_bitmap *));
extern void close_fd_bitmap __P((struct fd_bitmap *));
diff --git a/subst.c b/subst.c
--- a/subst.c
+++ b/subst.c
@@ -10676,11 +10676,12 @@ expand_word_list_internal (list, eflags)
tint = do_word_assignment (temp_list->word, 0);
this_command_name = savecmd;
/* Variable assignment errors in non-interactive shells
- running in Posix.2 mode cause the shell to exit. */
+ running in Posix.2 mode cause the shell to exit, unless
+ they are being run by the `command' builtin. */
if (tint == 0)
{
last_command_exit_value = EXECUTION_FAILURE;
- if (interactive_shell == 0 && posixly_correct)
+ if (interactive_shell == 0 && posixly_correct && executing_command_builtin == 0)
exp_jump_to_top_level (FORCE_EOF);
else
exp_jump_to_top_level (DISCARD);

View File

@ -8,7 +8,7 @@
Version: %{baseversion}%{patchleveltag} Version: %{baseversion}%{patchleveltag}
Name: bash Name: bash
Summary: The GNU Bourne Again shell Summary: The GNU Bourne Again shell
Release: 4%{?dist} Release: 5%{?dist}
License: GPLv3+ License: GPLv3+
Url: http://www.gnu.org/software/bash Url: http://www.gnu.org/software/bash
Source0: ftp://ftp.gnu.org/gnu/bash/bash-%{baseversion}.tar.gz Source0: ftp://ftp.gnu.org/gnu/bash/bash-%{baseversion}.tar.gz
@ -86,6 +86,10 @@ Patch128: bash-4.4-heredoc-cloexec.patch
# This should be dropped while rebasing to bash-4.5 # This should be dropped while rebasing to bash-4.5
Patch129: bash-4.4-unset-nonblock-stdin.patch Patch129: bash-4.4-unset-nonblock-stdin.patch
# 1389838 - command builtin should not abort on variable assignment errors
# This should be dropped while rebasing to bash-4.5
Patch130: bash-4.4-assignment-error.patch
BuildRequires: texinfo bison BuildRequires: texinfo bison
BuildRequires: ncurses-devel BuildRequires: ncurses-devel
BuildRequires: autoconf, gettext BuildRequires: autoconf, gettext
@ -302,6 +306,10 @@ end
%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt %doc doc/*.ps doc/*.0 doc/*.html doc/article.txt
%changelog %changelog
* Tue May 30 2017 Siteshwar Vashisht <svashisht@redhat.com> - 4.4.12-5
- command builtin should not abort on variable assignment errors
Resolves: #1389838
* Wed Apr 26 2017 Siteshwar Vashisht <svashisht@redhat.com> - 4.4.12-4 * Wed Apr 26 2017 Siteshwar Vashisht <svashisht@redhat.com> - 4.4.12-4
- Explicitly unset nonblocking mode while reading from stdin - Explicitly unset nonblocking mode while reading from stdin
Resolves: #1068697 Resolves: #1068697