backport check_output