Resolve-path doesn't strip quotes... #16933
Labels
Needs-Repro
The issue author needs to provide repro steps.
Needs-Triage
The issue is new and needs to be triaged by a work group.
Resolution-No Activity
Issue has had no activity for 6 months or more
Prerequisites
Steps to reproduce
ISSUE #1
I think if you want to make powershell easy to use, then the shell should automatically strip quotes around files when calling resolve-path... its always the case that calls to things get nested and its complicated to think if you need quotes or not... my opinion is that powershell resolve-path should always strip quotes... to help users and make it easier to use...
GOOD CASE
PS> $x = "C:\Users\wpmoore\Desktop\VSC_MDU-R\tb\TB_VSC_B2_SRC\AIC Calibration Strobe Signal"
PS> $x
C:\Users\wpmoore\Desktop\VSC_MDU-R\tb\TB_VSC_B2_SRC\AIC Calibration Strobe Signal
PS> Resolve-Path -Path $x
Path
C:\Users\wpmoore\Desktop\VSC_MDU-R\tb\TB_VSC_B2_SRC\AIC Calibration Strobe Signal\
BAD CASE - No automatic quote stripping from files with quotes....
PS> $x = "
"C:\Users\wpmoore\Desktop\VSC_MDU-R\tb\TB_VSC_B2_SRC\AIC Calibration Strobe Signal\
""PS> $p = Resolve-Path -Path $x
Resolve-Path : Cannot find drive. A drive with the name '"C' does not exist.
At line:1 char:6
ISSUE #2:
Actually... While I'm complaining... I don't like that resolve-path doesn't have an option to resolve a path that doesn't exist yet... always need to write this bogus code bullcrap code to get what i want:.
$pathfix = Resolve-Path -Path $file -ErrorAction SilentlyContinue -ErrorVariable ev
if (-not($pathfix)) {
$pathfix - $ev[0].TargetObject
}
This is complete bullcrap... give use a switch to resolve paths that doesn't already exist yet.... it always happens that i need to resolve a path to a place where i;m creating a new file that doens't exist yet.... why not this instead:
PS> $pathfix = Resolve-Path -Path $file -NoRequireExists
now its nice and easy.....
Expected behavior
Actual behavior
Error details
Environment data
Visuals
N/A
The text was updated successfully, but these errors were encountered: