Hello, portage provides good function to check errors on pipes: assert. It is mentioned in the dev manual: https://devmanual.gentoo.org/ebuild-writing/error-handling/index.html but is not mentioned in the man 5 ebuild. This should be fixed. Thanks!
I have a patch for this in the following branch: https://github.com/zmedico/portage/tree/bug_528760 I've posted it for review here: http://thread.gmane.org/gmane.linux.gentoo.portage.devel/4761
This is in git now: https://github.com/gentoo/portage/commit/7f38c9cbe3ce4a1eb4791b81b1ccd1a2f4eebfd1
This was released in 2.1.15.