mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-24 12:58:39 +00:00
Don't add GNUMAKEFLAGS to the environment
If GNUMAKEFLAGS was not present in the environment when we started, don't add it. * src/main.c (main): Don't mess with GNUMAKEFLAGS unless it exists. * tests/scripts/variables/GNUMAKEFLAGS: Test this behavior.
This commit is contained in:
parent
84ed34ba5a
commit
3ec497f8f8
2 changed files with 19 additions and 4 deletions
11
src/main.c
11
src/main.c
|
@ -1413,7 +1413,7 @@ main (int argc, char **argv, char **envp)
|
|||
|
||||
/* If this is MAKE_RESTARTS, check to see if the "already printed
|
||||
the enter statement" flag is set. */
|
||||
if (len == 13 && memcmp (envp[i], "MAKE_RESTARTS", 13) == 0)
|
||||
if (len == 13 && memcmp (envp[i], STRING_SIZE_TUPLE ("MAKE_RESTARTS")) == 0)
|
||||
{
|
||||
if (*ep == '-')
|
||||
{
|
||||
|
@ -1480,10 +1480,13 @@ main (int argc, char **argv, char **envp)
|
|||
#endif
|
||||
|
||||
/* Decode the switches. */
|
||||
decode_env_switches (STRING_SIZE_TUPLE (GNUMAKEFLAGS_NAME));
|
||||
if (lookup_variable (STRING_SIZE_TUPLE (GNUMAKEFLAGS_NAME)))
|
||||
{
|
||||
decode_env_switches (STRING_SIZE_TUPLE (GNUMAKEFLAGS_NAME));
|
||||
|
||||
/* Clear GNUMAKEFLAGS to avoid duplication. */
|
||||
define_variable_cname (GNUMAKEFLAGS_NAME, "", o_env, 0);
|
||||
/* Clear GNUMAKEFLAGS to avoid duplication. */
|
||||
define_variable_cname (GNUMAKEFLAGS_NAME, "", o_env, 0);
|
||||
}
|
||||
|
||||
decode_env_switches (STRING_SIZE_TUPLE (MAKEFLAGS_NAME));
|
||||
|
||||
|
|
|
@ -39,4 +39,16 @@ x.mk: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLA
|
|||
|
||||
unlink('x.mk');
|
||||
|
||||
# Ensure that we don't add GNUMAKEFLAGS to the environment if it's not there
|
||||
run_make_test(q!
|
||||
all: ; @env | grep GNUMAKEFLAGS; true
|
||||
!,
|
||||
'', '');
|
||||
|
||||
$ENV{GNUMAKEFLAGS} = '-Itst/bad';
|
||||
run_make_test(q!
|
||||
all: ; @env | grep GNUMAKEFLAGS; true
|
||||
!,
|
||||
'', 'GNUMAKEFLAGS=');
|
||||
|
||||
1;
|
||||
|
|
Loading…
Reference in a new issue