Respect -Qualifier/-NoQualifier/-Leaf/-IsAbsolute:$false in Split-Path#26474
Merged
iSazonov merged 4 commits intoPowerShell:masterfrom Nov 21, 2025
Merged
Respect -Qualifier/-NoQualifier/-Leaf/-IsAbsolute:$false in Split-Path#26474iSazonov merged 4 commits intoPowerShell:masterfrom
iSazonov merged 4 commits intoPowerShell:masterfrom
Conversation
…e:$false parameter values in Split-Path
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where Split-Path cmdlet doesn't respect explicit :$false values for switch parameters -Qualifier, -NoQualifier, -Leaf, and -IsAbsolute. Previously, these switches behaved identically whether set to $true or $false due to the code checking parameter set names instead of actual boolean values.
- Converted switch-case statement to if-else chain that checks actual boolean values of switch parameters
- Added comprehensive test coverage for all four affected parameters with explicit
:$falsevalues
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs | Refactored ProcessRecord method to check switch parameter boolean values instead of parameter set names, enabling proper handling of explicit :$false values |
| test/powershell/Modules/Microsoft.PowerShell.Management/Split-Path.Tests.ps1 | Added 4 new test cases validating that -Qualifier:$false, -NoQualifier:$false, -Leaf:$false, and -IsAbsolute:$false correctly fall back to default parent path behavior; also fixed formatting spacing issue on existing test |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/powershell/Modules/Microsoft.PowerShell.Management/Split-Path.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Split-Path.Tests.ps1
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs
Show resolved
Hide resolved
…Path.Tests.ps1 Co-authored-by: Copilot <[email protected]>
…Path.Tests.ps1 Co-authored-by: Copilot <[email protected]>
iSazonov
reviewed
Nov 19, 2025
src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs
Outdated
Show resolved
Hide resolved
iSazonov
approved these changes
Nov 19, 2025
SIRMARGIN
pushed a commit
to SIRMARGIN/PowerShell
that referenced
this pull request
Dec 12, 2025
kilasuit
pushed a commit
to kilasuit/PowerShell
that referenced
this pull request
Jan 2, 2026
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
This PR fixes the issue where
-Qualifier:$false,-NoQualifier:$false,-Leaf:$false, and-IsAbsolute:$falseare not respected inSplit-Path, causing them to behave the same as their$truecounterparts.Fixes #26470
Related to #25242
PR Context
When these switch parameters are explicitly set to
$falseforSplit-Path, the cmdlet incorrectly behaves as if they were set to$true. This occurs because the code usesParameterSetName(a string) in a switch statement instead of checking the actual boolean values of the switch parameters.This fix converts the switch statement to an if-else chain that directly checks each switch parameter's boolean value, ensuring that explicit
$falsevalues are properly respected.Changes
ParsePathCommand.cs: Converted the switch statement to an if-else chain that checks the actual boolean values of-IsAbsolute,-Qualifier,-Leaf/-LeafBase/-Extension, and-NoQualifierSplit-Path.Tests.ps1to verify each switch parameter respects:$falseTesting
:$falseparameter handling:$false, the cmdlet falls back to default behavior (returning the parent path)PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header