u/fjammes/dm-1497

PR for review.
I would not go as far as replacing all `echo` commands with `printf`. `echo` is still OK for simple use cases when you don't care about newline or other control characters.