bitbake: build.py: create separate function for shell trap creation code

Currently, the shell trap code was created in exec_func_shell(). Split
the function so that we can create the code separately.

Also, some whitespaces were automatically deleted by my editor. Since
this is not necessarily a bad thing, leave these changes too.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>