Devscript bash refactoring

Code cleanup, very little functional change