Avoid escaping paths when editing credentials #44910
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Shellwords.escape
escapes unquoted spaces with a backslash, but Windows does not treat backslash as an escape character. Escaping is also a problem when paths are expressed in shortened 8.3 format (e.g.C:\Users\RubyOn~1\AppData\Local\Temp\...
) because a backslash will be erroneously added before the~
.We can avoid the need to escape by using
system(command_name, *args)
instead ofsystem(command_line)
, but we must still supportENV["EDITOR"]
values that embed command line arguments, such assubl -w
.This commit changes to
system(command_name, *args)
, but usesShellwords.split
to extract any embedded arguments fromENV["EDITOR"]
. This requires that Windows users put quotes around the entire path of their editor if it contains spaces, such as:In other words, the following are not supported on Windows:
Fixes #41617 (again).
Closes #44890.
This is based on my suggestion in #42728 (comment), with a fix for the test I mentioned in #42728 (comment).
/cc @ariccio @joshleblanc Would it be possible for you to test this change locally, and verify that it solves your issue?