On Tue, 2022-01-18 at 12:38 -0800, Jon Forrest wrote:
> On 1/18/2022 10:55 AM, Paul Smith wrote:> 
> > All versions of make, including GNU make, invoke each logical line
> > of the recipe in a separate shell.
> 
> I'm curious what would happen if each logical line were executed in
> the same shell.

I guess what you really mean is if ALL logical lines (in a recipe) were
executed in the same shell.

You can achieve this if you want: that's what the .ONESHELL feature
does.

https://www.gnu.org/software/make/manual/html_node/One-Shell.html

However, blindly enabling this for makefiles which aren't written to
expect it WILL break them.  Many makefile recipes take advantage of
this "one line per shell" facility, by doing things like:

  foo:
          cd subdir && do command
          cd otherdir && do command

If these were run in the same shell this would work completely
differently.


Reply via email to