Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quote tokens when logging pip commands #4761

Merged
merged 1 commit into from
Aug 10, 2021

Conversation

allanlewis
Copy link
Contributor

@allanlewis allanlewis commented Aug 9, 2021

The issue

See #4760.

The fix

In order to improve the logging, this commit shell-quotes each token before joining the results with spaces. This means that users should be able to copy and paste logged commands and run them using any common shell without issue, including when paths contain spaces or other special characters.

The checklist

  • Associated issue
  • A news fragment in the news/ directory to describe this fix with the extension .bugfix, .feature, .behavior, .doc. .vendor. or .trivial (this will appear in the release changelog). Use semantic line breaks and name the file after the issue number or the PR #.

Previously, pip commands were printed as lists of tokens. a82bbb7 amended the
logging to join the tokens with strings. However, this will lead to invalid
commands if any token contains a space or some other special character that
needs to be escaped for standard shells. In order to improve the logging, this
commit shell-quotes each token before joining the results with spaces.
@allanlewis
Copy link
Contributor Author

Please advise if I should add a unit test for cmd_list_to_shell.

@frostming
Copy link
Contributor

That is okay, thanks.

@frostming frostming merged commit 0e7c1fa into pypa:master Aug 10, 2021
@allanlewis allanlewis deleted the quote-commands-when-logging branch August 10, 2021 07:18
@allanlewis
Copy link
Contributor Author

Thanks for the quick response, @frostming 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants