# HG changeset patch # User Micha Wiedenmann # Date 1584630384 -3600 # Node ID b746a22349f9eaa26363b5178ee4de1ba677fbbf # Parent a7f8c657a3f08d1e71ee112f797df011eea7a078 ui: use "procutil.shellsplit" to parse command A commandline containing a space ('"C:\\Program Files\\bar.exe" "..."') must not simply split at whitespace, instead quoting has to be taken into account. Use "shlex.split()" to parse it instead. This can improve the error message if we fail to launch a user configured editor which does not exist. Consider [ui] editor = "C:\Program Files\editor\editor.exe" where the path does not exist. "hg histedit" currently aborts with > Abort: edit failed: Program exited with status 1 here "Program" is not part of the message but the name of the program that failed (i.e. `basename("C:\\Program ")`). With this change the message instead reads > Abort: edit failed: C:\Program Files\editor\editor.exe exited with > status 1 which is also not ideal since infact "cmd.exe" exited with code 1, not the editor. But the real error message ("File not found") gets swallowed by `procutil` and including the correct path improves the error message nevertheless. diff -r a7f8c657a3f0 -r b746a22349f9 mercurial/ui.py --- a/mercurial/ui.py Thu Mar 05 11:02:07 2020 -0500 +++ b/mercurial/ui.py Thu Mar 19 16:06:24 2020 +0100 @@ -1868,7 +1868,7 @@ rc = self._runsystem(cmd, environ=environ, cwd=cwd, out=out) if rc and onerr: errmsg = b'%s %s' % ( - os.path.basename(cmd.split(None, 1)[0]), + procutil.shellsplit(cmd)[0], procutil.explainexit(rc), ) if errprefix: