, POSIX, :
def shell_escape(arg):
return "'%s'" % (arg.replace(r"'", r"'\''"), )
?
POSIX :
('') . .
, . - , , . ( '), (\'), ( ').
?
POSIX. bash. Solaris 5.10 /bin/sh (, , POSIX, ), , .
, . , ssh ( /etc/passwd ). , , /usr/bin/python git-shell - , , , -, , , .
csh/tcsh
, tcsh, , paramiko exec_command . ( /usr/bin/python , , ...)
tcsh, , . , , . , , tcsh :
$ tcsh -c $'echo \'foo\nbar\''
Unmatched '.
Unmatched '.
, , , , tcsh ( , , , , ,...).
, , :
- (
\n, \t,...) - (
', ", \) - (
*, ?, [] ..) - (
|, &, ||, &&,...) - Newlines
. re.escape - -- , POSIX escape- (, Python, "\\\n") - , . , re.escape , -, , . , , re.escape (, ) API.
, escape- , - , , , . printf "%s\n" escaped-string-to-test, , . echo : echo \n. /bin/echo , Solaris 5.10, , , \n.