When checking for invalid environment variable names we searched the
entire name string instead of just the first LENGTH chars; this could
cause us to incorrectly decide the variable was not exportable.
Dmitry Goncharov <dgoncharov@users.sf.net> found this bug and
provided a test case and sample fix: I used the test but chose a
slightly different fix.
* src/variable.c (define_variable_in_set): check the variable name
not the input string.
* tests/scripts/features/targetvars: Ensure environment variable
values are exported.
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;
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('