def shell_escape(s):
if isinstance(s, PosixPath):<EOL><INDENT>s = unicode_(s)<EOL><DEDENT>elif isinstance(s, bytes):<EOL><INDENT>s = s.decode('<STR_LIT:utf-8>')<EOL><DEDENT>if not s or any(c not in safe_shell_chars for c in s):<EOL><INDENT>return '<STR_LIT>' % (s.replace('<STR_LIT:\\>', '<STR_LIT>')<EOL>.replace('<STR_LIT:">', '<STR_LIT>')<EOL>.replace('<STR_LIT>', '<STR_LIT>')<EOL>.replace('<STR_LIT:$>', '<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>return s<EOL><DEDENT>
r"""Given bl"a, returns "bl\\"a".