Reverted changes from previous #2786 commit (closes #2786)

In order to circumvent shell interpolation and evaluation, the command
is now written to a temporary script that is executed. This allows to
properly isolate the command and our shell redirects around it.