Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

On Windows and macOS, Get-Item and Get-ChildItem report file names as specified, not their actual case #13190

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

Note: The problem:

  • affects only files, not also directories

  • for file paths, affects all path components.

Simple demonstration (macOS and Windows):

PS> (Get-Item $PSHOME/POWERSHELL.config.json).Name
POWERSHELL.config.json

Note how POWERSHELL.config.json was reported via .Name - exactly as specified - even though the actual casing of the filename is powershell.config.json

Steps to reproduce

Windows and macOS only (platforms with case-insensitive (but case-preserving) file-systems).

# Note: The problem occurs only with *files*, not directories.
#       With files, the problem occurs in all path components.
Describe "Get-Item / Get-ChildItem: non-wildcard file-name case fidelity test" {
  BeforeAll {
    Push-Location (Get-Item testdrive:/).FullName
    $nameActual = 'AB'
    $nameCaseVariant = 'aB'
    New-Item $nameActual # create as all-uppercase

    $testCases = 
      @{ Cmdlet = 'Get-Item'; Parameter = 'Path'; Property = 'Name' },
      @{ Cmdlet = 'Get-Item'; Parameter = 'Path'; Property = 'FullName' },
      @{ Cmdlet = 'Get-Item'; Parameter = 'LiteralPath'; Property = 'Name' },
      @{ Cmdlet = 'Get-Item'; Parameter = 'LiteralPath'; Property = 'FullName' },
      @{ Cmdlet = 'Get-ChildItem'; Parameter = 'Path'; Property = 'Name' },
      @{ Cmdlet = 'Get-ChildItem'; Parameter = 'Path'; Property = 'FullName' },
      @{ Cmdlet = 'Get-ChildItem'; Parameter = 'LiteralPath'; Property = 'Name' },
      @{ Cmdlet = 'Get-ChildItem'; Parameter = 'LiteralPath'; Property = 'FullName' }
  }
    
  It "<Cmdlet>: .<Property> should report '$nameActual' as the file name when literal case variant '$nameCaseVariant' is passed to <Parameter>" -Skip:$IsLinux -TestCase $testCases {
    param($Cmdlet, $Parameter, $Property) 
    $htArgs = @{ $Parameter = $nameCaseVariant }
    Split-Path -Leaf (& $Cmdlet @htArgs).$Property | Should -BeExactly $nameActual
  }
  AfterAll {
    Pop-Location
  }
}

Expected behavior

The tests should succeed.

Actual behavior

All tests fail.

Environment data

PowerShell Core 7.1.0-preview.5
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management moduleWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.Waiting - DotNetCorewaiting on a fix/change in .NETwaiting on a fix/change in .NET

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.