Show More
@@ -148,10 +148,20 b' def samestat(s1, s2):' | |||||
148 | # backslash before every double quote (being careful with the double |
|
148 | # backslash before every double quote (being careful with the double | |
149 | # quote we've appended to the end) |
|
149 | # quote we've appended to the end) | |
150 | _quotere = None |
|
150 | _quotere = None | |
|
151 | _needsshellquote = None | |||
151 | def shellquote(s): |
|
152 | def shellquote(s): | |
152 | global _quotere |
|
153 | global _quotere | |
153 | if _quotere is None: |
|
154 | if _quotere is None: | |
154 | _quotere = re.compile(r'(\\*)("|\\$)') |
|
155 | _quotere = re.compile(r'(\\*)("|\\$)') | |
|
156 | global _needsshellquote | |||
|
157 | if _needsshellquote is None: | |||
|
158 | # ":" and "\\" are also treated as "safe character", because | |||
|
159 | # they are used as a part of path name (and the latter doesn't | |||
|
160 | # work as "escape character", like one on posix) on Windows | |||
|
161 | _needsshellquote = re.compile(r'[^a-zA-Z0-9._:/\\-]').search | |||
|
162 | if not _needsshellquote(s) and not _quotere.search(s): | |||
|
163 | # "s" shouldn't have to be quoted | |||
|
164 | return s | |||
155 | return '"%s"' % _quotere.sub(r'\1\1\\\2', s) |
|
165 | return '"%s"' % _quotere.sub(r'\1\1\\\2', s) | |
156 |
|
166 | |||
157 | def quotecommand(cmd): |
|
167 | def quotecommand(cmd): |
@@ -107,11 +107,11 b' issue4463: usage of command line configu' | |||||
107 | $ echo a >> a |
|
107 | $ echo a >> a | |
108 | #if windows |
|
108 | #if windows | |
109 | $ hg --debug 4463a | grep '^running' |
|
109 | $ hg --debug 4463a | grep '^running' | |
110 |
running ' |
|
110 | running 'echo a-naked \'single quoted\' "double quoted" *\\a *\\a' in */extdiff.* (glob) | |
111 | $ hg --debug 4463b | grep '^running' |
|
111 | $ hg --debug 4463b | grep '^running' | |
112 |
running 'echo b-naked \'single quoted\' "double quoted" |
|
112 | running 'echo b-naked \'single quoted\' "double quoted" *\\a *\\a' in */extdiff.* (glob) | |
113 | $ hg --debug echo | grep '^running' |
|
113 | $ hg --debug echo | grep '^running' | |
114 |
running ' |
|
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) | |
@@ -138,15 +138,15 b' issue4463: usage of command line configu' | |||||
138 | > EOF |
|
138 | > EOF | |
139 | #if windows |
|
139 | #if windows | |
140 | $ hg --debug 4463b2 | grep '^running' |
|
140 | $ hg --debug 4463b2 | grep '^running' | |
141 |
running 'echo b2-naked \'single quoted\' "double quoted" |
|
141 | running 'echo b2-naked \'single quoted\' "double quoted" *\\a *\\a' in */extdiff.* (glob) | |
142 | $ hg --debug 4463b3 | grep '^running' |
|
142 | $ hg --debug 4463b3 | grep '^running' | |
143 |
running 'echo b3-naked \'single quoted\' "double quoted" |
|
143 | running 'echo b3-naked \'single quoted\' "double quoted" *\\a *\\a' in */extdiff.* (glob) | |
144 | $ hg --debug 4463b4 | grep '^running' |
|
144 | $ hg --debug 4463b4 | grep '^running' | |
145 |
running 'echo |
|
145 | running 'echo *\\a *\\a' in */extdiff.* (glob) | |
146 | $ hg --debug 4463b4 --option 'being quoted' | grep '^running' |
|
146 | $ hg --debug 4463b4 --option b4-naked --option 'being quoted' | grep '^running' | |
147 |
running 'echo "being quoted" |
|
147 | running 'echo b4-naked "being quoted" *\\a *\\a' in */extdiff.* (glob) | |
148 | $ hg --debug extdiff -p echo --option 'being quoted' | grep '^running' |
|
148 | $ hg --debug extdiff -p echo --option echo-naked --option 'being quoted' | grep '^running' | |
149 |
running ' |
|
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) |
General Comments 0
You need to be logged in to leave comments.
Login now