##// END OF EJS Templates
util: factor out shellsplit() function...
Yuya Nishihara -
r36433:0cb09c32 default
parent child Browse files
Show More
@@ -1240,9 +1240,7 b' def debuginstall(ui, **opts):'
1240 # editor
1240 # editor
1241 editor = ui.geteditor()
1241 editor = ui.geteditor()
1242 editor = util.expandpath(editor)
1242 editor = util.expandpath(editor)
1243 editorbin = pycompat.shlexsplit(editor, posix=not pycompat.iswindows)[0]
1243 editorbin = util.shellsplit(editor)[0]
1244 if pycompat.iswindows and editorbin[0] == '"' and editorbin[-1] == '"':
1245 editorbin = editorbin[1:-1]
1246 fm.write('editor', _("checking commit editor... (%s)\n"), editorbin)
1244 fm.write('editor', _("checking commit editor... (%s)\n"), editorbin)
1247 cmdpath = util.findexe(editorbin)
1245 cmdpath = util.findexe(editorbin)
1248 fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound',
1246 fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound',
@@ -461,6 +461,10 b' def shellquote(s):'
461 else:
461 else:
462 return "'%s'" % s.replace("'", "'\\''")
462 return "'%s'" % s.replace("'", "'\\''")
463
463
464 def shellsplit(s):
465 """Parse a command string in POSIX shell way (best-effort)"""
466 return pycompat.shlexsplit(s, posix=True)
467
464 def quotecommand(cmd):
468 def quotecommand(cmd):
465 return cmd
469 return cmd
466
470
@@ -147,6 +147,7 b' setbinary = platform.setbinary'
147 setflags = platform.setflags
147 setflags = platform.setflags
148 setsignalhandler = platform.setsignalhandler
148 setsignalhandler = platform.setsignalhandler
149 shellquote = platform.shellquote
149 shellquote = platform.shellquote
150 shellsplit = platform.shellsplit
150 spawndetached = platform.spawndetached
151 spawndetached = platform.spawndetached
151 split = platform.split
152 split = platform.split
152 sshargs = platform.sshargs
153 sshargs = platform.sshargs
@@ -296,6 +296,15 b' def shellquote(s):'
296 return s
296 return s
297 return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
297 return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
298
298
299 def _unquote(s):
300 if s.startswith(b'"') and s.endswith(b'"'):
301 return s[1:-1]
302 return s
303
304 def shellsplit(s):
305 """Parse a command string in cmd.exe way (best-effort)"""
306 return pycompat.maplist(_unquote, pycompat.shlexsplit(s, posix=False))
307
299 def quotecommand(cmd):
308 def quotecommand(cmd):
300 """Build a command string suitable for os.popen* calls."""
309 """Build a command string suitable for os.popen* calls."""
301 if sys.version_info < (2, 7, 1):
310 if sys.version_info < (2, 7, 1):
General Comments 0
You need to be logged in to leave comments. Login now