Skip to content

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

Open
@zahlman

Description

@zahlman

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

Metadata

Metadata

Assignees

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