mirror of
https://github.com/mirror/make.git
synced 2026-09-01 04:08:10 +08:00
[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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user