Fix some issues with different shell and error messages. Checked on x86_64-linux-gnu and i686-linux-gnu. (cherry picked from commit 4eda036f)