Skip to content

F5 with script containing single quotes results in 'not recognized as a ....' error #4269

Closed
PowerShell/PowerShellEditorServices
#1957
@msftrncs

Description

@msftrncs

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Following #4238, anytime an argument is quoted, it needs to have existing quotes escaped. On Windows, single quotes can appear in the file name/file path, but double quotes cannot, but on 'nix, both can.

I created a script with quotes in the file name (this is not at all unusual for me), added something simple to the script file, and then pressed F5 to attempt to run it, and received an error that the path was invalid.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.3.0
PSEdition                      Core
GitCommitId                    7.3.0
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}       
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.73.1
6261075646f055b99068d3688932416f2346dd3b
x64

Extension Version

ms-vscode.powershell@2022.11.0        
ms-vscode.powershell-preview@2022.11.0

Steps to Reproduce

Create script with single quotes and press F5 to run.

Visuals

image

Logs

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions