Subject: Re: [PATCH 1/6] CodingGuidelines: describe "export VAR=VAL" rule

From: Junio C Hamano <[email-masked]>
Date: Sat, 06 Apr 2024 10:03:42 -0700

Andreas Schwab <[email-masked]> writes:

>> I suspect you meant:
>>
>>    ... and suggest us to instead write it as "VAR=VAL" followed by
>>    "export VAR".
>
> There is no difference between them.  The export command only marks the
> variable for export, independent of the current or future value of the
> variable.  The exported value is always the last assigned one.

Correct.

But we are talking about working around sub-standard (read: buggy)
implementations and it is of dubious value to assume a compliant
implementation when devising a workaround.

It is easily imaginable that a sub-standard implementation uses a
symbol table with a single "is it exported?" bit in addition to
(name, value), without a way to say "this parameter is not set
(yet)" (IOW, never value==NULL), and such an implementation would
not be capable to have "this name is exported but nobody set the
value to it yet".  Using an assignment to make sure it is known
before setting the exported bit is safer to protect against such an
implementation.