Re: How to privately export a variable?

Paul Smith <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Organization GNU's Not UNIX!
Message-ID <[email protected]>
On Sun, 2023-01-08 at 21:14 +0900, Masahiro Yamada wrote:
> I expected "private export" would mean
> "privately export", but it is the same as "export".
> The variable is exported not only to 'foo',
> but also to 'bar' and 'baz'.

This is a bug, which has been fixed for the next release:

https://savannah.gnu.org/bugs/?61463

In the meantime it will work to separate the export from the private,
like this:

    FOR_FOO := global

    foo: private export FOR_FOO = $(p_FOO)
    foo: private p_FOO := 1

    foo: bar baz
    foo bar baz: ; @echo $@: $$FOR_FOO

(the "private" on the first foo: line doesn't have the desired effect
until the above bug is fixed but I left it there anyway).

Note it's of course critically important to use "=" in the export
assignment, not ":=".
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.