chore: upstream `run_cmd` and fixes bugs (#3324)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
8 files changed