stdenv: fail if the patch does not exist
stdenv: added escaping for patches
stdenv: Fix handling spaces in 'substitute'
stdenv: change 'echo -n' to 'printf "%s"'

[Bjørn: rationale is portability, "echo -n" isn't in POSIX]