diff --git a/src/variable.c b/src/variable.c index d9e1a4a6..94e925fb 100644 --- a/src/variable.c +++ b/src/variable.c @@ -282,6 +282,8 @@ define_variable_in_set (const char *name, size_t length, v->export = v_default; v->exportable = 1; + /* Check the nul-terminated variable name. */ + name = v->name; if (*name != '_' && (*name < 'A' || *name > 'Z') && (*name < 'a' || *name > 'z')) v->exportable = 0; diff --git a/tests/scripts/features/targetvars b/tests/scripts/features/targetvars index 66c7ce2d..08263bf3 100644 --- a/tests/scripts/features/targetvars +++ b/tests/scripts/features/targetvars @@ -281,6 +281,16 @@ all: ; $sname unlink("sd/$sname"); rmdir ('sd'); +# SV 59230: Conditional (non-)assignment of target-specific variables should +# preserve export settings. + +$ENV{hello} = 'moon'; +run_make_test(q! +all:; @echo hello=$$hello +dummy: hello?=world +!, + '', 'hello=moon'); + # TEST #19: Test define/endef variables as target-specific vars # run_make_test('