title: set Powershell core as a default GNU Make shell on windows/linux
body: <p>In the makefile on Windows.</p>
  
  <p>With the following make version:</p>
  
  <pre><code>PS C:\projects&gt; make --version
  GNU Make 4.1
  Built for i686-w64-mingw32
  Copyright (C) 1988-2014 Free Software Foundation, Inc.
  </code></pre>
  
  <p>I have tried to set <code>SHELL := pwsh</code> / <code>COMSPEC := pwsh</code> and run command without explicit shell specifying:</p>
  
  <pre><code># COMSPEC := pwsh -c
  SHELL := pwsh -c
  
  VAR=asdf/asdf
  
  .PHONY: get_var
  
  get_var:
      @Write-Output $(VAR)
  </code></pre>
  
  <p>without success. I've got an error:</p>
  
  <pre><code>PS C:\projects\makefile_factory&gt; make -f .\fi.makefile get_var
  process_begin: CreateProcess(NULL, Write-Output asdf/asdf, ...) failed.
  make (e=2): ═х єфрхЄё  эрщЄш єърчрээ√щ Їрщы.
  .\fi.makefile:10: recipe for target 'get_var' failed
  make: *** [get_var] Error 2
  </code></pre>
  
  <p>If shell specified explicitly in the command, it works:</p>
  
  <pre><code># COMSPEC := pwsh -c
  # SHELL := pwsh -c
  
  VAR=asdf/asdf
  
  .PHONY: get_var
  
  get_var:
      @pwsh -c Write-Output $(VAR)
  </code></pre>
  
  <p>run:</p>
  
  <pre><code>PS C:\projects\makefile_factory&gt; make -f .\fi.makefile get_var
  asdf/asdf
  </code></pre>
  
  <p>Also, i've looked into <a href="https://www.gnu.org/software/make/manual/make.html#Choosing-the-Shell" rel="nofollow noreferrer">make documentation</a>:</p>
  
  <blockquote>
    <p>However, on MS-DOS <strong>and MS-Windows the value of SHELL in the
    environment is used</strong>, 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.</p>
  </blockquote>
  
  <p>So i tried to set environment variable SHELL/MAKESHELL with no result:</p>
  
  <pre><code>PS C:\projects\makefile_factory&gt; $env:SHELL
  C:\Program Files\PowerShell\7\pwsh.exe
  PS C:\projects\makefile_factory&gt; $env:MAKESHELL
  C:\Program Files\PowerShell\7\pwsh.exe
  PS C:\projects\makefile_factory&gt; make -f .\fi.makefile get_var
  Write-Output asdf/asdf
  process_begin: CreateProcess(NULL, Write-Output asdf/asdf, ...) failed.
  make (e=2): ═х єфрхЄё  эрщЄш єърчрээ√щ Їрщы.
  .\fi.makefile:9: recipe for target 'get_var' failed
  make: *** [get_var] Error 2
  </code></pre>
  
  <p>So, isn't there a way to specify pwsh as a default shell?</p>