Condense some of the code in ShellUtils