Skip to content

Test-Path returns $true for ' ' on Windows #5717

@bergmeister

Description

@bergmeister

Steps to reproduce

Test-Path ' '

Expected behavior

NB: Because the .Net Core method Directory.Exists states in the docs here that trailing whitespaces are removed, the expectation of the last 2 spaces is true.

False

Actual behavior

On Windows:

True

On Linux (Ubuntu 17 or WSL):

False

Environment data

Reproes on the latest daily build of PowerShell Core (December 19, 2017) and Windows PowerShell 5.1

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.1.0-preview.519
PSEdition                      Core
GitCommitId                    v6.1.0-preview.519
OS                             Microsoft Windows 6.3.9600
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Ubuntu 17 VM

Name                           Value
----                           -----
PSVersion                      6.0.0-rc.2
PSEdition                      Core
GitCommitId                    v6.0.0-rc.2
OS                             Linux 4.10.0-42-generic #46-Ubuntu SMP Mon Dec 4 14:38:01 UTC 2017
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

The WSL Linux system

Name                           Value
----                           -----
PSVersion                      6.0.0-rc.2
PSEdition                      Core
GitCommitId                    v6.0.0-rc.2
OS                             Linux 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions