Actually, that touches on a larger issue. I think it should be possible to just do:
cmd.execute("sudo apt-get install xyz > /tmp/output.txt")
instead of:
cmd.execute(:sudo, "apt-get", "install", ...)
This is the most common use case, in my opinion, and supporting this pattern will encourage people to stop using bash to write this stuff.