Sometimes when commands fail no output is sent to STDERR, sometimes it comes in STDOUT instead

So checking that and using it if STDERR is empty

(cherry picked from commit 271fb5ff53957c31c673422006c24e900b881d84)