Use branches_cmd to substitute commands used several times.

Use abort() to write to `stderr` instead of `stdout` and automatically
exit the script.