From: foo on
Try this:

#!/bin/sh

set -e

set -o pipefail

FOO=3D`false | sed s/foo/bar/g` || exit 1

echo didnt exit