g_spawn_*() can't run scripts on Windows
It goes through series of weird gyrations, but eventually it boils down to it calling _wspawnvp()
or _wspawnv()
, neither of which is capable of running a script.
This is why spawn-singlethread
test fails on Windows. Note that changing the test to use .bat
file instead of a shell script has no positive result - _wspawnv[p]()
is not capable of running either.
There are two ways this can be fixed.
- Implement shebang parsing in glib spawn helper. This is doable, but can obviously be a source of many delicious bugs.
- Run any non-binary (identifying PE executables is easy) program via some kind of shell. Use
SHELL
, if it's set (assume that it's a *nix shell), otherwise useCOMSPEC
(assume it's a Windows cmd shell). This will have a number of interesting interactions with I/O redirection, exist codes, etc. Also, quoting arguments would be extremely tricky (the preferable tactic for such cases is to write a shell script that runs the stuff we need with the right arguments, and then make the shell run just that, thus sidestepping the problem of quoting arbitrary arguments on commandline, replacing it with a problem of quoting arbitrary arguments inside a shell script - which is at least somewhat solvable).