Description
Prerequisites
- Write a descriptive title.
Description of the new feature/enhancement
As PowerShell/PowerShell#24037 (comment) explains:
Expected behaviour
Originally, this issue was going to be about how PowerShell can't handle certain legal UTF-8 characters in inode paths. However, after creating a test script:
#!/usr/bin/env pwsh # Prerequisites # ------------- # ~~~pwsh # #Requires -PSEdition 'Core' # #Requires -Version 7 # ~~~ Set-Location -LiteralPath "$HOME" # Example Directory # ----------------- # Creates an example directory. $DirectoryPath = 'TabPrefixed ExampleDirectory.dir' $PrintPath = "$DirectoryPath" Write-Output (Show-Markdown -InputObject "The path is ``$PrintPath``.") New-Item ` -Path "$HOME" ` -Name "$DirectoryPath" ` -ItemType 'directory' # Example File # ------------ # Creates an example file. $FilePath = 'TabPrefixed ExampleFile.txt' $PrintPath = "$FilePath" Write-Output (Show-Markdown -InputObject "The path is ``$PrintPath``.") New-Item ` -Path ("$HOME" + [IO.Path]::DirectorySeparatorChar + "$DirectoryPath") ` -Name "$FilePath" ` -ItemType 'file' ` -Value 'Example text.' # Path Acquisition # ---------------- # Lists both. $FullFilePath = (` Get-ChildItem ` -LiteralPath ( "$HOME" + [IO.Path]::DirectorySeparatorChar + "$DirectoryPath" + [IO.Path]::DirectorySeparatorChar + "$FilePath") )[0] | Select-Object -ExpandProperty 'FullName' # File Content Acquisition # ------------------------ # This should fail. $PrintPath = "$FullFilePath" Write-Output (Show-Markdown -InputObject "The path is ``$PrintPath``.") Get-Content -LiteralPath "$FullFilePath" Write-Output $?I realized that it could. Instead, I've narrowed it to a fault in how PowerShell, via Konsole and VSCode's terminals, interprets certain characters (like
- tabs) as control codes.
Steps to reproduce
Try pasting your equivalent to the undermentioned command:
#!/usr/bin/env pwsh Get-Content -LiteralPath '/home/RokeJulianLockhart/TabPrefixed ExampleDirectory.dir/TabPrefixed ExampleFile.txt'...into the shell after successfully invoking it.
This value is able to be acquired by the undermentioned command:
#!/usr/bin/env pwsh (Get-ChildItem -LiteralPath "$DirectoryPath")[0].FullNameActual behavior
The undermentioned is a command that has been pasted:
#!/usr/bin/env pwsh Get-Content -LiteralPath "/home/RokeJulianLockhart/Documents/pyside6/prefix^Iexample.txt/example.txt"Note within it, the "
prefix^Iexample
". The original content does not contain that control code.Alternatively, sometimes, it appears to paste the path correctly, but doesn't recognise the value unless passed in a script:
PS /home/RokeJulianLockhart> (Get-ChildItem -LiteralPath "$DirectoryPath")[0].FullName /home/RokeJulianLockhart/TabPrefixed ExampleDirectory.dir/TabPrefixed ExampleFile.txt PS /home/RokeJulianLockhart> Get-Content -LiteralPath '/home/RokeJulianLockhart/TabPrefixed ExampleDirectory.dir/TabPrefixed ExampleFile.txt' Get-Content: Cannot find path '/home/RokeJulianLockhart/TabPrefixed ExampleDirectory.dir/TabPrefixed ExampleFile.txt' because it does not exist. PS /home/RokeJulianLockhart> Get-Content -LiteralPath "$FullFilePath" Example text. PS /home/RokeJulianLockhart> Write-Output "$FullFilePath" /home/RokeJulianLockhart/TabPrefixed ExampleDirectory.dir/TabPrefixed ExampleFile.txtVisuals
Screencast_20240710_125007.webm
Proposed technical implementation details (optional)
No response