0

I came across this question/answer [execute powershell commands in makefile][1]. I want to execute powershell commands in my makefile. I can run my command in powershell with no issues, but when I execute the command in my makefile, I get a bash syntax error. My code looks like this:

powershell sqlcmd -S testdb -m 1 -W -s "|" -f o:65001 -q ":r test1.sql n:r test2.sql n:out raw\sql_results.txt'

The error I get is

/usr/bin/sh: -c: line 0: unexpected EOF while looking for matching ``' /usr/bin/sh: -c: line 1: syntax error: unexpected end of file Do I need to escape the acute symbol before each n:? Again, powershell handles this syntax fine. Any ideas? [1]: https://stackoverflow.com/a/51697219/3737798

d84_n1nj4
  • 1,712
  • 6
  • 23
  • 40
  • Clearly your version of make is not invoking powershell, it's invoking a POSIX shell (sh). So no amount of powershell trickery will help you. Unfortunately unlike POSIX systems, the situation with shells on Windows is extremely complicated. Different builds of make will use different shells by default: some use `cmd.exe`, some use `sh`. I'm not aware of any build that uses powershell by default. You can set the `SHELL` variable in your makefile to the path to the shell program you want to be used, instead of the default. – MadScientist Jul 09 '21 at 16:16
  • Be aware, though, that this sets the shell for ALL recipes in your makefile. If you want to only run one specific recipe in powershell you'll have to do something more complicated. – MadScientist Jul 09 '21 at 16:17

0 Answers0