shell: fix newlines

This is a subset of #1038.
Fixes #1253.