Re: Which behavior is expected of $(shell )

Paul Smith <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Organization GNU's Not UNIX!
Message-ID <[email protected]>
On Tue, 2022-11-22 at 11:12 +0800, Changqing Li wrote:
> Here is what the make manual says,
> 
> 6.10 Variables from the Environment

It's not really related to this section.  It's related to how the shell
function works.  From that section of the manual we see:

| All variables that are marked as export will also be passed to the
| shell started by the shell function.

In your example, KBUILD_OUTPUT is coming from the environment, and all
variables imported from the environment automatically exported.  So,
the value of the KBUILD_OUTPUT variable set in the makefile is exported
to the shell function.

However, this behavior is new in GNU make 4.4.

> the value in shell environment like what 4.3  done. But I don't find 
> which commit or bug ID is for fixing this issue,  so I send this mail
> to double check with the exports at this. Thanks a lot.

See this from the NEWS file for GNU make 4.4:

https://git.savannah.gnu.org/cgit/make.git/tree/NEWS?h=4.4&id=ed493f6c9116cc217b99c2cfa6a95f15803235a2#n74

> * WARNING: Backward-incompatibility!
>   Previously makefile variables marked as export were not exported to commands
>   started by the $(shell ...) function.  Now, all exported variables are
>   exported to $(shell ...).

This is the reason for the difference in behavior you see.
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.