I have to implement the BASH set -o pipefail option in a POSIX way so that it works on various LINUX/UNIX flavors. To explain a bit, this option enables the user to
#!/bin/sh
# Saving the pid of the main shell is required,
# as each element of the pipe is a subshell.
self=$$
lots_and_fail() {
seq 100
return 1
}
{ lots_and_fail || kill $self; } | sed s/7/3/