From a275f4e9ab14a2ff827b67b46dd3bc746cdba328 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 8 Jan 2023 16:40:55 -0500 Subject: [SV 61218] Ensure MAKEFLAGS is expanded even with -e If -e was given we weren't expanding MAKEFLAGS before passing it through the environment to jobs: we don't expand variables we receive from the environment and when -e is given we set the origin of MAKEFLAGS to "environment override". Check for MAKEFLAGS specifically, which seems like a hack but I don't have a better idea offhand. * src/main.c (main): Drive-by: use o_default for MAKEOVERRIDES. * src/variable.c (target_environment): Always expand MAKEFLAGS regardless of the origin type. * tests/scripts/options/dash-e: Create a test. --- src/main.c | 2 +- src/variable.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 433f5826..cf2324d1 100644 --- a/src/main.c +++ b/src/main.c @@ -1920,7 +1920,7 @@ main (int argc, char **argv, char **envp) allow the user's setting of MAKEOVERRIDES to affect MAKEFLAGS, so a reference to this hidden variable is written instead. */ define_variable_cname ("MAKEOVERRIDES", "${-*-command-variables-*-}", - o_env, 1); + o_default, 1); #ifdef VMS vms_export_dcl_symbol ("MAKEOVERRIDES", "${-*-command-variables-*-}"); #endif diff --git a/src/variable.c b/src/variable.c index 009ee540..7b625aee 100644 --- a/src/variable.c +++ b/src/variable.c @@ -1114,8 +1114,9 @@ target_environment (struct file *file, int recursive) /* If V is recursively expanded and didn't come from the environment, expand its value. If it came from the environment, it should - go back into the environment unchanged. */ - if (v->recursive && v->origin != o_env && v->origin != o_env_override) + go back into the environment unchanged... except MAKEFLAGS. */ + if (v->recursive && ((v->origin != o_env && v->origin != o_env_override) + || streq (v->name, MAKEFLAGS_NAME))) value = cp = recursively_expand_for_file (v, file); /* If this is the SHELL variable remember we already added it. */ -- cgit v1.2.1