question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Translating PSDrive-based path arguments for external (native) executables is overzealous (PSNativePSPathResolution)

See original GitHub issue

PR #12386 introduced experimental feature PSNativePSPathResolution, which as of (at least) PowerShell Core 7.1.0-preview.7 has become a default feature.

  • For problems with this feature in general, see #13644

Its purpose is to translate PowerShell-drive-based paths to native filesystem paths, because external executables only understand the latter.

This translation is currently overzealous in that it nonsensically translates an argument that starts with : (which clearly isn’t a drive-based path).

@DHowett has pinpointed the problematic behavior to: https://github.com/PowerShell/PowerShell/blob/3effa204103460c996a8612aa70718fdf924047d/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs#L388-L406

Steps to reproduce

On Unix:

/bin/echo :foo | Should -Be ':foo'

On Windows:

cmd /c echo :foo | Should -Be ':foo'

Expected behavior

The test should succeed.

Actual behavior

The test fails, because the the current location’s path is unexpectedly prepended to :

Expected strings to be the same, but they were different. Expected length: 4 Actual length:   44 Strings differ at index 0.
Expected: ':foo' But was:  '/Users/jdoe...'

Environment data

PowerShell Core 7.1.0-preview.7

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:24 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
DHowettcommented, Sep 18, 2020

I do not believe that Issue-Question is the appropriate label for this issue. This is a significant regression in native tool use from one preview release to another, and we are at risk of shipping with it.

2reactions
SteveL-MSFTcommented, Oct 2, 2020

For 7.1, I’m going to revert the change to make this non-experimental

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's New in PowerShell 7.3
PowerShell 7.3.1 adds sqlcmd.exe to the list of native commands in Windows that use the Legacy style of argument passing.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found