Port shellescape from Ruby stdlib.
Format according to PEP8.