I have the following git pre-commit hook in Windows:
#!/bin/sh
./bin/Verification.exe
if [ $? -ne 0 ]
then
echo "Failed verfication: canceling commit"
exit 1
fi
exit 0
Verification.exe is a .Net console app the I boiled down to this for testing purposes:
static int Main(string[] args)
{
return -1;
}
The issue is that the bash script does not seem to make the exit code from the console app (i.e. -1) available in the $? variable. The exe runs, but the if-condition is always true in the script. I tried running Verification.exe from a Windows batch file with an "echo %errorlevel%" and it returns -1 as expected.
How do I test for the exit code inside the pre-commit script?