Skip to content

PowerShell command corruption with escape characters in file paths #4885

@s23010843

Description

@s23010843

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

Remove-Item : A parameter cannot be found that matches parameter name 'ForceRemove-Item'.
At line:1 char:772
+ ... \main\res\drawable\file.xml" -ForceRemove-Item "C:\Project ...
+                                               ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Remove-Item], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

Screenshot

N/A

Environment data

PS Version: 5.1.19041.6093
PS HostName: ConsoleHost
PSReadLine Version: 2.0.0-beta2
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 48
BufferHeight: 12

Steps to reproduce

  1. Open PowerShell in VS Code terminal
  2. Execute a long Remove-Item command with multiple file paths:
    Remove-Item "C:\Project\file1.xml", "C:\Project\file2.xml", "C:\Project\file3.xml", "C:\Project\file4.xml", "C:\Project\file5.xml", "C:\Project\file6.xml", "C:\Project\file7.xml", "C:\Project\file8.xml" -Force
  3. Command gets corrupted during PSReadLine processing
  4. Error occurs with malformed parameter syntax

Expected behavior

The PowerShell command should execute properly without corruption:

  • File paths should maintain proper backslash characters ()
  • Parameters should remain separate (-Force should not concatenate)
  • Multiple file deletion should complete successfully

Actual behavior

The command gets corrupted during execution:

  • Backslashes () are replaced with hex escape sequences (\x5c)
  • The -Force parameter gets concatenated becoming "-ForceRemove-Item"
  • File paths are truncated and corrupted mid-execution
  • Results in ParameterBindingException

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions