Avoid shell-escaping and the shell altogether! Use list form program execution wherever possible.
In Perl:
open(my $fh, "-|", "find", $dir, "-type", "f", "-print0") or die;
In Python: f = os.popen2(["find", dir, "-type", "f", "-print0"])
If you're executing a pipeline, you do need to get the shell involved. But I'd probably write the author's examples like so (once again avoiding the need to shell escape arguments): f = os.popen2(["sh", "-c", \
'find "$0" -type f -print0 | xargs -0 grep foo | wc -l', dir])
2. Prefixing each multi-command pipeline with “set -o pipefail;Alas, pipefail is not in POSIX /bin/sh, which many of us prefer for shell scripting. It's in bash and ksh though.
3. Explicitly checking for failure after each shelled out command
Valid. You should always do this. In shell scripts, "set -e" is a good thing, although pipelines without "set -o pipefail" are still a problem.