Fixes #1135. Command prefix is applied before shell_env.

Reverses the order in which `shell_env` and `prefix` are applied to a command.