Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Test-Path -IsValid -PathType Leaf doesn't correctly recognize a leaf #8607
This issue is about an incorrect validation of the
When a path ends with a backslash it is supposed to be a container.
Furthermore, according to the official documentation:
However, when using the
For example, the following command line returns
It should return false because a leaf path cannot end with a backslash.
This behavior has been tested on PowerShell 5.1 and 6.1.1.
Hi @fullenw1 There are a couple of things to be aware of here. First, if
PSCore > Test-Path -IsValid foo -PathType leaf True PSCore > Test-Path -IsValid foo -PathType Container True
Second, when it is used by itself,
PSCore > test-path -PathType Container $profile/ False PSCore > test-path -PathType Leaf $profile/ True
Likewise, when using the
PSCore > Split-Path -Leaf a\b\c\ c
Thank you for the explanation.
The breaking change (puting them in separate parameter sets) in the next version would probably be the logical way to go.