Child process should not raise exception, but exit with error code in case of error.

Either successfully setup environment and execute the given command, or exit with error code.
Only the parent process should raise exceptions.
User of sh module does not expect that their exception handler could catch exceptions in child process created by sh module.
If too general exception handling (e.g. try: ... except: pass) is used, then the child process can continue in execution of program.
( Sorry for the big diff. The change is only wrapping of the whole child process block in try: ... finally: ... )