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

Incorrect quoting for file names causes terminal commands to fail (in varying platform-specific ways) #24126

Open
zahlman opened this issue Sep 18, 2024 · 0 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team

Comments

@zahlman
Copy link

zahlman commented Sep 18, 2024

This issue is analogous to #23135 (which I believe was closed prematurely), specific to non-Windows environments using a shell such as sh, bash etc. I am reporting it on behalf of another confused user who actually has VS Code installed (see https://stackoverflow.com/staging-ground/78990765 for details); because I don't, I can't use the in-program process to file a bug report. But this could also be considered as a feature request, I suppose.

Steps to reproduce:

  1. Have a username with !, $ or other specially interpreted character in it, on a Linux or Mac system.
  2. Use a traditional shell.
  3. Attempt to run any Python code whatsoever via the extension.

Expected result:

When a command is generated to run the Python interpreter, it should give the properly escaped path to the file being run in single quotes, so that the shell will interpret it literally. Alternately, it could avoid the problem that the quoting is trying to solve - ensuring that the file path is treated as a single token - by backslash-escaping any spaces instead.

Actual result:

The path is given in double quotes, which have different meaning for these shells. Double quotes enable interpolation with $, as well as history expansion with ! (the issue affecting the poor user I helped). Either way, this prevents successfully invoking Python.

In #23135, the same issue was reported with $ characters in PowerShell, because that shell treats them similarly.

In general, the extension needs to be aware of what shell it's using, and apply appropriate corresponding rules for quoting or escaping. It seems that currently the rule is something like "wrap in double quotes if the path contains a space", which only works for cmd (and even then I'm not 100% sure).

@zahlman zahlman added the feature-request Request for new features or functionality label Sep 18, 2024
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Sep 18, 2024
@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug and removed feature-request Request for new features or functionality labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants