Since these functions are MinGW-specific, they better belong into this
compatibility file. They will be needed there in a follow-up change that
reimplements execvp().
In this case, no path lookup actually takes place, and the returned
program name is equal to the passed in program name. But this code
path contained a thinko that crashed.
For this purpose the path lookup is done manually, and the found file
is inspected for the interpreter. If one is found, the script is spawned
under the interpreter; otherwise, the program is spawned normally.
Windows does not have fork(), but something called spawn() that is roughly
equivalent to a fork()/exec() pair, factor out the Unix style code into
a function that does it more similarly to spawn(). Now the Windows style
spawn() can more easily be employed to achieve the same that the Unix style
code does.