diff --git a/src/read.c b/src/read.c index 3553fd79..9e2c1695 100644 --- a/src/read.c +++ b/src/read.c @@ -1832,7 +1832,8 @@ record_target_var (struct nameseq *filenames, char *defn, /* Set up the variable to be *-specific. */ v->per_target = 1; v->private_var = vmod->private_v; - v->export = vmod->export_v ? v_export : v_default; + if (vmod->export_v) + v->export = v_export; /* If it's not an override, check to see if there was a command-line setting. If so, reset the value. */ diff --git a/tests/scripts/features/targetvars b/tests/scripts/features/targetvars index 08263bf3..14b9f1da 100644 --- a/tests/scripts/features/targetvars +++ b/tests/scripts/features/targetvars @@ -86,7 +86,6 @@ run_make_test(undef, "foo.q bar.q", "qvar = rvar\nqvar =\n"); run_make_test(undef, "foo.t bar.s", "qvar = qvar\nqvar =\n"); - # TEST #8 # For PR/1378: Target-specific vars don't inherit correctly @@ -291,6 +290,17 @@ dummy: hello?=world !, '', 'hello=moon'); +# SV 59230: Assignment of a global variable should not affect export of a +# target specific variable. + +$ENV{hello} = "moon"; +run_make_test(q! +all:; @echo hello=$$hello +hello=sun +dummy: hello?=world +!, + '', 'hello=sun'); + # TEST #19: Test define/endef variables as target-specific vars # run_make_test('