def shell_escape(text, _safe=re.compile(r"<STR_LIT>")):
if not text or _safe.match(text):<EOL><INDENT>return text<EOL><DEDENT>squote = type(text)("<STR_LIT:'>")<EOL>return squote + text.replace(squote, type(text)(r"<STR_LIT>")) + squote<EOL>
Escape given string according to shell rules.