##// END OF EJS Templates
posix: quote the specified string only when it may have to be quoted...
FUJIWARA Katsunori -
r23683:5edb3871 default
parent child Browse files
Show More
@@ -8,7 +8,7 b''
8 from i18n import _
8 from i18n import _
9 import encoding
9 import encoding
10 import os, sys, errno, stat, getpass, pwd, grp, socket, tempfile, unicodedata
10 import os, sys, errno, stat, getpass, pwd, grp, socket, tempfile, unicodedata
11 import fcntl
11 import fcntl, re
12
12
13 posixfile = open
13 posixfile = open
14 normpath = os.path.normpath
14 normpath = os.path.normpath
@@ -315,9 +315,16 b" if sys.platform == 'cygwin':"
315 def checklink(path):
315 def checklink(path):
316 return False
316 return False
317
317
318 _needsshellquote = None
318 def shellquote(s):
319 def shellquote(s):
319 if os.sys.platform == 'OpenVMS':
320 if os.sys.platform == 'OpenVMS':
320 return '"%s"' % s
321 return '"%s"' % s
322 global _needsshellquote
323 if _needsshellquote is None:
324 _needsshellquote = re.compile(r'[^a-zA-Z0-9._/-]').search
325 if not _needsshellquote(s):
326 # "s" shouldn't have to be quoted
327 return s
321 else:
328 else:
322 return "'%s'" % s.replace("'", "'\\''")
329 return "'%s'" % s.replace("'", "'\\''")
323
330
@@ -114,11 +114,11 b' issue4463: usage of command line configu'
114 running '*echo* *\\a *\\a' in */extdiff.* (glob)
114 running '*echo* *\\a *\\a' in */extdiff.* (glob)
115 #else
115 #else
116 $ hg --debug 4463a | grep '^running'
116 $ hg --debug 4463a | grep '^running'
117 running '\'echo\' a-naked \'single quoted\' "double quoted" \'*/a\' \'$TESTTMP/a/a\'' in */extdiff.* (glob)
117 running 'echo a-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob)
118 $ hg --debug 4463b | grep '^running'
118 $ hg --debug 4463b | grep '^running'
119 running 'echo b-naked \'single quoted\' "double quoted" \'*/a\' \'$TESTTMP/a/a\'' in */extdiff.* (glob)
119 running 'echo b-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob)
120 $ hg --debug echo | grep '^running'
120 $ hg --debug echo | grep '^running'
121 running "'*echo*' '*/a' '$TESTTMP/a/a'" in */extdiff.* (glob)
121 running '*echo */a $TESTTMP/a/a' in */extdiff.* (glob)
122 #endif
122 #endif
123
123
124 (getting options from other than extdiff section)
124 (getting options from other than extdiff section)
@@ -149,15 +149,15 b' issue4463: usage of command line configu'
149 running 'echo echo-naked "being quoted" *\\a *\\a' in */extdiff.* (glob)
149 running 'echo echo-naked "being quoted" *\\a *\\a' in */extdiff.* (glob)
150 #else
150 #else
151 $ hg --debug 4463b2 | grep '^running'
151 $ hg --debug 4463b2 | grep '^running'
152 running 'echo b2-naked \'single quoted\' "double quoted" \'*/a\' \'$TESTTMP/a/a\'' in */extdiff.* (glob)
152 running 'echo b2-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob)
153 $ hg --debug 4463b3 | grep '^running'
153 $ hg --debug 4463b3 | grep '^running'
154 running 'echo b3-naked \'single quoted\' "double quoted" \'*/a\' \'$TESTTMP/a/a\'' in */extdiff.* (glob)
154 running 'echo b3-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob)
155 $ hg --debug 4463b4 | grep '^running'
155 $ hg --debug 4463b4 | grep '^running'
156 running "echo '*/a' '$TESTTMP/a/a'" in */extdiff.* (glob)
156 running 'echo */a $TESTTMP/a/a' in */extdiff.* (glob)
157 $ hg --debug 4463b4 --option 'being quoted' | grep '^running'
157 $ hg --debug 4463b4 --option b4-naked --option 'being quoted' | grep '^running'
158 running "echo 'being quoted' '*/a' '$TESTTMP/a/a'" in */extdiff.* (glob)
158 running "echo b4-naked 'being quoted' */a $TESTTMP/a/a" in */extdiff.* (glob)
159 $ hg --debug extdiff -p echo --option 'being quoted' | grep '^running'
159 $ hg --debug extdiff -p echo --option echo-naked --option 'being quoted' | grep '^running'
160 running "'echo' 'being quoted' '*/a' '$TESTTMP/a/a'" in */extdiff.* (glob)
160 running "echo echo-naked 'being quoted' */a $TESTTMP/a/a" in */extdiff.* (glob)
161 #endif
161 #endif
162
162
163 #if execbit
163 #if execbit
@@ -273,7 +273,7 b' Fallback to merge-tools.tool.executable|'
273 making snapshot of 2 files from working directory
273 making snapshot of 2 files from working directory
274 a
274 a
275 b
275 b
276 running "'$TESTTMP/a/dir/tool.sh' 'a.*' 'a'" in */extdiff.* (glob)
276 running '$TESTTMP/a/dir/tool.sh a.* a' in */extdiff.* (glob)
277 ** custom diff **
277 ** custom diff **
278 cleaning up temp directory
278 cleaning up temp directory
279 [1]
279 [1]
General Comments 0
You need to be logged in to leave comments. Login now