diff --git a/README.md b/README.md
index 3d1d27f83cf8fa71a883db1b70b4f5af7659d35f..663f783165028041bcfbd08749f03f6611716f5d 100644
--- a/README.md
+++ b/README.md
@@ -83,9 +83,11 @@ To compile the above and get each manifest in a separate file on disk use the fo
 #!/usr/bin/env bash
 set -e
 set -x
+# only exit with zero if all commands of the pipeline exit successfully
+set -o pipefail
 
                                                # optional, but we would like to generate yaml, not json
-jsonnet -J vendor -m manifests example.jsonnet | xargs -I{} sh -c 'cat $1 | gojsontoyaml > $1.yaml; rm $1' -- {}
+jsonnet -J vendor -m manifests example.jsonnet | xargs -I{} sh -c 'cat $1 | gojsontoyaml > $1.yaml; rm -f $1' -- {}
 
 ```
 
diff --git a/build.sh b/build.sh
index 30e758524b7ea3ad68c28578293bbd86902490af..9c22672eeaaf7e0aa64653e3fbb65036cd7966e4 100755
--- a/build.sh
+++ b/build.sh
@@ -1,6 +1,8 @@
 #!/usr/bin/env bash
 set -e
 set -x
+# only exit with zero if all commands of the pipeline exit successfully
+set -o pipefail
 
                                                # optional, but we would like to generate yaml, not json
 jsonnet -J vendor -m manifests example.jsonnet | xargs -I{} sh -c 'cat $1 | gojsontoyaml > $1.yaml; rm -f $1' -- {}