]> git.ipfire.org Git - thirdparty/make.git/commit
[SV 63040] shell: Fall back to the callers environment
authorPaul Smith <psmith@gnu.org>
Sat, 10 Sep 2022 20:21:23 +0000 (16:21 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 10 Sep 2022 20:27:47 +0000 (16:27 -0400)
commit70ba0357a080f72b9f5912f16b3ffc095db381e6
treefef33bac04c3d9c8708b7dee86341ffb358ba99a
parent7d484017077089ac2642b89da8984ca46a07323d
[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.
NEWS
doc/make.texi
src/expand.c
tests/scripts/functions/shell