diff --git a/shelly.cabal b/shelly.cabal
--- a/shelly.cabal
+++ b/shelly.cabal
@@ -1,6 +1,6 @@
 Name:       shelly
 
-Version:     1.6.3.3
+Version:     1.6.3.4
 Synopsis:    shell-like (systems) programming in Haskell
 
 Description: Shelly provides convenient systems programming in Haskell,
diff --git a/src/Shelly.hs b/src/Shelly.hs
--- a/src/Shelly.hs
+++ b/src/Shelly.hs
@@ -1077,7 +1077,11 @@
 
 bashArgs :: FilePath -> [Text] -> [Text]
 bashArgs fp args =
-  ["-c", "'set -o pipefail; " <> sanitise (toTextIgnore fp : args) <> "'"]
+  -- trapping PIPE is needed to avoid random failures from setting pipefail
+  --
+  -- https://github.com/yesodweb/Shelly.hs/issues/106
+  -- http://stackoverflow.com/questions/22464786/ignoring-bash-pipefail-for-error-code-141
+  ["-c", "'set -o pipefail; trap '' PIPE; " <> sanitise (toTextIgnore fp : args) <> "'"]
   where
     sanitise = T.replace "'" "\'" . T.intercalate " "
 
