set Powershell core as a default GNU Make shell on windows/linux


In the makefile on Windows.

With the following make version:

I have tried to set SHELL := pwsh / COMSPEC := pwsh and run command without explicit shell specifying:

without success. I’ve got an error:

If shell specified explicitly in the command, it works:


Also, i’ve looked into make documentation:

However, on MS-DOS and MS-Windows the value of SHELL in the
environment is used
, since on those systems most users do not set this
variable, and therefore it is most likely set specifically to be used
by make. On MS-DOS, if the setting of SHELL is not suitable for make,
you can set the variable MAKESHELL to the shell that make should use;
if set it will be used as the shell instead of the value of SHELL.

So i tried to set environment variable SHELL/MAKESHELL with no result:

So, isn’t there a way to specify pwsh as a default shell?


What @raspy says is true, but, I found a glorious workaround!

If you take a look at this if statement right here you’ll notice that if the shellflags is set to something besides -c or -ce it will always use the slow option (Which means it will always execute through the SHELL rather the binary directly! 🎉🎉). Luckily for us, we can set the .SHELLFLAGS directly, take a look at these docs

In any event, all that means we need to do is set the .SHELLFLAGS to something besides -c or -ce, for example with powershell we can use -Command, tying it all together:

Or, in my example where I want PowerShell.exe on Windows & the default shell on Linux:



set Powershell core as a default GNU Make shell on windows/linux by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply