rebase -i -p: fixes required for MacOSX

MacOSX' shell and sed are a bit challenged with the way this developer
writes shell scripts. One problem is that the shell cannot really handle
statements like this one:

	y="$(for x in 1 2
		do
			case "$x" in
			1)
				echo "Buwahahaha!"
				;;
			esac
		done)"

It mistakes the ')' in the case statement as the end of the command. The
workaround is to use the backtick instead.

The problem with sed is that it neither handles alternative grouping
with '|' (i.e. "\(a|b\)" won't match "a" nor "b"), nor does it
interpolate '\n' on the right-hand side. We work around the former by
having multiple clauses, and around the latter problem by using a shell
variable LF that we assigned a newline beforehand.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>