8000 Resolve-path doesn't strip quotes... · Issue #16933 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Resolve-path doesn't strip quotes... #16933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks done
wm2015email opened this issue Feb 28, 2022 · 3 comments
Closed
5 tasks done

Resolve-path doesn't strip quotes... #16933

wm2015email opened this issue Feb 28, 2022 · 3 comments
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

Comments

@wm2015email
Copy link

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

  • $p = Resolve-Path -Path $x
  •  ~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: ("C:String) [Resolve-Path], DriveNotFoundException
    • FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand

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

PS> $x = "`"C:\Users\wpmoore\Desktop\VSC_MDU-R\tb\TB_VSC_B2_SRC\AIC Calibration Strobe Signal\`""
PS> $p = Resolve-Path -Path $x
PS> Resolve-Path -Path $x

Path
----
C:\Users\wpmoore\Desktop\VSC_MDU-R\tb\TB_VSC_B2_SRC\AIC Calibration Strobe Signal\

Actual behavior

# 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
+ $p = Resolve-Path -Path $x
+      ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: ("C:String) [Resolve-Path], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand

Error details

Resolve-Path : Cannot find drive. A drive with the name '"C' does not exist.
At line:1 char:6
+ $p = Resolve-Path -Path $x
+      ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: ("C:String) [Resolve-Path], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand

Environment data

Resolve-Path : Cannot find drive. A drive with the name '"C' does not exist.
At line:1 char:6
+ $p = Resolve-Path -Path $x
+      ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: ("C:String) [Resolve-Path], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand

Visuals

N/A

@wm2015email wm2015email added the Needs-Triage The issue is new and needs to be triaged by a work group. label Feb 28, 2022
@iSazonov
Copy link
Collaborator
iSazonov commented Mar 2, 2022

Please split to 2 issues.

@SydneyhSmith SydneyhSmith added the Needs-Repro The issue author needs to provide repro steps. label May 16, 2022
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Resolution-No Activity Issue has had no activity for 6 months or more label Nov 15, 2023
Copy link
Contributor

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants
0