detect the problem beforehand rather than relying on $PIPESTATUS