def shell_comment(c):
    'Do not shell-escape raw strings in comments, but do handle line breaks.'
    return ShellQuoted('# {c}').format(c=ShellQuoted(
        (raw_shell(c) if isinstance(c, ShellQuoted) else c)
            .replace('\n', '\n# ')
    ))
Do not shell-escape raw strings in comments, but do handle line breaks.