Fix exit code handling in shell.