ghmerge: improve error handling
When python3 is the default python interpreter, the embedded script
fails with a syntax error at the print statement. In the absence of
error checking, this leads to a cascade of unhandled errors, ending
up in an empty pager window. Here an example:
ghmerge prnum reviewer1 reviewer2
- the empty output of the python command causes the env command to print
the (named and positional) parameters instead of clearing $1 and $2.
Consequently, the script assigns WHO=reviewer1 and BRANCH=reviewer2.
- git checks out a local branch reviewer1-reviewer2 and tries to pull
from https://github.com/reviewer1/openssl.git reviewer2
This call fails, and again the error is ignored.
- The call `git diff reviewer1-reviewer2` leads to the empty pager
window, since git has no diffs to show.
Countermeasures
- make the python script work for python2 and python3
- add a break-on-error statement (`set -o errexit`, aka `set -e`)
- replace `set` by `set --` which changes the behaviour of the set
command as desired (see `man set`).
- add an explicit check for $WHO and $BRANCH
- add an exit trap for cleaning up the branch
Signed-off-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>