Skip to content

Commit

Permalink
Use shell=True for opening the user-provided editor with pip config
Browse files Browse the repository at this point in the history
This makes the behavior compatible with git and other tools that invoke
the editor in this manner.
  • Loading branch information
pradyunsg committed Jun 17, 2022
1 parent 6c2013c commit 57ae74f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pip/_internal/commands/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,13 @@ def open_in_editor(self, options: Values, args: List[str]) -> None:
fname = self.configuration.get_file_to_edit()
if fname is None:
raise PipError("Could not determine appropriate file.")
elif '"' in fname:
# This shouldn't happen, unless we see a username like that.
# If that happens, we'd appreciate a pull request fixing this.
raise PipError('Can not open an editor for a file name containing ".')

try:
subprocess.check_call([editor, fname])
subprocess.check_call(f'{editor} "{fname}"', shell=True)
except FileNotFoundError as e:
if not e.filename:
e.filename = editor
Expand Down

0 comments on commit 57ae74f

Please sign in to comment.