If I have a pwsh script like:
param (
[string[]]$inDirs
)
foreach ($dir in $inDirs){
write-host $dir
}
and I do
pwsh myscript.ps1 'c:\\some\dir\'
The result is
c:\\some\dir"
Where somehow, the last backslash + single quote has been turned into a double quote. This walks like a bug and stinks like a bug, particularly as the other backslashes don't escape anything, just the one next to the single quote, and that the "escaped" character isn't one that is in the original string, but apparently it's as-designed.
Obviously I can call the script and take care not to add a trailing slash, but guess what happens if I use tab-completion to supply the name of a directory? "Hi, I'm clippy, it seems like you're tab-completing a directory path, I'll just go ahead and add a good ol' trailing slash for you there".
Tested with pwsh 7.5.2 on Windows Server 2019 Datacenter
powershell.exeas the host and the path needs to have a space in it - (i) start apowershell.exeinteractive session (ii) runpwsh myscript.ps1 'c:\\some\ dir\'(note the space beforedir\(iii) the script outputsc:\\some\ dir".pwsh myscript.ps1 "'c:\\some\ dir\'"