Skip to content
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

Workaround Powershell 6.2/7.0 breaking compatibility with Get-ChildItem #8013

Closed
wants to merge 1 commit into from

Conversation

TheGoddessInari
Copy link
Contributor

Powershell 6.2/7.0 in infinite wisdom decided to change the value of
what Get-ChildItem (and anything dealing with FileInfo/DirectoryInfo)
returns from relative to absolute path.

The only way to work around this for both existing versions and future
versions is to explicitly request the Name. Hopefully this doesn't
get changed again.

NOTE: This PS change breaks a lot of scripts, including many
of Microsoft's own first-party scripts. No workarounds were pushed
for any that I could see in the year+ since the issue was first
reported.

Powershell 6.2/7.0 in infinite wisdom decided to change the value of
what `Get-ChildItem` (and anything dealing with FileInfo/DirectoryInfo)
returns from relative to absolute path.

The only way to work around this for both existing versions and future
versions is to explicitly request the `Name`. Hopefully this doesn't
get changed again.

NOTE: This PS change breaks a lot of scripts, including many
of Microsoft's own first-party scripts. No workarounds were pushed
for any that I could see in the year+ since the issue was first
reported.
@strega-nil
Copy link
Contributor

strega-nil commented Sep 6, 2019

This looks good to me, and is more correct. Thanks @TheGoddessInari

bitmoji

I'm going to modify the commit message, though.

strega-nil pushed a commit that referenced this pull request Sep 6, 2019
In Powershell 6.2/7.0, `Get-ChildItem`'s paths are now printed as
absolute paths instead of relative paths; this breaks the code we have
that assumes that they're printed as relative paths.

Thus, change the code to request the `Name` property specifically, which
is what we actually wanted.
@strega-nil strega-nil closed this Sep 6, 2019
@TheGoddessInari TheGoddessInari deleted the fix-pwsh branch October 2, 2019 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants