summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2022-09-10 16:21:23 -0400
committerPaul Smith <psmith@gnu.org>2022-09-10 16:27:47 -0400
commit70ba0357a080f72b9f5912f16b3ffc095db381e6 (patch)
treefef33bac04c3d9c8708b7dee86341ffb358ba99a /tests
parent7d484017077089ac2642b89da8984ca46a07323d (diff)
downloadmake-git-70ba0357a080f72b9f5912f16b3ffc095db381e6.tar.gz
[SV 63040] shell: Fall back to the callers environment
If we detect a recursive variable reference when constructing the environment for the shell function, return the original value from the caller's environment. Other options such as failing, returning the empty string, or returning the unexpanded make variable value have been shown to not behave well in real-world environments. If the variable doesn't exist in the caller's environment, return the empty string. Found by Sergei Trofimovich <slyich@gmail.com> when testing older versions of autoconf. * NEWS: Clarify this behavior. * doc/make.texi (Shell Function): Ditto. Also add info about !=. * src/expand.c (recursively_expand_for_file): Search the caller's environment if we detect a recursive variable expansion. * tests/scripts/functions/shell: Add tests for this behavior.
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/functions/shell16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/scripts/functions/shell b/tests/scripts/functions/shell
index a5bd5ddc..e889b5f7 100644
--- a/tests/scripts/functions/shell
+++ b/tests/scripts/functions/shell
@@ -98,6 +98,22 @@ all:; : $(HI)
',
'',": hi");
+$ENV{HI} = 'outer';
+run_make_test('
+export HI = $(shell echo $$HI)
+.PHONY: all
+all:; @echo $$HI
+',
+ '',"outer");
+
+$ENV{HI} = 'outer';
+run_make_test('
+export HI = $(shell echo $$HI)
+.PHONY: all
+all:; : $(HI)
+',
+ '',": outer");
+
if ($port_type ne 'W32') {
# Test shell errors in recipes including offset
# This needs to be ported to Windows, or else Windows error messages