From c2058ec98cf3f6722be4436cae07a386e3c7b48d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 22 Feb 2020 20:25:03 +0100 Subject: ash: Expand here-documents in the current shell environment Upstream commit: Date: Sun, 11 Nov 2007 15:27:00 +0800 Expand here-documents in the current shell environment Previously we always expanded here-documents in a subshell. This is contrary to the POSIX specification and how other shells behave. What's more this slows down many expansions due to the extra fork (however, it must be said that it is possible for it speed up certain expansions by running it simultaneously with the command on two CPUs). This patch move the expansion into the current shell environment. Test case: unset a cat <<- EOF > /dev/null ${a=NOT} EOF echo ${a}BAD Old result: BAD New result: NOTBAD Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-heredoc/heredoc_side_effects.right | 1 + shell/ash_test/ash-heredoc/heredoc_side_effects.tests | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 shell/ash_test/ash-heredoc/heredoc_side_effects.right create mode 100755 shell/ash_test/ash-heredoc/heredoc_side_effects.tests (limited to 'shell/ash_test') diff --git a/shell/ash_test/ash-heredoc/heredoc_side_effects.right b/shell/ash_test/ash-heredoc/heredoc_side_effects.right new file mode 100644 index 000000000..53b2c03c1 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc_side_effects.right @@ -0,0 +1 @@ +NO BUG diff --git a/shell/ash_test/ash-heredoc/heredoc_side_effects.tests b/shell/ash_test/ash-heredoc/heredoc_side_effects.tests new file mode 100755 index 000000000..3fb622ae4 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc_side_effects.tests @@ -0,0 +1,5 @@ +unset a +cat </dev/null +${a=NO} +EOF +echo $a BUG -- cgit v1.2.3