Fix #1292

Tested on OSX and Linux; I have no way to test this change on Windows, unfortunately, so further review is needed.

Spaces are escaped properly, but I had to add an ad-hoc check for node-webkit arguments because, on OS X, light.sh seems to launch LT twice; this check is unsound, albeit not significantly more so than the `dir` parsing already was.