Skip to content

Extension should be aware of what shell type user is using to send shell specific escaped commands #24126

Open

Description

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).

Activity

  1. added
    bugIssue identified by VS Code Team member as probable bug
    and removed
    feature-requestRequest for new features or functionality
    on Sep 18, 2024
  2. added
    needs spikeLabel for issues that need investigation before they can be worked on.
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Dec 9, 2024
  3. anthonykim1 commented on Dec 9, 2024

    @anthonykim1

    Thanks for this, this is great point. This is actually on the plan and we would actually be able to do this via microsoft/vscode#230165 is resolved. Lets track it: microsoft/vscode#230165

    Going to leave this open so you can verify once extensions have access to shell type and we are able to use the info to properly escape in shell specific way.

  4. changed the title [-]Incorrect quoting for file names causes terminal commands to fail (in varying platform-specific ways)[/-] [+]Extension should be aware of what shell type user is using to send shell specific escaped commands[/+] on Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugneeds spikeLabel for issues that need investigation before they can be worked on.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions